Glass surface implicit defect detection method
By employing tensor decomposition and spectral residual optimization techniques, combined with adaptive segmentation and dynamic thresholding, the problems of insufficient signal-to-noise ratio and real-time performance in the detection of implicit defects on glass surfaces are solved, achieving efficient defect detection and automatic sorting.
Patent Information
- Application Number
- CN202610028970.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-09
- Publication Date
- 2026-04-21
AI Technical Summary
Existing methods for detecting latent defects on glass surfaces suffer from the shortcomings of traditional edge detection, such as insufficient signal-to-noise ratio for low-contrast latent defects, high false negative rate, morphological processing being easily affected by glass surface texture, and fixed-parameter detection algorithms being unable to adapt to changes in glass batches on the production line. Linear scans also have poor real-time performance and cannot meet the requirements for online inspection.
Tensor decomposition technology is used to focus implicit defect information through high-order tensor components. Combined with spectral residual optimization and Gaussian filtering to separate the background and residuals, a residual map with significantly enhanced defects is generated. Through adaptive segmentation and dynamic thresholding, automatic defect identification and sorting are achieved.
It effectively suppressed background texture interference, improved the signal-to-noise ratio of defect detection, reduced the false negative rate, and achieved real-time online detection and production efficiency.
Smart Images

Figure CN121904008A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of data processing technology, specifically a method for detecting latent defects on glass surfaces. Background Technology
[0002] Latent defect detection methods on glass surfaces are techniques for detecting minute imperfections that are difficult to observe directly with the naked eye under normal lighting conditions and exist within the glass. The core principle is to create a significant contrast difference between the originally invisible or difficult-to-see defects and the normal glass background, allowing industrial cameras to capture them and image processing algorithms to identify and classify them. However, existing methods for detecting latent defects on glass surfaces suffer from several technical problems: limitations of traditional edge detection methods, insufficient signal-to-noise ratio for low-contrast latent defects, high false negative rates, and susceptibility to interference from glass surface textures during morphological processing. Furthermore, fixed-parameter detection algorithms cannot adapt to changes in glass batches on the production line, and linear scans have poor real-time performance, failing to meet the needs of online inspection. Summary of the Invention
[0003] To address the aforementioned issues and overcome the shortcomings of existing technologies, this invention provides a method for detecting implicit defects on glass surfaces. It addresses the problems of traditional edge detection, insufficient signal-to-noise ratio for low-contrast implicit defects, high false negative rates, and susceptibility to interference from glass surface textures during morphological processing. The method employs tensor decomposition, focusing implicit defect information through higher-order tensor components. Spectral residual optimization separates the background and residual in the logarithmic spectrum using Gaussian filtering. Inverse transformation generates a residual map with significantly enhanced defects, fundamentally suppressing interference from background textures. Furthermore, it addresses the challenges of changing glass batches on the production line, the inability of fixed-parameter detection algorithms to adapt to variations, and the poor real-time performance of linear array scanning, which fails to meet online detection requirements. The method calculates the mean and standard deviation of the residual map to generate a dynamic threshold. Based on this threshold, the residual map is binarized. A high-speed interface and real-time network ensure extremely low latency from result output to execution, automatically identifying and sorting defects, significantly improving production line efficiency.
[0004] The technical solution adopted by this invention is as follows: This invention provides a method for detecting latent defects on glass surfaces, which includes the following steps:
[0005] Step S1: Image acquisition;
[0006] Step S2: Tensor decomposition;
[0007] Step S3: Spectral residual optimization;
[0008] Step S4: Adaptive segmentation;
[0009] Step S5: Output the results.
[0010] Further, in step S1, the image acquisition includes the following steps:
[0011] Step S11: Lighting technology selection, adopting multi-mode hybrid lighting based on common hidden defect types in automotive glass;
[0012] Step S12: Image capture. The automotive glass is carried by a conveyor belt or robotic arm on the production line and moves at a constant speed. The system is coupled to the conveyor belt through a rotary encoder. The encoder provides real-time feedback of position information. When the glass reaches the precise starting position of the camera's field of view, the encoder sends a trigger signal to the Basler camera for precise exposure.
[0013] Step S13: Data acquisition. After receiving the trigger signal, the Basler camera begins exposure and reads sensor data at a frame rate of 15fps. The generated raw data stream is transmitted via the Camera Link HS interface protocol.
[0014] Step S14: Data caching. The massive amount of image data transmitted is cached on the FPGA board. Simple and decisive real-time preprocessing operations are performed before the data enters the main processing pipeline.
[0015] Further, in step S2, the tensor decomposition includes the following steps:
[0016] Step S21: Centralization processing. The industrial camera obtains a 10K×8K RGB image. This image is represented as a third-order tensor. The tensor... Centralized processing is implemented;
[0017] Step S22: Construct the decomposition model, using the following formula:
[0018] ;
[0019] In the formula, Z represents the preset decomposition rank, with a value of 5. Let R represent the characteristic distribution of the r-th component along the height direction, and let R represent the set of real numbers. This represents the characteristic distribution of the r-th component along the width direction. Let r represent the weight vector of the r-th component in the color channel. When r=1 or 2, background texture is separated; when r=3, 4, or 5, defect features are separated. Indicates the outer product operation;
[0020] Step S23: Output the factor matrix, using the following formula:
[0021] ;
[0022] ;
[0023] ;
[0024] In the formula, U represents the spatial height feature matrix, V represents the spatial width feature matrix, and W represents the channel weight matrix;
[0025] Step S24: FPGA parallel optimization. Initialize three factor matrices, use the ALS algorithm to fix two of the matrices, update the other matrix, and repeat the process. After each loop, calculate the reconstruction error. When the reconstruction error is less than a preset threshold, the loop stops.
[0026] Further, in step S3, the spectral residual optimization includes the following steps:
[0027] Step S31: High-order component loading. The high-order component feature map representing the defect information is obtained from the FPGA tensor decomposition stage. The high-order component feature map is generated by reconstructing the components corresponding to r≥3 in the spatial height feature matrix and spatial width feature matrix, and is transmitted to the global video memory of the NVIDIA A100 GPU through the high-speed bus.
[0028] Step S32: FFT transforms the high-order component feature map to the frequency domain, outputting a complex matrix containing the amplitude and phase spectra of the image. In the frequency domain, the global, regular textures of the image are represented by low-frequency components, while local, abrupt edges and defects are represented by high-frequency components. The formula used is as follows:
[0029] ;
[0030] In the formula, denoted as a complex matrix in the frequency domain, FFT represents the Fast Fourier Transform, and F represents the higher-order component feature map;
[0031] Step S33: Logarithmic spectrum calculation. The complex matrix is moduloed point-by-point to obtain the amplitude spectrum. Then, point-by-point natural logarithm calculation is performed to obtain the logarithmic amplitude spectrum. The formula used is as follows:
[0032] ;
[0033] In the formula, L represents the logarithmic amplitude spectrum. Indicates amplitude spectrum, This represents the smoothing constant, with a value of 10. -8 To prevent division by zero;
[0034] Step S34: Mean filtering, using a 7×7 Gaussian kernel for filtering, the formula is as follows:
[0035] ;
[0036] In the formula, The expression represents the smoothed logarithmic spectrum, and h represents the Gaussian filter kernel. Indicates the convolution operation;
[0037] Step S35: Extract the spectral residual by performing pointwise matrix subtraction. The formula used is as follows:
[0038] ;
[0039] In the formula, R1 represents the spectral residual;
[0040] Step S36: Calculate the residual map, use the spectral residual as the new amplitude, retain the phase spectrum of the original frequency domain signal, construct a new complex frequency domain signal, and then use an inverse transform to transform the frequency domain into the spatial domain, extract the real part, and obtain the final spatial domain residual map. The formula used is as follows:
[0041] ;
[0042] In the formula, Residual represents the residual map. In this map, the background area has low pixel gray values and is represented as dark, while the defect area has high pixel gray values and is represented as bright. Re() represents taking the real part of the complex number, IFFT represents the inverse fast Fourier transform, exp() represents the complex exponential function, i represents the imaginary unit, and angle() represents finding the phase of the complex number.
[0043] Further, in step S4, the adaptive segmentation includes the following steps:
[0044] Step S41: Calculate the statistical characteristics of the residual plot using the following formula:
[0045] ;
[0046] ;
[0047] In the formula, This represents the average grayscale value of all pixels in the residual image. M represents the square root of the variance, and N represents the height of the residual plot. This represents the total pixel value of the residual map. This represents the gray value of the residual image at pixel coordinates (x, y).
[0048] Step S42: Calculate the dynamic threshold using the following formula:
[0049] ;
[0050] In the formula, T represents the dynamic threshold, k represents the preset amplification factor, and k is 1.5;
[0051] Step S43: Generate a defect distribution map. Apply the calculated dynamic threshold to the entire residual map, perform pixel-by-pixel judgment, and generate the final defect distribution map. The outline, bounding rectangle coordinates, and centroid pixel coordinates of each white connected region in the defect distribution map constitute accurate defect location information. The formula used is as follows:
[0052] ;
[0053] In the formula, This represents the defect distribution map. A value of 1 indicates that the system has identified a defect at location (x, y), while a value of 0 indicates that the system has identified the location (x, y) as background.
[0054] Further, in step S5, the result output includes the following steps: the detection system transmits the defect location information generated by the GPU processing to the industrial control computer in real time through the PCIe 3.0 x8 high-speed interface, and then sends the sorting instruction to the PLC controller through the high deterministic industrial Ethernet, and finally the PLC drives the sorting mechanism to complete the precise removal of glass defects.
[0055] The beneficial results achieved by the present invention using the above solution are as follows:
[0056] (1) To address the technical problems of traditional edge detection, such as insufficient signal-to-noise ratio for low-contrast implicit defects, high false negative rate, and easy interference of glass surface texture in morphological processing, tensor decomposition is adopted. Implicit defect information is focused through high-order tensor components. Through spectral residual optimization, Gaussian filtering is used to separate the background and residual in the logarithmic spectrum. Then, the residual map with significantly enhanced defects is generated through inverse transformation, which fundamentally suppresses the interference of background texture.
[0057] (2) In response to the technical problem that glass batches on the production line may be changed, the detection algorithm with fixed parameters cannot adapt to the changes, the linear array scanning has poor real-time performance and cannot meet the online detection requirements, the mean and standard deviation of the residual map are calculated to generate a dynamic threshold. The residual map is binarized according to the threshold. High-speed interface and real-time network are used to ensure extremely low latency from the output of results to execution, automatically judge defects, and automatically sort, which greatly improves the production efficiency of the production line. Attached Figure Description
[0058] Figure 1 A schematic flowchart of a method for detecting latent defects on a glass surface provided by the present invention;
[0059] Figure 2 This is a flowchart illustrating step S2;
[0060] Figure 3 This is a flowchart illustrating step S3;
[0061] Figure 4 This is a flowchart illustrating step S4.
[0062] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof. Detailed Implementation
[0063] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0064] In the description of this invention, it should be understood that the terms "upper", "lower", "front", "rear", "left", "right", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.
[0065] Example 1, see Figure 1 The present invention provides a method for detecting latent defects on a glass surface, the method comprising the following steps:
[0066] Step S1: Image acquisition. Defects are highlighted through multi-mode mixed illumination, images are captured, and the image data is transmitted to the FPGA in real time for caching and preprocessing.
[0067] Step S2: Tensor decomposition, construct the image data into a third-order tensor and center it, construct the decomposition model, output the factor matrix, and iteratively update the factor matrix until the reconstruction error is less than the preset threshold.
[0068] Step S3: Spectral residual optimization, loading of higher-order components, generation of higher-order component feature maps. After transforming the higher-order component feature maps to the frequency domain using FFT, Gaussian filtering is used to separate the background and residuals in the logarithmic spectrum. Then, an inverse transformation is used to generate a residual map with significantly enhanced defects.
[0069] Step S4: Adaptive segmentation. By calculating the mean and standard deviation of the residual map, a dynamic threshold is generated. Based on this threshold, the residual map is binarized to generate a defect distribution map that separates the defects from the background.
[0070] Step S5: Output the results. Transmit the defect data to the industrial control computer, send instructions to the PLC via industrial Ethernet, and finally drive the sorting mechanism to accurately remove glass defects.
[0071] Example 2, see Figure 1 This embodiment is based on the above embodiment. In step S1, the image acquisition includes the following steps:
[0072] Step S11: Illumination technology selection. Based on the common types of hidden defects in automotive glass, multi-mode hybrid illumination is adopted, which includes dark field illumination, polarized light illumination, and backlight illumination. In the actual production line, multiple illumination modes are integrated into one imaging path through a beam splitter. The optical lens is a high-resolution industrial lens adapted to a 10K×8K resolution sensor to ensure that the modulation transfer function is high enough throughout the field of view, avoiding the lens itself becoming a bottleneck for resolution. At the same time, the lens distortion must be extremely small and strictly calibrated to ensure the geometric accuracy of the image.
[0073] Step S12: Image capture. The automotive glass is carried by a conveyor belt or robotic arm on the production line and moves at a constant speed. The system is coupled to the conveyor belt through a rotary encoder. The encoder provides real-time feedback of position information. When the glass reaches the precise starting position of the camera's field of view, the encoder sends a trigger signal to the Basler camera for precise exposure.
[0074] Step S13: Data acquisition. After receiving the trigger signal, the Basler camera begins exposure and reads sensor data at a frame rate of 15fps. The generated raw data stream is transmitted via the Camera Link HS interface protocol.
[0075] Step S14: Data caching. The massive amount of image data transmitted is cached on the FPGA board. Simple and decisive real-time preprocessing operations are performed before the data enters the main processing pipeline.
[0076] Example 3, see Figure 1 and Figure 2 This embodiment is based on the above embodiment. In step S2, the tensor decomposition includes the following steps:
[0077] Step S21: Centralized processing. The industrial camera obtains a 10K×8K RGB image, which is represented as a third-order tensor. I represents the number of pixels in the height direction of the image, with a value of 8192; J represents the number of pixels in the width direction of the image, with a value of 10240; K represents the number of image channel dimensions, with a value of 3 for RGB color images. Centralized processing is implemented;
[0078] Step S22: Construct the decomposition model. A dedicated tensor decomposition module is built based on the Xilinx XCVU9P chip. The formulas used are as follows:
[0079] ;
[0080] In the formula, Z represents the preset decomposition rank, with a value of 5. Let R represent the characteristic distribution of the r-th component along the height direction, and let R represent the set of real numbers. This represents the characteristic distribution of the r-th component along the width direction. Let r represent the weight vector of the r-th component in the color channel. When r=1 or 2, background texture is separated; when r=3, 4, or 5, defect features are separated. Indicates the outer product operation;
[0081] Step S23: Output the factor matrix. The factor matrix is efficiently cached using 16MB Block RAM. The formula used is as follows:
[0082] ;
[0083] ;
[0084] ;
[0085] In the formula, U represents the spatial height feature matrix, V represents the spatial width feature matrix, and W represents the channel weight matrix;
[0086] Step S24: FPGA parallel optimization, initialize three factor matrices, use the ALS algorithm for iterative update, fix two of the matrices, and use the hardware acceleration array to update the other matrix; calculate the reconstruction error in real time after each iteration, and stop the loop when the reconstruction error is less than the preset threshold to ensure that the tensor decomposition delay is less than 200μs and the module power consumption is stable at 12W.
[0087] Example 4, see Figure 1 and Figure 3 This embodiment is based on the above embodiment. In step S3, the spectral residual optimization includes the following steps:
[0088] Step S31: High-order component loading. The high-order component feature map representing the defect information is obtained from the FPGA tensor decomposition stage. The high-order component feature map is generated by reconstructing the components corresponding to r≥3 in the spatial height feature matrix and spatial width feature matrix, and is transmitted to the global video memory of the NVIDIA A100 GPU through the high-speed bus.
[0089] Step S32: FFT transformation. 1024 thread blocks are started on the GPU, each with a 256-thread grid configuration. The high-order component feature maps are transformed to the frequency domain, outputting a complex matrix containing the amplitude and phase spectra of the image. In the frequency domain, global, regular textures of the image are represented by low-frequency components, while local, abrupt edges and defects are represented by high-frequency components. The formula used is as follows:
[0090] ;
[0091] In the formula, denoted as a complex matrix in the frequency domain, FFT represents the Fast Fourier Transform, and F represents the higher-order component feature map;
[0092] Step S33: Logarithmic spectrum calculation. The complex matrix is moduloed point-by-point to obtain the amplitude spectrum. Then, point-by-point natural logarithm calculation is performed to obtain the logarithmic amplitude spectrum. The formula used is as follows:
[0093] ;
[0094] In the formula, L represents the logarithmic amplitude spectrum. Indicates amplitude spectrum, This represents the smoothing constant, with a value of 10. -8 To prevent division by zero;
[0095] Step S34: Mean filtering. Data access is optimized through shared memory and register block strategies. A 7×7 Gaussian kernel is used for filtering, and the formula is as follows:
[0096] ;
[0097] In the formula, The expression represents the smoothed logarithmic spectrum, and h represents the Gaussian filter kernel. Indicates the convolution operation;
[0098] Step S35: Extract the spectral residual by performing pointwise matrix subtraction. The formula used is as follows:
[0099] ;
[0100] In the formula, R1 represents the spectral residual;
[0101] Step S36: Calculate the residual map, use the spectral residual as the new amplitude, retain the phase spectrum of the original frequency domain signal, construct a new complex frequency domain signal, and then use an inverse transform to transform the frequency domain into the spatial domain, extract the real part, and obtain the final spatial domain residual map. The formula used is as follows:
[0102] ;
[0103] In the formula, Residual represents the residual map. In this map, the background area has low pixel gray values and is represented as dark, while the defect area has high pixel gray values and is represented as bright. Re() represents taking the real part of the complex number, IFFT represents the inverse fast Fourier transform, exp() represents the complex exponential function, i represents the imaginary unit, and angle() represents finding the phase of the complex number.
[0104] By performing the above operations, tensor decomposition is used to focus implicit defect information through high-order tensor components. Through spectral residual optimization, Gaussian filtering is used to separate the background and residual in the logarithmic spectrum. Then, an inverse transformation is used to generate a residual map with significantly enhanced defects, which fundamentally suppresses the interference of background texture. This solves the technical problems of traditional edge detection of defects, such as insufficient signal-to-noise ratio for low-contrast implicit defects, high false negative rate, and morphological processing being easily interfered with by glass surface texture.
[0105] Example 5, see Figure 1 and Figure 4 This embodiment is based on the above embodiment. In step S4, the adaptive segmentation includes the following steps:
[0106] Step S41: Calculate the statistical characteristics of the residual plot using the following formula:
[0107] ;
[0108] ;
[0109] In the formula, This represents the average grayscale value of all pixels in the residual image. M represents the square root of the variance, and N represents the height of the residual plot. This represents the total pixel value of the residual map. This represents the gray value of the residual image at pixel coordinates (x, y).
[0110] Step S42: Calculate the dynamic threshold using the following formula:
[0111] ;
[0112] In the formula, T represents the dynamic threshold, k represents the preset amplification factor, and k is 1.5;
[0113] Step S43: Generate a defect distribution map. Apply the calculated dynamic threshold to the entire residual map, perform pixel-by-pixel judgment, and generate the final defect distribution map. The outline, bounding rectangle coordinates, and centroid pixel coordinates of each white connected region in the defect distribution map constitute accurate defect location information. The formula used is as follows:
[0114] ;
[0115] In the formula, This represents the defect distribution map. A value of 1 indicates that the system has identified a defect at location (x, y), while a value of 0 indicates that the system has identified the location (x, y) as background.
[0116] Example 6, see Figure 1 This embodiment is based on the above embodiment. In step S5, the result output includes the following steps: the detection system transmits the defect location information generated by the GPU processing to the industrial control computer in real time through the PCIe 3.0 x8 high-speed interface, and then sends the sorting instruction to the PLC controller through the high deterministic industrial Ethernet. Finally, the PLC drives the sorting mechanism to complete the precise removal of glass defects.
[0117] By performing the above operations, the mean and standard deviation of the residual map are calculated to generate a dynamic threshold. The residual map is then binarized based on this threshold. A high-speed interface and real-time network ensure extremely low latency from result output to execution. Defects are automatically identified and sorted, greatly improving the production efficiency of the production line. This solves the technical problems that fixed-parameter detection algorithms cannot adapt to changes in glass batches on the production line, and linear array scanning has poor real-time performance, failing to meet the needs of online inspection.
[0118] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0119] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention.
[0120] The present invention and its embodiments have been described above. This description is not restrictive, and the accompanying drawings are only one embodiment of the present invention; the actual structure is not limited thereto. In conclusion, if those skilled in the art are inspired by this description and design similar structures and embodiments without departing from the spirit of the invention, such designs should fall within the protection scope of the present invention.
Claims
1. A method for detecting latent defects on glass surfaces, characterized in that: The method includes the following steps: Step S1: Image acquisition. Defects are highlighted through multi-mode mixed illumination, images are captured, and the image data is transmitted to the FPGA in real time for caching and preprocessing. Step S2: Tensor decomposition, construct the image data into a third-order tensor and center it, construct the decomposition model, output the factor matrix, and iteratively update the factor matrix until the reconstruction error is less than the preset threshold. Step S3: Spectral residual optimization, loading of higher-order components, generation of higher-order component feature maps. After transforming the higher-order component feature maps to the frequency domain using FFT, Gaussian filtering is used to separate the background and residuals in the logarithmic spectrum. Then, an inverse transformation is used to generate a residual map with significantly enhanced defects. Step S4: Adaptive segmentation. By calculating the mean and standard deviation of the residual map, a dynamic threshold is generated. Based on this threshold, the residual map is binarized to generate a defect distribution map that separates the defects from the background. Step S5: Output the results.
2. The method for detecting latent defects on a glass surface according to claim 1, characterized in that: In step S2, the tensor decomposition includes the following steps: Step S21: Centralization processing. Obtain an RGB image from an industrial camera, represent this image as a third-order tensor, and process the tensor... Centralized processing is implemented; Step S22: Construct the decomposition model, using the following formula: ; In the formula, Z represents the preset decomposition rank, with a value of 5. Let R represent the characteristic distribution of the r-th component along the height direction, and let R represent the set of real numbers. This represents the characteristic distribution of the r-th component along the width direction. This represents the weight vector of the r-th component in the color channel. Indicates the outer product operation; Step S23: Output the factor matrix, using the following formula: ; ; ; In the formula, U represents the spatial height feature matrix, V represents the spatial width feature matrix, and W represents the channel weight matrix; Step S24: FPGA parallel optimization. Initialize three factor matrices, use the ALS algorithm to fix two of the matrices, update the other matrix, and repeat the process. Calculate the reconstruction error after each loop. Stop the loop when the reconstruction error is less than a preset threshold.
3. The method for detecting latent defects on a glass surface according to claim 1, characterized in that: In step S3, the spectral residual optimization includes the following steps: Step S31: High-order component loading. The high-order component feature map representing the defect information is obtained from the FPGA tensor decomposition stage. The high-order component feature map is generated by reconstructing the components corresponding to r≥3 in the spatial height feature matrix and spatial width feature matrix, and is transmitted to the global video memory of the NVIDIA A100 GPU through the high-speed bus. Step S32: FFT transforms the higher-order component feature map to the frequency domain, outputting a complex matrix containing the amplitude and phase spectra of the image. The formula used is as follows: ; In the formula, denoted as a complex matrix in the frequency domain, FFT represents the Fast Fourier Transform, and F represents the higher-order component feature map; Step S33: Logarithmic spectrum calculation. The complex matrix is moduloed point-by-point to obtain the amplitude spectrum. Then, point-by-point natural logarithm calculation is performed to obtain the logarithmic amplitude spectrum. The formula used is as follows: ; In the formula, L represents the logarithmic amplitude spectrum. Indicates amplitude spectrum, This represents the smoothing constant, with a value of 10. -8 To prevent division by zero; Step S34: Mean filtering, using a 7×7 Gaussian kernel for filtering, the formula is as follows: ; In the formula, The expression represents the smoothed logarithmic spectrum, and h represents the Gaussian filter kernel. Indicates the convolution operation; Step S35: Extract the spectral residual by performing pointwise matrix subtraction. The formula used is as follows: ; In the formula, R1 represents the spectral residual; Step S36: Calculate the residual map, use the spectral residual as the new amplitude, retain the phase spectrum of the original frequency domain signal, construct a new complex frequency domain signal, and then use an inverse transform to transform the frequency domain into the spatial domain, extract the real part, and obtain the final spatial domain residual map. The formula used is as follows: ; In the formula, Residual represents the residual plot, Re() represents taking the real part of the complex number, IFFT represents the inverse fast Fourier transform, exp() represents the complex exponential function, i represents the imaginary unit, and angle() represents finding the phase of the complex number.
4. The method for detecting latent defects on a glass surface according to claim 1, characterized in that: In step S4, the adaptive segmentation includes the following steps: Step S41: Calculate the statistical characteristics of the residual plot using the following formula: ; ; In the formula, This represents the average grayscale value of all pixels in the residual image. M represents the square root of the variance, and N represents the height of the residual plot. This represents the total pixel value of the residual map. This represents the gray value of the residual image at pixel coordinates (x, y). Step S42: Calculate the dynamic threshold using the following formula: ; In the formula, T represents the dynamic threshold and k represents the preset amplification factor; Step S43: Generate a defect distribution map. Apply the calculated dynamic threshold to the entire residual map, perform pixel-by-pixel judgment, and generate the final defect distribution map. The formula used is as follows: ; In the formula, This represents a defect distribution map.
5. The method for detecting latent defects on a glass surface according to claim 1, characterized in that: In step S5, the result output includes the following steps: the detection system transmits the defect location information to the industrial control computer in real time through a high-speed interface, and then sends the sorting instruction to the PLC controller through a highly deterministic industrial Ethernet. Finally, the PLC drives the sorting mechanism to complete the precise removal of glass defects.
6. The method for detecting latent defects on a glass surface according to claim 1, characterized in that: In step S1, the image acquisition includes the following steps: Step S11: Lighting technology selection, adopting multi-mode hybrid lighting; Step S12: Image capture. When the glass reaches the precise starting position of the camera's field of view, the encoder sends a trigger signal to the Basler camera for precise exposure. Step S13: Data acquisition. After receiving the trigger signal, the Basler camera begins exposure and reads sensor data. Step S14: Data caching. The massive amount of image data transmitted is cached on the FPGA board.