CN109087370B - Method for generating spongy defect image of casting - Google Patents
Method for generating spongy defect image of casting Download PDFInfo
- Publication number
- CN109087370B CN109087370B CN201810697178.4A CN201810697178A CN109087370B CN 109087370 B CN109087370 B CN 109087370B CN 201810697178 A CN201810697178 A CN 201810697178A CN 109087370 B CN109087370 B CN 109087370B
- Authority
- CN
- China
- Prior art keywords
- image
- skeleton
- defect
- randomly
- spongy
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
- 230000007547 defect Effects 0.000 title claims abstract description 70
- 238000005266 casting Methods 0.000 title claims abstract description 27
- 238000000034 method Methods 0.000 title claims abstract description 21
- 238000001914 filtration Methods 0.000 claims abstract description 10
- 238000013507 mapping Methods 0.000 claims 2
- 230000000694 effects Effects 0.000 abstract description 4
- 238000004422 calculation algorithm Methods 0.000 description 4
- 238000010586 diagram Methods 0.000 description 3
- 238000012360 testing method Methods 0.000 description 3
- 238000012549 training Methods 0.000 description 3
- 238000010521 absorption reaction Methods 0.000 description 2
- 230000002950 deficient Effects 0.000 description 2
- 238000001514 detection method Methods 0.000 description 2
- 230000004927 fusion Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 238000006467 substitution reaction Methods 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 238000004088 simulation Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T11/00—2D [Two Dimensional] image generation
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Image Processing (AREA)
- Analysing Materials By The Use Of Radiation (AREA)
Abstract
The invention discloses a method for generating a spongy defect image of a casting, which comprises the following steps: (1) randomly generating a spongy defect skeleton image, wherein the steps of defining an initial skeleton, randomly generating branch skeletons according to a preset skeleton number, determining a reference curve of the skeleton, randomly generating an offset for each skeleton compared with the reference curve, and randomly setting initial gray levels for all the skeletons; the upper and lower lines of each framework are randomly offset for a certain distance, and the gray scale between the upper and lower lines is randomly adjusted by a difference value; (2) filtering the skeleton image; (3) superposing noise in the filtered image; (4) and superposing the image added with the noise on the casting image to obtain a spongy defect image. The method of the invention has the advantages of diversified defects, controllable shape and size through parameters, certain randomness, closer image effect to the real image, and acceptance as the defect image sample through the subjective judgment of human eyes of experts.
Description
Technical Field
The invention relates to the technical field of defect image generation, in particular to a method for generating a spongy defect image of a casting.
Background
In actual casting production, although the defective rate is greatly reduced by improving casting technology and materials, unqualified castings cannot be completely eliminated, and the internal defects of each cast product still need to be detected to ensure the quality of the delivered products.
At present, automatic defect detection gradually becomes a demand of the casting industry, a good detection algorithm usually needs a large number of defect samples for training and testing, a low defective rate can make some defect samples difficult to collect in a large number, and an algorithm capable of generating a large number of simulation images similar to real defects becomes an important solution for increasing the sample amount. Because the defects of the casting are various, such as shrinkage porosity, inclusion, bubbles, sponge shape and the like, the generation method of each defect is different. Among them, the spongy defect is one of the casting defect types defined in the international standard, and is a shrinkage porosity of a material which is not dense enough to form a sponge-like shape after casting, and the shape, the air holes and the cracks of the material are greatly different.
At present, two types of defect image generation methods are mainly used, one type is based on CAD software, a perspective depth image of a casting is calculated according to a ray attenuation coefficient, namely a projection image of a defect is calculated according to the ray absorption intensity. Because the defect shape has great randomness and randomness, the method needs to manually define the shape of the defect in advance and measure and calculate the absorption intensity of the ray according to the shape, so that the shape of each defect needs to be designed manually, and the application of the method in mass generation of the shape with random variation characteristics is greatly limited. The other method is that based on the characteristic analysis of the X-ray image of the defect, a plurality of typical characteristics of the defect are generated by a nonparametric method different from vector image calculation, and then a defect image is finally generated on the workpiece through a characteristic fusion and background fusion mode. However, the defect images obtained by the method generally have the problems of single form and large difference between the image effect and the real images, and cannot be regarded as samples for training and testing subsequent algorithms.
Therefore, the method for generating the spongy defect image quickly and enabling the generated defect to be more real has important research significance and practical value.
Disclosure of Invention
The invention aims to overcome the defects of the prior art and provide a method for generating a casting spongy defect image, the method has the advantages that the generated defects are diversified, the shape and the size of the defects can be controlled by parameters, certain randomness is realized, the image effect is closer to that of a real image, and the images can be accepted as defect image samples through the subjective judgment of human eyes of experts.
The purpose of the invention is realized by the following technical scheme: a method for generating an image of a spongy defect of a casting comprises the following steps:
(1) randomly generating a spongy defect skeleton image, wherein the steps of defining an initial skeleton, randomly generating branch skeletons according to a preset skeleton number, determining a reference curve of the skeleton, randomly generating an offset for each skeleton compared with the reference curve, and randomly setting initial gray levels for all the skeletons; the upper and lower lines of each framework are randomly offset for a certain distance, and the gray scale between the upper and lower lines is randomly adjusted by a difference value;
(2) filtering the skeleton image;
(3) superposing noise in the filtered image;
(4) and superposing the image added with the noise on the casting image to obtain a spongy defect image.
Preferably, in the step (1), an initial skeleton length, that is, the number of pixels in the longitudinal direction of the skeleton, is defined; the randomly generated branch skeleton length is less than or equal to one tenth of the initial skeleton length. Thereby enabling the branching effect to be built up even more.
Preferably, in the step (1), it is assumed that each skeleton randomly generates an offset b compared with the reference curvei(1) The offset is the difference between the initial position and the abscissa of the reference curve on the same row, and the value range is-L110 to L1Integer between/10, L1Denotes the initial skeleton length, i.e. the starting coordinate of the ith branch skeleton is (x)yi+bi(1),yi) Wherein x isyiAs a reference curve at the y-thiAbscissa of the row, yiThe starting ordinate of the ith branch skeleton is shown.
Preferably, in order to ensure the reality of the image, the next row offset in each skeleton is the offset of the previous row plus a random integer between-m 1 and m2, and the gray scale of the next row offset is the gray scale of the previous row plus a random integer between-n 1 and n 2. Here, m1, m2, n1 and n2 are all empirical values, and can be obtained by comprehensively considering the shape, size, gray scale and the like of the defect in the current captured image.
Preferably, in the step (2), the skeleton image is subjected to gaussian filtering according to the characteristics of the spongy defect image.
Preferably, in the step (3), a random berlin noise image is generated according to a non-zero pixel position of the filtered image, and then the noise image is superimposed on the filtered image to obtain the noise-added image.
Furthermore, after the skeleton image is subjected to gaussian filtering, in order to control the gray level of the image and enable the image superposition result to be more similar to the actual defect, the gray level of the filtered image is mapped between 0 and G, the random Berlin noise image is mapped between 0 and a, and then the two mapped images are superposed to obtain the image added with noise. G, a is an empirical value and can be set according to the characteristics of the current actual image.
Preferably, in the step (4), a superimposing position is selected on the casting image, and then the image with the noise added thereto is rotated by a certain angle and superimposed on the position.
Compared with the prior art, the invention has the following advantages and beneficial effects:
1. in the process of generating the spongy defect skeleton, the shape and the size of the spongy defect skeleton can be directly controlled by parameters, and the spongy defect skeleton has certain randomness, so that the generated defect has diversity and does not depend on an actual defect sample in the aspects of gray scale or other geometric shapes.
2. Aiming at the characteristics of the generated spongy defect skeleton and the actual casting spongy defect image, the invention selects a further processing mode combining Gaussian filtering and Berlin noise, the processed image is closer to the real image, and the processed image can be accepted as a defect image sample through subjective judgment of human eyes of experts.
3. The invention constructs the framework, and then carries out the processing modes of filtering and noise adding, so that the operation amount is small, and the speed of generating the sample is fast.
Drawings
FIG. 1 is a flow chart of the present example for generating an image of a casting spongy defect.
Fig. 2 is a reference graph generated in the present embodiment.
FIG. 3 is a skeleton diagram of a sponge defect randomly generated in this example.
Fig. 4 is a diagram of the skeleton after gaussian filtering in the present embodiment.
Fig. 5 is a berlin noise map generated randomly by the present embodiment.
Fig. 6 is a diagram of the spongy defect generated in the present example.
Fig. 7 is a comparison graph of the sponge-like defect map generated in the present example and the actual sponge-like defect map.
Detailed Description
The drawings are for illustrative purposes only and are not to be construed as limiting the patent; for the purpose of better illustrating the embodiments, certain features of the drawings may be omitted, enlarged or reduced, and do not represent the size of an actual product; it will be understood by those skilled in the art that certain well-known structures in the drawings and descriptions thereof may be omitted. The present invention will be described in further detail with reference to examples and drawings, but the present invention is not limited thereto.
Examples
As shown in fig. 1, the method for generating an image of a casting spongy defect of the embodiment includes the following steps:
firstly, generating a spongy defect skeleton image randomly.
In this embodiment, a spongy defect skeleton is constructed according to the characteristics of the actual casting spongy defect image, and then the defect image is generated on the basis of the skeleton. The framework is the greatest innovation point of the invention, and comprises the following specific steps:
(1) the proper number N of skeletons is selected, the first bar can be used as an initial skeleton, and the rest can be used as branch skeletons, wherein N is a random number between 40 and 80 in the embodiment.
(2) Determining an initial skeleton length L1I.e. the number of pixels in the longitudinal direction of the initial skeleton. This example L1=400。
(3) Randomly generating the starting ordinate y of all the branched skeletonsiAnd a length Li. In this embodiment, the length of the branched skeleton is less than or equal to one tenth of the length of the original skeleton.
(4) The reference curve for drawing the skeleton according to the practical situation of the application can be an arc line as shown in fig. 2, and can also be any curve segment or straight line segment.
(5) Randomly generating the initial offset b of all skeletonsi(1) The offset is the difference between the initial position and the abscissa of the reference curve on the same row, and the value range is-L110 to L1An integer between/10. I.e. the starting coordinate of the ith skeleton is (x)yi+bi(1),yi) Wherein is xyiReference curve at the y-thiThe abscissa of the row.
(6) Randomly setting initial gray a for all skeletonsi(1) I.e. in the image (x)yi+bi(1),yi) The grey scale of the pixel.
(7) All skeletons are drawn line by line from top to bottom, and the offset of the next line of the ith skeleton is the offset of the previous line plus a random integer between-2 and 2, and the gray scale of the next line of the ith skeleton is the gray scale of the previous line plus a random integer between-10 and 10. The final drawn sponge defect skeleton image results are shown in fig. 3.
And secondly, filtering the skeleton image.
In this embodiment, the sponge defect skeleton image is gaussian filtered, as shown in fig. 4, and its gray value is mapped between 0 and 20.
And thirdly, superposing noise in the filtered image.
From the non-zero pixel positions of the filtered image, a random berlin noise image is generated, as shown in fig. 5. The noise image is then mapped between 0 and 5 and superimposed on the filtered image, resulting in the noise-added image shown in fig. 6.
And fourthly, rotating the image added with the noise by a proper angle, and then adding and superposing the image to a proper position of the casting image to obtain the spongy defect image.
Fig. 7 includes the spongy defect map generated by the present embodiment and the actual spongy defect map, and a comparison between the two shows that the spongy defect map generated by the present embodiment is closer to the actual spongy defect, and can be considered as a sample for training and testing the subsequent algorithm.
The above embodiments are preferred embodiments of the present invention, but the present invention is not limited to the above embodiments, and any other changes, modifications, substitutions, combinations, and simplifications which do not depart from the spirit and principle of the present invention should be construed as equivalents thereof, and all such changes, modifications, substitutions, combinations, and simplifications are intended to be included in the scope of the present invention.
Claims (3)
1. A method for generating an image of a spongy defect of a casting is characterized by comprising the following steps:
(1) randomly generating a spongy defect skeleton image, wherein the steps of defining an initial skeleton, randomly generating branch skeletons according to a preset skeleton number, determining a reference curve of the skeleton, randomly generating an offset for each skeleton compared with the reference curve, and randomly setting initial gray levels for all the skeletons; the upper and lower lines of each framework are randomly offset for a certain distance, and the gray scale between the upper and lower lines is randomly adjusted by a difference value;
(2) performing Gaussian filtering on the skeleton image;
(3) generating a random Berlin noise image according to the non-zero pixel position of the filtered image, and then superposing the noise image on the filtered image to obtain an image added with noise; after the skeleton image is subjected to Gaussian filtering, mapping the gray value of the filtered image to be between 0 and G, mapping a random Berlin noise image to be between 0 and a, wherein G, a is an empirical value, and then overlapping the two mapped images to obtain an image added with noise;
(4) superposing the image added with the noise on the casting image to obtain a spongy defect image;
in the step (1), it is set that each skeleton randomly generates an offset b compared with a reference curvei(1) The offset is the difference between the initial position and the abscissa of the reference curve on the same row, and the value range is-L110 to L1Integer between/10, L1Denotes the initial skeleton length, i.e. the starting coordinate of the ith branch skeleton is (x)yi+bi(1),yi) Wherein x isyiAs a reference curve at the y-thiAbscissa of the row, yiRepresenting the initial ordinate of the ith branch skeleton; the offset of the next row in each skeleton is the offset of the previous row plus a random integer between-m 1 and m2, the gray scale of the next row is also the gray scale of the previous row plus a random integer between-n 1 and n2, and m1, m2, n1 and n2 are all empirical values.
2. The casting spongy defect image generation method according to claim 1, wherein in the step (1), an initial skeleton length, namely the number of pixels in the longitudinal direction of the skeleton, is defined; the randomly generated branch skeleton length is less than or equal to one tenth of the initial skeleton length.
3. The method for generating the image of the spongy defect of the casting as recited in claim 1, wherein in the step (4), a superposition position is selected on the image of the casting, and then the image with the noise is rotated by a certain angle and is superposed on the position.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810697178.4A CN109087370B (en) | 2018-06-29 | 2018-06-29 | Method for generating spongy defect image of casting |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810697178.4A CN109087370B (en) | 2018-06-29 | 2018-06-29 | Method for generating spongy defect image of casting |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109087370A CN109087370A (en) | 2018-12-25 |
CN109087370B true CN109087370B (en) | 2020-10-27 |
Family
ID=64834803
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810697178.4A Expired - Fee Related CN109087370B (en) | 2018-06-29 | 2018-06-29 | Method for generating spongy defect image of casting |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109087370B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110223277A (en) * | 2019-05-28 | 2019-09-10 | 深圳新视智科技术有限公司 | Method, apparatus, terminal device and the storage medium that image generates |
CN110689477B (en) * | 2019-09-07 | 2023-01-10 | 创新奇智(重庆)科技有限公司 | Universal flaw image simulation method |
CN111429411B (en) * | 2020-03-16 | 2023-04-25 | 东南大学 | X-ray defect image sample generation method for carbon fiber composite core wire |
CN113643406B (en) * | 2021-08-12 | 2022-03-25 | 北京的卢深视科技有限公司 | Image generation method, electronic device, and computer-readable storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070265091A1 (en) * | 2006-04-25 | 2007-11-15 | Aguilar Jr Maximino | Method to generate virtual world event notifications from within a persistent world game |
CN106530267A (en) * | 2016-11-30 | 2017-03-22 | 长沙全度影像科技有限公司 | Fusion method for avoiding panoramic picture misalignment |
-
2018
- 2018-06-29 CN CN201810697178.4A patent/CN109087370B/en not_active Expired - Fee Related
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070265091A1 (en) * | 2006-04-25 | 2007-11-15 | Aguilar Jr Maximino | Method to generate virtual world event notifications from within a persistent world game |
CN106530267A (en) * | 2016-11-30 | 2017-03-22 | 长沙全度影像科技有限公司 | Fusion method for avoiding panoramic picture misalignment |
Non-Patent Citations (2)
Title |
---|
基于定性视觉特征语义描述的裂纹缺陷仿真;詹银燕;《中国优秀硕士学位论文全文数据库 信息科技辑》;20110315;第45-51页 * |
基于语义描述的铸造缺陷图像生成研究;汪玉琳;《中国优秀硕士学位论文全文数据库 信息科技辑》;20150115;第21-24页 * |
Also Published As
Publication number | Publication date |
---|---|
CN109087370A (en) | 2018-12-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109087370B (en) | Method for generating spongy defect image of casting | |
CN111814867B (en) | Training method of defect detection model, defect detection method and related device | |
JP7254324B2 (en) | IMAGE GENERATING APPARATUS AND IMAGE GENERATING METHOD FOR GENERATING INSPECTION IMAGE FOR PERFORMANCE ADJUSTMENT OF IMAGE INSPECTION SYSTEM | |
WO2020031984A1 (en) | Component inspection method and inspection system | |
CN107358636B (en) | Loose defect image generation method based on texture synthesis | |
CN108827181B (en) | Vision-based plate surface detection method | |
CN105095581B (en) | A kind of casting shrinking hole defect image generation method | |
KR102650215B1 (en) | Method and apparatus for processing image | |
CN106791773B (en) | A kind of novel view synthesis method based on depth image | |
CN110660040A (en) | Industrial product irregular defect detection method based on deep learning | |
JP2004012422A (en) | Pattern inspection device, pattern inspection method, and program | |
CN111476758B (en) | Defect detection method and device for AMOLED display screen, computer equipment and storage medium | |
CN107423709A (en) | A kind of object detection method for merging visible ray and far infrared | |
CN110246138A (en) | A kind of method of digital cores image pore throat segmentation | |
CN105976336A (en) | Fuzzy repair method of video image | |
CN106770318A (en) | Weld defect real-time detection method based on improved background subtraction | |
CN113240790B (en) | Rail defect image generation method based on 3D model and point cloud processing | |
JP5557271B2 (en) | Radiation inspection apparatus, radiation inspection method, and radiation inspection program | |
Ziabari et al. | Simurgh: A Framework for CAD-Driven Deep Learning Based X-Ray CT Reconstruction | |
JP2008051558A (en) | Visual inspection method and device | |
WO2023119922A1 (en) | Image generating device, method, and program, training device, and training data | |
Qi et al. | Quantitative detection of minor defects in metal materials based on variation coefficient of CT image | |
JP2012048579A (en) | Image processing apparatus and method of the same | |
JP7518784B2 (en) | Visual inspection apparatus, visual inspection method, image generating apparatus, and image generating method | |
CN108615041A (en) | A kind of angular-point detection method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20201027 |
|
CF01 | Termination of patent right due to non-payment of annual fee |