Existing crack recognition methods based on deep learning often face difficulties when detecting cracks in complex scenes such as brake marks, water marks, and shadows. The inadequate amount of available data can be primarily attributed to this factor. To address this issue, a controllable generative model of pavement cracks is proposed that can generate crack images in complex scenes by leveraging background images and crack mask images. The proposed model, the crack diffusion model (CDM), is based on the diffusion model network, which enables better control over the position and morphology of cracks by adjusting the conditional input of cracks. Experiments show that CDM has several advantages, including high definition, controllability, and sensitivity to narrow cracks. Utilizing CDM to create a synthetic crack data set in complex scenes resulted in substantial improvements of crack detection and segmentation. The method proposed in this study can effectively alleviate the effort required for data acquisition and labeling, especially in complex scenes.