| Casting technology gains comprehensive application in industrial manufacture because of its low cost,short production cycle and flexible production methods,which also promotes the rapid development of China's auto market.In order to ensure the quality and safety of automobiles,foundry manufacturers continue to enhance the detection of casting defects in the production process.The widely used X-ray automatic detection technology in industry,which has higher stability and consistency than artificial defect detection.In order to further improve the X-ray detection technology and the accuracy of automatic defect recognition algorithm,collecting a large number of X-ray defect samples for further study is necessary.Face of the problems such as the low defective product rate and difficulty in sample collection of foundry products,this paper proposes an image simulation algorithm for shrinkage defects based on texture synthesis.It not only obtains good simulation results,but provides reference value for the study of other types of defects simulation algorithms.According to the visually non-uniform texture characteristic of shrinkage defects,this paper proposes a shrinkage defect image generation algorithm based on the KD tree search algorithm.The algorithm is mainly divided into three stages,including the stages of preparatory,of searching and matching for pending synthesis area and of simulated image generation.The specific content is as follows:1)According to the formation process and visual characteristics of casting shrinkage defects,a method of searching image blocks using KD tree is proposed to generate a simulation shrinkage defect with randomness.To increase the speed of computing,principal component analysis method is used to integrate and compress the data set,which greatly reduces the amount of calculation.2)This paper uses the prominent denoising and edge-preserving features of the bilateral filter to denoise the collected X-ray defect images.For the facilitation of the defect generation and the smoothness of the subsequent image fusion progress,this paper proposes a method of difference background removal based on gray distribution.3)A gray-weighted fusion algorithm is used to achieve the boundary fusion between the matching block and the synthesized region,and obtain a complete simulation X-ray image with shrinkage defects,which further to achieve a better fusion effect between simulation defects and background.4)The quality of the simulated defect image generated by the algorithm is evaluated from both subjective and objective aspects.Subjective quality assessment is in the view of human vision,while objective quality assessment uses SSIM and convolutional neural network defect detection.The three experiments all give positive result,which verifies the validity of the simulated defect images generated in this paper.It also summarizes the shortcomings of the algorithm and the future research direction. |