Detection method, system and medium
By using a single-chip TDI true color line scan camera to perform dispersion correction and grayscale image conversion on color samples, the dispersion problem of line scan color cameras is solved, enabling high-precision defect detection of color samples and improving the detection capability of phase deflection technology.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HEFEI I TEK OPTOELECTRONICS CO LTD
- Filing Date
- 2025-12-30
- Publication Date
- 2026-04-21
AI Technical Summary
In existing technologies, line scan color cameras suffer from chromatic dispersion, which affects the accuracy of phase extraction and makes it impossible to effectively detect discoloration and dirt defects on color samples. Furthermore, existing color phase deflection techniques require the projection of multiple additional frames of patterns, which increases the camera's line frequency requirements and the light source's flicker time, thus affecting image quality.
A single-chip TDI true color line scan camera is used to reconstruct the color component data of the color sample image through interpolation, calculate the color difference and color ratio for dispersion correction, convert it into a grayscale image for phase deflection defect detection, and reconstruct the three-dimensional morphology through phase shift calculation. The optimal morphology is obtained by iterative optimization algorithm.
It enables the detection of defects with significant color differences on the surface of colored samples, improves detection accuracy and image quality, expands the application scenarios of phase deflection technology, reduces the error caused by color differences in detection, and maintains the camera line frequency and light source period.
Smart Images

Figure CN121903984A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing, and particularly relates to a detection method, system and medium. Background Technology
[0002] Phase deflection is a precise optical measurement technique. Its principle is as follows: when a known, regular beam of light (such as parallel light or sinusoidal fringes) is projected onto the surface of an object, the phase of the reflected or transmitted light wave changes due to variations in the object's microstructure or refractive index. By detecting this change in phase distribution, the three-dimensional morphology or internal optical properties of the object can be reconstructed with high precision, making it widely used in industrial inspection, biomedicine, and other fields.
[0003] Traditional phase deflection technology uses a black and white light source and camera to detect defects such as scratches and bumps on the surface of mirror-like objects. If there is a large color difference on the surface being measured, the detection effect of the above defects will decrease, and it cannot detect color-related defects, such as discoloration or dirt. Therefore, color phase deflection technology is needed.
[0004] Currently, color phase deflection technology is mainly based on area array imaging systems. Typical solutions include using a monochrome area array camera with color filters to acquire color information, or directly using a color area array camera combined with color structured light projection. However, there is currently no color phase deflection technology solution based on line scan cameras. The core challenge lies in the significant chromatic aberration phenomenon in line scan color cameras, which affects the accuracy of phase extraction. Therefore, it is necessary to effectively suppress chromatic aberration while maintaining color imaging capabilities to obtain high-quality images suitable for phase calculation. Patent CN119012021A proposes a chromatic aberration correction method suitable for single-chip multi-line true color cameras, which can achieve chromatic aberration correction in free acquisition scenarios with a fixed image compression ratio. However, when directly applying this method to color phase deflection technology, targeted optimization at the algorithm level is still required to adapt to the needs of phase measurement.
[0005] Traditional line-scan phase deflection uses a monochrome camera with a monochrome light source, which cannot detect defects such as discoloration or dirt on colored samples. Therefore, color line-scan phase deflection is needed to detect these color-related defects. In the scheme using a color structured light source, three additional frames of pure color patterns (red, green, and blue) need to be projected to achieve color imaging. This increases the total number of projected patterns, which not only increases the requirements for the camera's line frequency but may also affect image quality due to the shortened flicker time of the light source.
[0006] Therefore, in order to detect defects with large color differences on the surface of colored samples, maintain the camera line frequency and light source period, solve the dispersion problem, improve image acquisition quality, and improve the accuracy of phase deflection defect detection, this invention provides a detection method, system, and medium. Summary of the Invention
[0007] The purpose of this invention is to overcome the above-mentioned problems in the prior art and to provide a detection method, system and medium.
[0008] To achieve the above-mentioned technical objectives and effects, the present invention is implemented through the following technical solution:
[0009] A detection method for acquiring color sample images using a color camera to perform defect detection based on phase deflection, the detection method comprising:
[0010] Image data of black and white stripes shifted according to a preset phase illuminating the surface of the colored sample is acquired, and the image data is interpolated to reconstruct the color component data missing for the corresponding pixels;
[0011] Calculate the color difference and color ratio of the corresponding color component data in adjacent rows to guide the color component correction of the reference row to obtain a dispersion-corrected color image;
[0012] The color image data of each color component is weighted and transformed to form a grayscale image, so as to map the color information of the color sample surface;
[0013] Phase shift calculation is used to calculate the phase value corresponding to each pixel in the grayscale image in order to reconstruct the three-dimensional morphology of the colored sample surface for defect detection;
[0014] The image data is RGB data captured by a color camera;
[0015] The color camera is a single-chip TDI true color line scan camera;
[0016] The reference line is the row of color pixels to be corrected.
[0017] Furthermore, the detection method further includes:
[0018] Based on the three-dimensional morphology, a simulated stripe image of the ideal sample is rendered in reverse. An optimization algorithm is then used to iteratively obtain the optimal three-dimensional morphology with the goal of minimizing the difference between the simulated stripe image and the real stripe image.
[0019] Furthermore, the optimal three-dimensional morphology is the three-dimensional morphology of the colored sample that reaches a preset number of iterations or has a difference less than a preset difference.
[0020] Furthermore, the optimization algorithm is a gradient descent algorithm, a Gauss-Newton method, or a Levenberg-Marquardt algorithm.
[0021] Further, the interpolation of the image data to reconstruct the color component data corresponding to the missing pixels includes:
[0022] The missing color component data of the pixel is calculated by weighted interpolation using the color component data of the corresponding pixel's neighborhood, and the interpolation weight is set by the distance between the neighboring pixels and the pixel.
[0023] Furthermore, the neighborhood refers to other pixels within a preset window centered on the corresponding pixel.
[0024] Further, the weighted transformation of the color image's color component data to form a grayscale image includes:
[0025] The grayscale values of the corresponding pixels are converted according to the preset RGB component ratio to obtain a grayscale image with color information guidance.
[0026] Furthermore, the calculation formula for converting the corresponding pixel's grayscale value according to the preset RGB component ratio is as follows:
[0027] Y = 0.299R + 0.587G + 0.114B;
[0028] Where Y is the grayscale value of the pixel to be converted, and R, G, and B are the color component data of the pixel to be converted, respectively.
[0029] A detection system for acquiring color sample images using a color camera to perform defect detection based on phase deflection, the detection system comprising:
[0030] The acquisition module acquires image data of black and white stripes that are shifted according to a preset phase and illuminates the surface of the colored sample, and reconstructs the color component data missing from the corresponding pixels by interpolating the image data.
[0031] The calculation module calculates the color difference and color ratio of the corresponding color component data in adjacent rows to guide the color component correction of the reference row to obtain a color image after dispersion correction.
[0032] The analysis module performs weighted transformation of the color component data of the color image to form a grayscale image, so as to map the color information of the color sample surface;
[0033] The detection module performs phase shift calculations on the phase values corresponding to each pixel in the grayscale image to reconstruct the three-dimensional morphology of the colored sample surface for defect detection.
[0034] The image data is RGB data captured by a color camera;
[0035] The color camera is a single-chip TDI true color line scan camera;
[0036] The reference line is the row of color pixels to be corrected.
[0037] A computer-readable storage medium includes a computer program that, when executed by a processor, implements the above-described detection method.
[0038] The beneficial effects of this invention are:
[0039] (1) In this invention, a phase deflection system is built by using a color camera in conjunction with black and white stripes to achieve defect detection of colored samples with large surface color differences. This system is used to capture the color information of the sample and couple it to form a grayscale image that can be used for phase deflection. This allows products with different colors to be defect detected by phase deflection, reducing the detection error of subtle defects due to color differences and improving the product defect detection accuracy. At the same time, the quality of the color image before acquiring the grayscale image is improved by introducing dispersion correction. Furthermore, this invention overcomes the changes in camera line frequency and black and white stripe periodicity caused by using a colored light source to illuminate the sample to acquire an additional color image in the prior art, thereby improving the overall brightness and imaging quality of the image acquisition and further improving the defect detection accuracy based on phase deflection.
[0040] (2) In this invention, by acquiring image data of black and white stripes that are shifted according to a preset phase and illuminating the surface of the colored sample, the image data is interpolated to reconstruct the color component data of the corresponding missing pixels, so that the complete color information of all pixels of the colored sample image can be collected, the color difference of the colored sample surface is depicted, and the application scenario of phase deflection can be expanded to defect types with large color differences.
[0041] By calculating the color difference and color ratio of the corresponding color component data in adjacent rows, the color component correction of the reference row is used to obtain a color image after dispersion correction. In this way, the spatial correlation and stability of the ratio / difference relationship of the color components in the local area are used to correct pixel dispersion defects and obtain a more accurate color image to characterize the color difference of the surface of the color sample more precisely.
[0042] By weighted transformation of the color image data of each color component to form a grayscale image, the color information of the color sample surface is mapped, so that the grayscale image used for phase deflection defect detection is endowed with the color information of the sample surface, so that the color difference of the sample surface participates in defect detection, and the error of different colored samples in defect detection is reduced.
[0043] Phase shifting is used to calculate the phase value corresponding to each pixel in the grayscale image to reconstruct the three-dimensional morphology of the colored sample surface for defect detection. This eliminates the need for a black-and-white camera to acquire color information by illuminating the sample surface with a colored light source. Defect detection is performed directly through the stripe image acquired in phase deflection, maintaining the camera's line frequency and the black-and-white stripe flicker period, thereby improving the overall brightness and imaging quality of the image acquisition.
[0044] (3) In this invention, the simulated stripe image under ideal conditions is obtained by reverse simulation of the three-dimensional morphology obtained by phase deflection phase shift calculation, and the difference is compared with the actual stripe image. The optimization goal is to minimize the difference between the simulated stripe image and the actual stripe image. The dispersion correction parameter that meets the iteration condition is obtained by the optimization algorithm. The corresponding grayscale image is obtained based on the dispersion correction parameter and the optimal three-dimensional morphology is finally obtained. The defect detection result obtained by phase deflection is iteratively optimized to improve the defect detection accuracy. Attached Figure Description
[0045] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0046] Figure 1 This is a flowchart of the detection method in this invention;
[0047] Figure 2 This is a block diagram of the output system structure in this invention;
[0048] Figure 3 This is a schematic diagram of the linear scanning phase deflection system in this invention;
[0049] Figure 4 This is a schematic diagram of the stripes displayed by the line scan stripe light source in this invention;
[0050] Figure 5 This is a schematic diagram of the image captured by the camera and the stripe number in this invention;
[0051] Figure 6 This is a schematic diagram of the spatial position of the camera's RGB three-pixel row directly acquired in Embodiment 1 of the present invention;
[0052] Figure 7 This is a schematic diagram of the camera with an installation tilt angle in Embodiment 1 of the present invention;
[0053] Figure 8 This is a schematic diagram of the spatial position and stripe numbering of the RGB three-line scan at different times in Embodiment 1 of the present invention;
[0054] Figure 9 This is a schematic diagram of the RGB three-line scan spatial position corresponding to the first black and white stripe image at different times in Embodiment 1 of the present invention;
[0055] Figure 10 This is a schematic diagram of the RGB three-line scanning spatial position corresponding to the first black and white stripe image when the camera is installed at a tilt angle of 45° in Embodiment 1 of the present invention;
[0056] Figure 11This is a schematic diagram of the spatial position distribution after delay based on line R in Embodiment 1 of the present invention. Detailed Implementation
[0057] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0058] To address the alignment issue of depth and brightness data acquired from different cameras, a color image is fused together to visualize the depth and brightness information of the object under test.
[0059] like Figure 1 As shown, this embodiment first provides a detection method for acquiring color sample images using a color camera to perform defect detection based on phase refraction. The detection method includes:
[0060] Image data of black and white stripes shifted according to a preset phase illuminating the surface of the colored sample is acquired, and the image data is interpolated to reconstruct the color component data missing for the corresponding pixels;
[0061] Calculate the color difference and color ratio of the corresponding color component data in adjacent rows to guide the color component correction of the reference row to obtain a dispersion-corrected color image;
[0062] The color image data of each color component is weighted and transformed to form a grayscale image, so as to map the color information of the color sample surface;
[0063] Phase shift calculation is used to calculate the phase value corresponding to each pixel in the grayscale image in order to reconstruct the three-dimensional morphology of the colored sample surface for defect detection;
[0064] The image data is RGB data captured by a color camera;
[0065] The color camera is a single-chip TDI true color line scan camera;
[0066] The reference line is the row of color pixels to be corrected.
[0067] In this embodiment, the specific process for detecting phase deflection defects includes:
[0068] Phase deflection is a technique that uses a light source to display stripes, and a camera captures an image to detect defects by assessing the degree of deformation of these stripes. For example... Figure 3The diagram shows a schematic of a line-scan phase deflection detection system. Light emitted from the light source is transmitted to the surface being measured and reflected by the specular reflection law into the camera. Assuming the light ray emitted from point E on the light source is reflected by line A on the surface being measured and enters the camera, according to the principle of optical reversibility, the light can be considered to have exited the camera, been reflected by line A on the surface being measured, and returned to point E on the surface of the light source. If line A on the surface being measured is not an ideal mirror and has a defect, then the light ray emitted from the camera will be reflected to point Q on the surface of the light source, which is different from point E. The distance between point Q and point E reflects the degree of tilt of line A on the surface being measured relative to an ideal mirror. The greater the distance between point Q and point E, the greater the tilt, and the deeper the defect at point A on the surface being measured.
[0069] To identify changes in the light path caused by defects, the light source needs to sequentially display multiple sinusoidal fringe patterns with a defined phase difference between them, specifically including, for example... Figure 4 The four vertical stripe patterns and four horizontal stripe patterns shown are used to detect defects in the horizontal and vertical directions, respectively.
[0070] Because the light source displays eight stripe patterns in a strobe cycle, the image directly captured by the line scan camera is composed of eight stripe patterns interlaced and superimposed. Figure 5 The image shown represents the stripe numbers corresponding to each row of the image directly acquired by the line scan camera. In the image, "line" represents the image acquisition time series, and "fringe" represents the stripe number corresponding to that series. It can be seen that rows 1-8 correspond to stripe pattern 1-8, rows 9-16 again correspond to stripe pattern 1-8, and so on.
[0071] Let the original line scan image be I. line The 8 stripe patterns are respectively I i If i = 1, 2, ..., 8, then the pixel I in the r-th row of each stripe pattern... i (r) can be represented as:
[0072] I i (r)=I line (8r+i) (1)
[0073] Taking the vertical stripe pattern as an example, under ideal conditions, the four images captured by the camera can be represented by the following formula (2):
[0074]
[0075] From the camera image acquisition equation in equation (2) above, various algorithm result images can be calculated to represent different information of the side:
[0076] 1) Average pattern: By averaging the stripe pattern, we can get a general idea of the condition of the surface being measured and the diffuse reflection component, which can be used to detect dirt and dullness.
[0077]
[0078] 2) Specular reflection diagram: This diagram shows the distribution of specular reflection components on the side surface and is used to detect scratches.
[0079]
[0080] 3) Phase diagram: Represents the phase distribution of sinusoidal fringes, used to detect bumps and depressions.
[0081]
[0082] Example 1
[0083] In this embodiment, an example is given to illustrate the difference between the dispersion correction in this invention and the prior art. A TDI true color line scan camera has pixel rows of RGB colors. Taking a single-line true color camera as an example, that is, one row for each of the three RGB colors. The number of pixels between the pixels in the three RGB rows is denoted as 'a'; for example, a = 1, meaning there is a 1-pixel interval between the pixels in the three RGB rows. When the camera line frequency and the object's motion speed have a 1:1 relationship, the spatial positions of the RGB (red, green, blue) three rows without time delay are as follows: Figure 6 As shown in the table, t represents the line period. Here, the ratio of the camera's line frequency to the object's speed is denoted as 1:N.
[0084] In an online scanning phase deflection system, since the light source needs to display 8 stripe patterns in a loop before the algorithm calculates the result image, when the algorithm result image does not have any stretching or compression deformation, that is, when the ratio of the equivalent line frequency of the result image to the object's speed is 1:1, the theoretical line frequency of the line scanning camera to the object's speed should be 8:1, i.e., N = 0.125.
[0085] Depend on Figure 3 As can be seen, in a line-scan phase-deflection system, in order for the camera to receive the fringes reflected from the side, the camera is usually tilted at a certain angle to capture the image from the side. For example... Figure 7 As shown, when the camera is mounted at an angle α, the object size corresponding to the pixel imaging is l1. When mounted vertically, the object size of the pixel imaging is l0. That is, the area of size l0 on the image corresponds to the area of size l1 on the measured surface. According to the geometric relationship, l1 = l0 / cosα. Therefore, the true value of the ratio of the camera scanning line frequency to the object's motion speed is 1:N / cos(α). In the online scanning phase deflection system, N = 0.125 / cos(α).
[0086] When the number of pixels between RGB pixel rows is *a*, and the true ratio of the camera's scanning line frequency to the object's motion speed is 1:N, the spatial positions and stripe numbers of the RGB three rows of pixels scanned in an equally spaced time sequence are as follows: Figure 8 As shown.
[0087] When performing dispersion correction, the pixel rows used for interpolation should come from the same fringe pattern. Taking fringe pattern I1 as an example, remove... Figure 8 Data from other stripe patterns were obtained Figure 9 ;
[0088] The difference from existing dispersion correction methods is that:
[0089] ① The calculation method for integer-level delay is as follows Indicates rounding down
[0090] ②The front of the image 2 *delay+ 1 The row data cannot be interpolated, so no dispersion correction is performed.
[0091] ③ The equivalent value of N is 8cosα, which means that the ratio of the camera line frequency to the physical distance between two adjacent pixel lines in the same stripe pattern is 1:8cosα.
[0092] Subsequently, with a = 1 and α = 45°, the stripes... Figure 1 Taking the correction as an example, at this time... Figure 9 Spatial location distribution such as Figure 10 As shown.
[0093] At this point, the delay is in the integer order. Spatial location distribution after delay based on line R is as follows Figure 11 As shown.
[0094] The first three lines are left uncorrected, except for the stripes. Figure 1 The correction begins on the fourth line. The correction steps are as follows:
[0095] 1) Interpolation yields the G and B components at position 4.50:
[0096]
[0097] 2) Interpolation yields the G and R components at position 5.62.
[0098]
[0099] 3) Calculate the GR and GB color differences at positions 4.50 and 5.62, and interpolate to obtain the GR and GB color difference at position 5.06.
[0100] GR(5.06)=(G(4.50)-R(4.50)+G(5.62)-R(5.62)) / 2
[0101] GB(5.06)=(G(4.50)-B(4.50)+G(5.62)-B(5.62)) / 2
[0102] 4) Calculate the R and B components at position 5.06 using reverse color difference calculation, and complete the color difference correction at position 5.06:
[0103] R(5.06)=G(5.06)-GR(5.06)
[0104] B(5.06) = G(5.06) - GB(5.06)
[0105] For all eight fringe patterns, dispersion correction needs to be performed using the method described above. Let the corrected color fringe pattern be I′. i For i = 1, 2, ..., 8, an average color image can be obtained by averaging to detect color-related defects such as discoloration. This average color image is the same size as the average image, specular reflection image and phase image calculated by equations (3, 4, 5), and there is no stretching or compression.
[0106]
[0107] After calculating the average color image using equation (6), the RGB channels of the color stripe image need to be converted to grayscale images at an appropriate ratio according to the surface color of the object being measured, and then the phase deflection calculation in equations (3, 4, 5) is performed.
[0108] In this invention, a phase deflection system is constructed using a color camera and black and white stripes to achieve defect detection on colored samples with significant surface color differences. This system captures the sample's color information and couples it to form a grayscale image that can be used for phase deflection. This allows products with different colors to be detected through phase deflection, reducing the detection error of subtle defects due to color differences and improving the accuracy of product defect detection. At the same time, the quality of the color image before acquiring the grayscale image is improved by introducing dispersion correction. Furthermore, this invention overcomes the changes in camera line frequency and black and white stripe periodicity caused by using a colored light source to illuminate the sample to acquire an additional color image in existing technologies, thereby improving the overall brightness and imaging quality of the image acquisition and further enhancing the accuracy of defect detection based on phase deflection.
[0109] In this invention, by acquiring image data of black and white stripes illuminating the surface of the colored sample according to a preset phase, and reconstructing the color component data of the corresponding missing pixels by interpolating the image data, the complete color information of all pixels of the colored sample image can be collected, thus characterizing the color difference of the colored sample surface and expanding the application scenarios of phase deflection to defect types with large color differences.
[0110] By calculating the color difference and color ratio of the corresponding color component data in adjacent rows, the color component correction of the reference row is used to obtain a color image after dispersion correction. In this way, the spatial correlation and stability of the ratio / difference relationship of the color components in the local area are used to correct pixel dispersion defects and obtain a more accurate color image to characterize the color difference of the surface of the color sample more precisely.
[0111] By weighted transformation of the color image data of each color component to form a grayscale image, the color information of the color sample surface is mapped, so that the grayscale image used for phase deflection defect detection is endowed with the color information of the sample surface, so that the color difference of the sample surface participates in defect detection, and the error of different colored samples in defect detection is reduced.
[0112] Phase shifting is used to calculate the phase value corresponding to each pixel in the grayscale image to reconstruct the three-dimensional morphology of the colored sample surface for defect detection. This eliminates the need for a black-and-white camera to acquire color information by illuminating the sample surface with a colored light source. Defect detection is performed directly through the stripe image acquired in phase deflection, maintaining the camera's line frequency and the black-and-white stripe flicker period, thereby improving the overall brightness and imaging quality of the image acquisition.
[0113] In some embodiments, to improve the accuracy of three-dimensional topography acquisition, the detection method further includes:
[0114] Based on the three-dimensional morphology, a simulated stripe image of the ideal sample is rendered in reverse. An optimization algorithm is then used to iteratively obtain the optimal three-dimensional morphology with the goal of minimizing the difference between the simulated stripe image and the real stripe image.
[0115] In this embodiment, the specific iterative process includes:
[0116] Step 1: Using the calculated 3D topography and combined with the known system geometry (camera and light source positions), reverse simulate the ideal, non-aliased stripe image sequence that the object's surface should reflect.
[0117] Step 2: Compare the simulated ideal image with the actual acquired original image, and adjust the dispersion correction parameters through an optimization algorithm to minimize the difference between the original image after these parameter corrections and the stripe image sequence;
[0118] Step 3: Repeat Step 1 with the optimized new parameters to perform a new round of phase calculations, obtain a more accurate 3D topography, substitute it into Step 1 and repeat the above steps until the 3D topography and correction parameters converge.
[0119] In this embodiment, a simulated stripe image under ideal conditions is obtained by reverse simulation of the three-dimensional morphology obtained based on phase deflection phase shift calculation. The simulated stripe image is then compared with the actual stripe image to minimize the difference between the simulated and actual stripe images as the optimization objective. The dispersion correction parameters that meet the iteration conditions are obtained through the optimization algorithm. Based on the dispersion correction parameters, the corresponding grayscale image is obtained and the optimal three-dimensional morphology is finally obtained. This iterative optimization of the defect detection results obtained by phase deflection improves the defect detection accuracy.
[0120] In this embodiment, specific difference types can be evaluated using evaluation functions such as stripe spacing and size.
[0121] In some implementations, in order to determine the number of iterations to obtain a three-dimensional morphology that meets the usage requirements, the optimal three-dimensional morphology is the three-dimensional morphology of the colored sample that reaches a preset number of iterations or has a difference less than a preset difference.
[0122] In this embodiment, the final mapping combination of the optimal dispersion correction parameters and the optimal three-dimensional shape is achieved by setting an iteration termination condition.
[0123] In some implementations, in order to quickly reduce the difference between the simulated stripe image and the real stripe image to approximate the optimal three-dimensional morphology, the optimization algorithm is a gradient descent algorithm, a Gauss-Newton method, or a Levenberg-Marquardt algorithm.
[0124] In this embodiment, the optimization algorithm includes, but is not limited to, the algorithm types mentioned above. Other optimization algorithms that can reduce the difference between simulated stripe images and real stripe images can also be applied, with only differences in optimization efficiency and accuracy.
[0125] In some implementations, to obtain the missing color component data for all pixels, the interpolation of the image data to reconstruct the missing color component data for the corresponding pixels includes:
[0126] The missing color component data of the pixel is calculated by weighted interpolation using the color component data of the corresponding pixel's neighborhood, and the interpolation weight is set by the distance between the neighboring pixels and the pixel.
[0127] In this embodiment, the method of obtaining missing color component data by weighted interpolation of neighboring pixels can be achieved using a conventional demosaic algorithm, which will not be elaborated on here.
[0128] In some implementations, in order to determine the target neighboring pixels that need to be interpolated to obtain the missing color component data of the corresponding pixel, the neighboring pixels are other pixels within a preset window centered on the corresponding pixel.
[0129] In this embodiment, the size and shape of the preset window are set and adjusted accordingly to adjust the number of pixels participating in the calculation of the missing color component data of the corresponding pixel, thereby controlling the accuracy of the color component data obtained by weighted interpolation.
[0130] In some implementations, in order to convert the acquired color image of the sample into a grayscale image with color enhancement suitable for phase deflection defect detection, the weighted transformation of the color component data of the color image to form a grayscale image includes:
[0131] The grayscale values of the corresponding pixels are converted according to the preset RGB component ratio to obtain a grayscale image with color information guidance.
[0132] In this embodiment, each RGB color component contained in each pixel is mapped according to a preset ratio to form a corresponding grayscale value. This is used to guide the reconstruction of the grayscale image through the color information in the color image, so that the grayscale image is coupled with the color information of the color difference on the surface of the color sample and participates in the phase deflection system for phase defect detection, thereby overcoming the defect detection error caused by the color difference on the surface of the color sample.
[0133] In some implementations, to ensure that the grayscale image obtained from the color image conversion meets the visual characteristics of the human eye, the calculation formula for converting the corresponding pixel grayscale value according to the preset RGB component ratio is as follows:
[0134] Y = 0.299R + 0.587G + 0.114B;
[0135] Where Y is the grayscale value of the pixel to be converted, and R, G, and B are the color component data of the pixel to be converted, respectively.
[0136] In this embodiment, the corresponding grayscale image is obtained by using an RGB component conversion ratio that conforms to the visual characteristics of the human eye, making the obtained grayscale image more intuitive and meeting specific usage requirements.
[0137] like Figure 2 As shown, the present invention also provides a detection system for acquiring color sample images using a color camera to perform defect detection based on phase deflection, the detection system comprising:
[0138] The acquisition module acquires image data of black and white stripes that are shifted according to a preset phase and illuminates the surface of the colored sample, and reconstructs the color component data missing from the corresponding pixels by interpolating the image data.
[0139] The calculation module calculates the color difference and color ratio of the corresponding color component data in adjacent rows to guide the color component correction of the reference row to obtain a color image after dispersion correction.
[0140] The analysis module performs weighted transformation of the color component data of the color image to form a grayscale image, so as to map the color information of the color sample surface;
[0141] The detection module performs phase shift calculations on the phase values corresponding to each pixel in the grayscale image to reconstruct the three-dimensional morphology of the colored sample surface for defect detection.
[0142] The image data is RGB data captured by a color camera;
[0143] The color camera is a single-chip TDI true color line scan camera;
[0144] The reference line is the row of color pixels to be corrected.
[0145] For detailed operating methods and principles of each module in the detection system, please refer to the detection method described above, and they will not be repeated here.
[0146] The present invention also provides a computer-readable storage medium including a computer program that, when executed by a processor, implements the above-described detection method.
[0147] In practical applications, a computer-readable storage medium can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this embodiment, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0148] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0149] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0150] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0151] In the description of this specification, references to terms such as "an embodiment," "example," and "specific example" indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0152] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention.
Claims
1. A detection method for acquiring color sample images using a color camera to perform defect detection based on phase deflection, characterized in that, The detection method includes: Image data of black and white stripes shifted according to a preset phase illuminating the surface of the colored sample is acquired, and the image data is interpolated to reconstruct the color component data missing for the corresponding pixels; Calculate the color difference and color ratio of the corresponding color component data in adjacent rows to guide the color component correction of the reference row to obtain a dispersion-corrected color image; The color image data of each color component is weighted and transformed to form a grayscale image, so as to map the color information of the color sample surface; Phase shift calculation is used to calculate the phase value corresponding to each pixel in the grayscale image in order to reconstruct the three-dimensional morphology of the colored sample surface for defect detection; The image data is RGB data captured by a color camera; The color camera is a single-chip TDI true color line scan camera; The reference line is the row of color pixels to be corrected.
2. The detection method according to claim 1, characterized in that, The detection method further includes: Based on the three-dimensional morphology, a simulated stripe image of the ideal sample is rendered in reverse. An optimization algorithm is then used to iteratively obtain the optimal three-dimensional morphology with the goal of minimizing the difference between the simulated stripe image and the real stripe image.
3. A detection method according to any one of claims 1-2, characterized in that, The optimal three-dimensional morphology is the three-dimensional morphology of the colored sample that reaches a preset number of iterations or has a difference less than a preset difference.
4. The detection method according to claim 2, characterized in that, The optimization algorithm is gradient descent, Gauss-Newton method, or Levenberg-Marquardt algorithm.
5. The detection method according to claim 1, characterized in that, The interpolation of the image data to reconstruct the color component data corresponding to the missing pixels includes: The missing color component data of the pixel is calculated by weighted interpolation using the color component data of the corresponding pixel's neighborhood, and the interpolation weight is set by the distance between the neighboring pixels and the pixel.
6. The detection method according to claim 5, characterized in that, The neighborhood is the other pixels within the preset window center pixel with the corresponding pixel as the center pixel.
7. The detection method according to claim 1, characterized in that, The weighted transformation of the color image's color component data to form a grayscale image includes: The grayscale values of the corresponding pixels are converted according to the preset RGB component ratio to obtain a grayscale image with color information guidance.
8. The detection method according to claim 7, characterized in that, The formula for calculating the grayscale value of the corresponding pixel by converting it according to the preset RGB component ratio is as follows: Y = 0.299R + 0.587G + 0.114B; Where Y is the grayscale value of the pixel to be converted, and R, G, and B are the color component data of the pixel to be converted, respectively.
9. A detection system for acquiring color sample images using a color camera to perform defect detection based on phase deflection, characterized in that, The detection system includes: The acquisition module acquires image data of black and white stripes that are shifted according to a preset phase and illuminates the surface of the colored sample, and reconstructs the color component data missing from the corresponding pixels by interpolating the image data. The calculation module calculates the color difference and color ratio of the corresponding color component data in adjacent rows to guide the color component correction of the reference row to obtain a color image after dispersion correction. The analysis module performs weighted transformation of the color component data of the color image to form a grayscale image, so as to map the color information of the color sample surface; The detection module performs phase shift calculations on the phase values corresponding to each pixel in the grayscale image to reconstruct the three-dimensional morphology of the colored sample surface for defect detection. The image data is RGB data captured by a color camera; The color camera is a single-chip TDI true color line scan camera; The reference line is the row of color pixels to be corrected.
10. A computer-readable storage medium comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the detection method as described in any one of claims 1-8.
Citation Information
Patent Citations
Dispersion correction method and system and multi-line true color camera
CN119012021A