Diffusion plate defect detection model training method based on image enhancement
Patent Information
- Application Number
- CN202611059596.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-16
- Publication Date
- 2026-10-20
AI Technical Summary
然而,现有高光谱检测方法大多局限于挑选特征波段或计算简化的波段比值,未针对扩散板网格纹理的方向性特征进行局部增强,导致多波段数据中的方向性纹理差异被忽略,缺陷与网格结构在图像中仍保持较低的对比度
[0013]基于局部纹理方向性分布的多方向相关性增强处理,在像素点的局部邻域窗口内计算灰度值的多方向梯度响应值,依据响应值对像素进行方向性权重赋值并形成方向性权重矩阵,再以该矩阵为卷积核对波段图像执行加权卷积。该处理使得沿扩散板网格纹理主方向的灰度变化得到平滑,而偏离主方向的局部异常纹理被显著放大,缺陷区域原本杂乱或中断的方向性特征在增强图像中表现为与规则网格背景明显不同的高响应值。当将方向性权重矩阵按多个角度旋转并实施并行卷积时,可进一步捕获任意取向的细微纹理异常,突破传统各向同性滤波对所有方向同等处理导致的纹理模糊局限,使嵌入在网格纹理中的低对比度缺陷的边界和形态更为完整地呈现,由此在保持网格结构连续性的同时对缺陷产生强烈信号提升。
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This invention relates to the field of hyperspectral image defect detection technology, specifically to a method for training a diffuser plate defect detection model based on image enhancement. Background Technology
[0002] As an optical element with a regular micro / nano grid structure, the surface defects of diffuser plates, such as scratches, pits, and foreign objects, can severely affect their optical performance, making high-precision automated defect detection crucial. Current technologies for diffuser plate defect detection typically employ manual visual inspection or image processing methods based on visible light industrial cameras. Manual visual inspection relies on operator experience, resulting in poor consistency and low efficiency. Visible light imaging methods utilize texture or grayscale thresholding under single illumination, but due to the significant directionality of the diffuser plate grid texture and the weak defect signal, conventional image processing techniques struggle to effectively separate defects from the grid background. Some solutions introduce hyperspectral imaging technology, acquiring richer spectral information by collecting dozens or even hundreds of narrow-band images. However, most existing hyperspectral detection methods are limited to selecting characteristic bands or calculating simplified band ratios, failing to locally enhance the directional characteristics of the diffuser plate grid texture. This leads to the neglect of directional texture differences in multi-band data, resulting in low contrast between defects and the grid structure in the image. Meanwhile, existing methods, when extracting defect detection parameters, often directly set fixed discrimination thresholds based on the overall image's grayscale statistical characteristics, failing to consider the spatial distribution differences between normal grayscale gradations caused by structural fluctuations at diffuser grid nodes and actual defect grayscale jumps. While the grayscale changes in grid node regions may numerically resemble those of minute defects, they exhibit distinguishable patterns in spatial location and deviation from the grid structure. Conventional detection models fail to utilize this spatial deviation information, resulting in a lack of adaptive threshold setting and a tendency to misclassify grid nodes as defects or miss actual defects. Therefore, a method is needed that can enhance the multi-directional texture correlation of multi-band diffuser images and combine multi-band grayscale jump characteristics with grid structure spatial deviations to construct a detection model. This would address the problems of minute defects being difficult to highlight in directional textured backgrounds and the easy confusion between normal grayscale fluctuations caused by the grid structure and defect grayscale jumps. Summary of the Invention
[0003] This invention provides a training method for a diffusion plate defect detection model based on image enhancement, which aims to significantly enhance and accurately distinguish minute defects in hyperspectral images of diffusion plates. By combining directional texture enhancement and multi-band gradient characteristics with grid structure deviation, a detection model that can adaptively distinguish defective pixels from normal pixels is constructed.
[0004] To achieve the above objectives, the present invention provides the following technical solution: The present invention provides a method for training a diffusion plate defect detection model based on image enhancement, comprising the following steps:
[0005] A set of multi-band raw image data of a diffuser sample acquired by a hyperspectral camera under preset light source conditions is obtained. Multi-directional correlation enhancement processing based on local texture directionality distribution is performed on each band image in the multi-band raw image data set to generate an enhanced image set. As a technical solution of this invention, the enhancement processing includes: dividing each band image into local neighborhood windows for each pixel; calculating the multi-directional gradient response value of the pixel's grayscale value within the local neighborhood window; assigning directional weights to the pixels based on the multi-directional gradient response values to generate a directional weight matrix; and performing a weighted convolution operation on the band images using the directional weight matrix as the convolution kernel to generate an enhanced image. Preferably, the weighted convolution operation can rotate the directional weight matrix according to multiple preset angles to generate multiple directional weight sub-matrices. These directional weight sub-matrices are then used to perform parallel convolution operations on the band images to obtain multiple directional convolution response maps, and the maximum grayscale value at the same pixel location is taken to form the final enhanced image. This step enables adaptive enhancement of the grayscale difference at the edge of the defect based on the directional characteristics of the surface texture of the diffuser plate, effectively suppressing the interference of the regular texture background, so that the small defects can obtain a consistent and eye-catching response on multi-band images.
[0006] Based on the grayscale value sequence of each pixel in the enhanced image set under different bands, a two-dimensional amplitude gradient distribution map of the pixels is constructed. Specifically, the grayscale values of each pixel under all bands are extracted to construct a grayscale value sequence; the grayscale value sequence is differentially processed to obtain the grayscale value change rate sequence between adjacent bands; the maximum value of the grayscale value change rate sequence is used as the amplitude feature of the pixel, and the standard deviation of the grayscale value change rate sequence is used as the gradient feature of the pixel; the two-dimensional amplitude gradient distribution map is constructed with the amplitude feature as the horizontal axis and the gradient feature as the vertical axis. Preferably, the amplitude feature and gradient feature are linearly normalized and mapped to a preset coordinate space range, and the coordinate space is divided into grids according to a preset grid step size. The number of pixels falling in each grid cell is counted, and the grid cells are grayscale colored according to the number of pixels to obtain an intuitive two-dimensional amplitude gradient distribution map. This distribution map can separate the drastic spectral changes caused by defects from the smooth normal texture fluctuations in the feature space, providing a stable and distinguishable feature benchmark for the identification of defective pixels.
[0007] Based on the two-dimensional amplitude gradient distribution map, a set of pixels with drastic grayscale value jumps is identified as candidate defect regions. Preferably, spatial statistics based on pixel density are performed on the two-dimensional amplitude gradient distribution map to identify sparse regions where pixel density is below a preset density threshold. The amplitude features corresponding to pixels in the sparse regions are sorted, and pixels with amplitude features greater than the preset amplitude threshold are extracted from the sorted results to form a set of pixels with drastic grayscale value jumps. Based on the spatial connectivity of this set of pixels, pixel groups whose connectivity satisfies a preset clustering threshold are aggregated to generate candidate defect regions. More preferably, the set of pixels with drastic grayscale value jumps is labeled with eight-neighbor connected components to generate multiple connected components. The ratio of the perimeter to the area of each connected component is calculated as a compactness index, and connected components whose compactness index satisfies a preset compactness threshold are selected as candidate defect regions. This process utilizes the distribution patterns of pixels in the amplitude-gradient space and spatial compactness constraints to eliminate isolated noise and false defects, making the candidate regions closer to the actual defect morphology.
[0008] Based on the positional deviation between the candidate defect region and the diffuser grid structure to which the pixel belongs, defective pixel intervals and normal pixel intervals are divided. Specifically, the grid structure parameters of the diffuser sample are extracted to generate a grid node coordinate matrix; for each pixel in the candidate defect region, the Euclidean distance between it and the nearest grid node in the grid node coordinate matrix is calculated as the positional deviation; the positional deviation is normalized to generate a deviation score; according to the deviation score, pixels with a deviation greater than a preset deviation threshold are classified as defective pixel intervals, and pixels with a deviation less than or equal to the preset deviation threshold are classified as normal pixel intervals. This step introduces the inherent grid structure of the diffuser as a spatial reference, which can avoid misjudging slight undulations at the grid edges as defects and improve the accuracy of defect localization.
[0009] Based on the pixel grayscale statistical characteristics of the defective pixel interval and the normal pixel interval, the detection parameter set of the diffuser plate sample is determined, and the detection model is constructed. A preferred approach is to calculate the mean grayscale value of all pixels in both the defective and normal pixel intervals, generating the defective grayscale mean and the normal grayscale mean; calculate the grayscale variance of all pixels in both intervals, generating the defective grayscale variance and the normal grayscale variance; and determine the grayscale discrimination threshold in the detection parameter set based on the difference between the defective and normal grayscale mean values, combined with the ratio of the defective grayscale variance to the normal grayscale variance. This detection parameter set fully reflects the separability of defects and background in grayscale statistics and can be directly used for accurate pixel classification during online detection.
[0010] As a further improvement of the present invention, after generating the enhanced image set, histogram equalization processing based on the cumulative distribution function of pixel gray levels can be applied to the images in the enhanced image set to generate an equalized enhanced image set. Based on the offset of the gray level of each pixel in the equalized enhanced image set from the mean gray level of its local neighborhood, regions of abnormal brightness are located. These regions of abnormal brightness are then used as constraints to correct the spatial boundaries of candidate defect regions. This processing can correct the overall brightness deviation caused by uneven light sources or differences in hyperspectral response, making the defect boundary delineation more closely match the actual defect contour, and further improving the detection model's ability to detect weak contrast defects.
[0011] The method of this invention utilizes multi-band information from hyperspectral imaging, combined with texture directionality enhancement, spectral gradient feature spatial mapping, mesh structure deviation analysis, and grayscale statistical modeling. It can extract defect regions with high precision and automatically determine detection parameters against complex diffuser plate texture backgrounds, significantly reducing reliance on manual calibration and improving the robustness and efficiency of the model in detecting various minute defects in mass production.
[0012] The technical effects and advantages provided by the present invention in the above technical solution are as follows:
[0013] Multi-directional correlation enhancement based on local texture directionality distribution calculates multi-directional gradient response values of grayscale values within the local neighborhood window of each pixel. Directional weights are assigned to pixels based on these response values to form a directional weight matrix, which is then used as the kernel for weighted convolution of the band image. This process smooths grayscale changes along the main direction of the diffuser grid texture, while significantly amplifying local anomalous textures deviating from the main direction. The originally chaotic or interrupted directional features of defect areas appear as high response values in the enhanced image, distinctly different from the regular grid background. When the directional weight matrix is rotated at multiple angles and parallel convolution is performed, subtle texture anomalies of arbitrary orientation can be further captured. This overcomes the limitation of traditional isotropic filtering, which processes all directions equally, resulting in texture blurring. It allows for a more complete presentation of the boundaries and shapes of low-contrast defects embedded in the grid texture, thus strongly enhancing the defect signal while maintaining the continuity of the grid structure.
[0014] By constructing a two-dimensional amplitude gradient distribution map, the maximum rate of change of grayscale value sequence for each pixel across the entire spectral band is extracted as the amplitude feature, and the standard deviation of the rate of change sequence is used as the gradient feature. Pixel distribution is statistically analyzed in a two-dimensional coordinate space, simultaneously measuring the absolute intensity of grayscale changes and the instability of spectral fluctuations. Using pixel density to filter sparse regions and extract high-amplitude pixels on this distribution map, suspected defect points with drastic grayscale value jumps can be quickly identified. Furthermore, a node coordinate matrix of the diffuser grid structure is introduced to calculate the Euclidean distance between each pixel within the defect candidate region and the nearest grid node, generating a deviation score. Based on the deviation score, defect pixel intervals and normal pixel intervals are divided. Normal grayscale fluctuations near grid nodes caused by the structure itself are classified into the normal pixel interval, while abnormal jump points with large spatial offsets from the grid nodes are identified as defects. The grayscale distinction threshold calculated in this way integrates three pieces of information: the amplitude of spectral jumps, the degree of fluctuation between bands, and the spatial deviation of the grid structure. It overcomes the high misjudgment rate caused by relying solely on the absolute grayscale threshold or a single spectral index. While having a certain tolerance for the grayscale changes of the diffuser grid structure itself, it reliably captures spectral feature distortions caused by minor defects. The detection parameter set shows good robustness to changes in illumination and differences in grid structure consistency. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.
[0016] Figure 1 This is a flowchart of the training method for a diffusion plate defect detection model based on image enhancement;
[0017] Figure 2 This is a flowchart of a diffuser image enhancement method based on multi-directional gradient response and directional weighted convolution;
[0018] Figure 3 This is a flowchart of a defect candidate region extraction method based on amplitude gradient distribution. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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, 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.
[0020] See Figure 1 This invention provides a training method for a diffusion plate defect detection model based on image enhancement, comprising the following steps: acquiring a set of multi-band raw image data of diffusion plate samples acquired by a hyperspectral camera under preset light source conditions. The diffusion plate samples can be diffusion plates randomly selected from the production line, containing various defects and normal structures. The preset light source conditions include the type of light source, incident angle, intensity, and spectral range. The hyperspectral camera simultaneously acquires images in multiple narrow bands within the visible to near-infrared range, obtaining grayscale images corresponding to each band, forming a set of multi-band raw image data.
[0021] Multi-directional correlation enhancement processing based on local texture directionality distribution is performed on each band image in the multi-band original image dataset to generate an enhanced image set. This processing utilizes the regular grid texture of the diffuser surface, analyzes the texture orientation within the local neighborhood of each pixel, calculates weighted responses in different directions, highlights anomalous regions with inconsistent texture orientations with the surrounding area, and suppresses background noise from the regular grid.
[0022] Based on the gray value sequence of each pixel in the enhanced image set under different bands, a two-dimensional amplitude gradient distribution map of the pixels is constructed. The gray values of the same pixel location in all enhanced band images are extracted and arranged into a gray value sequence. The gray value change rate sequence is obtained by differentiating the sequence. The maximum value of the change rate sequence is used as the amplitude feature, and the standard deviation of the change rate sequence is used as the gradient feature. With the amplitude feature as the horizontal axis and the gradient feature as the vertical axis, a two-dimensional distribution map is formed, so that defect pixels that are different from the spectral response of normal materials exhibit distinguishable clustering characteristics on the distribution map.
[0023] The set of pixels with drastic gray-level changes is determined based on the two-dimensional amplitude gradient distribution map, serving as candidate defect regions. Pixels with sparse density and high amplitude characteristics are identified on the distribution map, mapped back to the image space, and aggregated into candidate regions using spatial connectivity, thereby obtaining the preliminary defect location.
[0024] Based on the positional deviation between the candidate defect region and the diffuser mesh structure to which the pixel belongs, defective pixel intervals and normal pixel intervals are divided. The node coordinates of the diffuser mesh structure are extracted, and the Euclidean distance between each pixel in the candidate region and the nearest mesh node is calculated as the positional deviation. The deviation is normalized to generate a deviation score, and the pixels are divided into defective pixel intervals and normal pixel intervals by using the deviation score threshold.
[0025] Based on the pixel grayscale statistical characteristics of the defective pixel interval and the normal pixel interval, the detection parameter set of the diffuser plate sample is determined, and the detection model is constructed. The grayscale mean and grayscale variance of all pixels in the defective pixel interval and the normal pixel interval are calculated respectively. Using the difference between the grayscale mean values of the two intervals and the ratio of the grayscale variances, the grayscale discrimination threshold used for subsequent online detection is determined, thus completing the model training.
[0026] Example 1:
[0027] In specific implementation, please refer to Figure 2 For each band image, a local neighborhood window is created for each pixel. The local neighborhood window is a square window with an odd-numbered side length, determined by the diffuser grid spacing. The diffuser grid spacing is the pixel distance between adjacent grid nodes, obtained by pre-processing a Fourier transform on a defect-free diffuser sample to extract the spectral peak positions. Let the diffuser grid spacing be... Pixels, local neighborhood window side length according to Calculation, where This indicates a floor operation. It rounds down to the nearest integer, centered at each pixel, and rounds down to the nearest integer. The square region is used as the local neighborhood window of the pixel.
[0028] Calculate the multi-directional gradient response values of pixel grayscale values within a local neighborhood window. The multi-directional gradient response values include the horizontal gradient response values. Vertical gradient response value Gradient response value in the first diagonal direction Gradient response value in the second diagonal direction Horizontal gradient response value It is the sum of the absolute values of the differences in grayscale values between adjacent pixels in the same column within the window, calculated as follows:
[0029]
[0030] in, The coordinates of the center pixel of the window. For the window radius, Indicates the coordinates in the band image. The grayscale value of the pixel. Indicates the coordinates in the band image. The grayscale value of the pixel. Vertical gradient response value. It is the sum of the absolute values of the differences in grayscale values between adjacent pixels in the same row within the window, calculated as follows:
[0031]
[0032] in, Indicates the coordinates in the band image. The grayscale value of the pixel, the gradient response value in the first diagonal direction It is the sum of the absolute values of the grayscale differences between adjacent pixels along the direction from the top left to the bottom right within the window, calculated as follows:
[0033]
[0034] in, Indicates the coordinates in the band image. The grayscale value of the pixel, the gradient response value in the second diagonal direction It is the sum of the absolute values of the grayscale differences between adjacent pixels along the direction from the upper right to the lower left within the window, calculated as follows:
[0035]
[0036] in, Indicates the coordinates in the band image. The grayscale values of each pixel are assigned directional weights based on multi-directional gradient response values, generating a directional weight matrix. For the center pixel... The gradient response values in four directions , , , The gradient response value is sorted and compared to determine the dominant local texture direction. A directional weight matrix is set to the same size as the local neighborhood window, with each element representing the directional weight coefficient for its corresponding neighborhood location. In the directional weight matrix, the neighboring pixels corresponding to the dominant local texture direction are assigned the highest weight coefficient. The neighboring pixel positions corresponding to the direction orthogonal to the main direction of the local texture are assigned the lowest weight coefficient. The neighboring pixel positions corresponding to the other two directions are assigned intermediate weight coefficients. Highest weighting coefficient Intermediate weighting coefficient and lowest weight coefficient satisfy ,and One specific assignment method is as follows: , , The matrix assigned according to the directional correspondence is used as the directional weight matrix for that pixel.
[0037] A weighted convolution operation is performed on the band image using the directional weight matrix as the convolution kernel. The weighted convolution operation process is as follows: First, the directional weight matrix is rotated according to several preset angles to generate multiple directional weight sub-matrices. The preset angles include 0 degrees, 45 degrees, 90 degrees, and 135 degrees. The rotation operation is centered on the center of the directional weight matrix, and bilinear interpolation is used to resample and determine the values of the matrix elements after rotation, keeping the directional weight relationships of the matrix elements unchanged after rotation, resulting in 0-degree, 45-degree, 90-degree, and 135-degree directional weight sub-matrices.
[0038] Multiple directional weight sub-matrices are used to perform parallel convolution operations on the band image, obtaining multiple directional convolution response maps. For a given directional weight sub-matrix, the image is slid pixel-by-pixel across the band image. The sum of the product of the corresponding elements of the directional weight sub-matrix and the covered band image region is used as the convolution response value of the center pixel in that direction. Let the size of the directional weight sub-matrix be... Window radius For coordinates in the band image pixels, direction Corresponding convolution response value The calculation formula is:
[0039]
[0040] in, For direction indication, choose 0 degrees, 45 degrees, 90 degrees, or 135 degrees; Indicates direction Relative offset in the corresponding directional weight submatrix Weighting coefficients at each location; Indicates the coordinates in the band image. The grayscale value of each pixel. Traverse all pixel positions in the band image to obtain the direction. The corresponding directional convolution response map.
[0041] The enhanced image is generated by taking the maximum grayscale value at the same pixel location in the convolutional response map of multiple directions. For coordinates... Enhance the grayscale value of the pixel in the image. for:
[0042]
[0043] The above steps are performed on each band image in the multi-band original image data set to combine the enhanced images corresponding to all band images and generate an enhanced image set.
[0044] Example 2:
[0045] In practice, the grayscale values of each pixel across all bands are extracted to construct a grayscale value sequence. The enhanced image set contains enhanced images with the same number of bands as the original multi-band image dataset, for a total of [number missing]. , This represents the number of spectral channels in the hyperspectral camera, ranging from 10 to 200. For the enhanced image set, the spatial coordinates are... The pixels are analyzed, and their grayscale values are extracted in ascending order of band index to form a grayscale value sequence. ,in Representing coordinates The pixel in the first Gray values in an enhanced image of each band. For band indexing, .
[0046] Perform a difference operation on the grayscale value sequence to obtain the grayscale value change rate sequence between adjacent bands. The difference operation uses a forward difference method. For the grayscale value sequence... grayscale value and the grayscale value The rate of change of gray values between adjacent bands The calculation formula is:
[0047]
[0048] in, For the position index of the rate of change sequence, ; Indicates the first The rate of change of gray values between adjacent band pairs; For the first The grayscale value of this pixel in a band-enhanced image; For the first The grayscale value of this pixel in the enhanced image of each band; This is a preset, extremely small positive constant used to avoid the denominator being zero. Values ; Indicates taking and The larger of the two values. Perform the above calculation sequentially on all adjacent band pairs in the grayscale value sequence to obtain the grayscale value change rate sequence. .
[0049] The maximum value of the grayscale value change rate sequence is used as the amplitude feature of the pixel, and the standard deviation of the grayscale value change rate sequence is used as the gradient feature of the pixel. Amplitude Feature The calculation method is as follows: for the gray value change rate sequence All The rate of change takes the maximum value, that is... Gradient features The calculation method is as follows: first calculate the gray value change rate sequence. middle The mean of the rate of change values Then calculate the gradient features The above calculations are performed on each pixel at each spatial coordinate position in the enhanced image set to obtain the magnitude and gradient features of each pixel.
[0050] A two-dimensional amplitude and gradient distribution map is constructed using amplitude features as the x-axis and gradient features as the y-axis. During construction, both amplitude and gradient features are first linearly normalized and mapped to a preset coordinate space. The preset coordinate space uses x-axis and y-axis values... Interval. The magnitude feature for any pixel. The linearly normalized x-axis coordinate values The calculation method is as follows:
[0051]
[0052] in, This represents the minimum value of the magnitude feature of all pixels. This represents the maximum value of the magnitude feature across all pixels. For gradient features... The ordinate values after linear normalization The calculation method is as follows:
[0053]
[0054] in, The minimum value of the gradient features of all pixels. This represents the maximum value of the gradient features of all pixels. After linear normalization, each pixel corresponds to a coordinate space range. A two-dimensional coordinate point within .
[0055] The coordinate space is divided into grids according to a preset grid step size, and the number of pixels falling into each grid cell is counted. Preset grid step size. Set to 0.01, and adjust the horizontal axis. The interval is divided into equal parts Each interval will be represented by the vertical axis. The interval is divided into equal parts The coordinate space is divided into intervals. The grid unit size is set to 0.01. This is to balance the statistical resolution and computational efficiency of the distribution map. A step size of 0.01 maintains sufficient detail resolution while avoiding the loss of statistical significance due to excessively fine division resulting in too few pixels per grid unit. For the horizontal axis... The interval, the vertical axis of the first interval A grid cell for each interval, where , Statistical coordinates satisfy and The number of pixels, denoted as .
[0056] The grid cells are colored in grayscale based on the number of pixels within each cell, generating a two-dimensional amplitude gradient distribution map. A linear grayscale mapping method is used, first determining the number of pixels in each grid cell... Normalization to The interval is used to obtain the normalized density value. ,in This represents the maximum number of pixels across all grid cells. Then, normalize the density value. Mapped to grayscale values , An integer between 0 and 255. Pixels are represented by grid cells, and grayscale values are used. Fill, forming a size of A two-dimensional amplitude gradient distribution map of a pixel. The horizontal axis of the two-dimensional amplitude gradient distribution map corresponds to the amplitude feature dimension, and the vertical axis corresponds to the gradient feature dimension. The gray value at each position reflects the cluster density of the pixel under the combination of amplitude and gradient features.
[0057] Example 3:
[0058] In specific implementation, please refer to Figure 3 Spatial statistics based on pixel density are performed on the two-dimensional amplitude gradient distribution map to identify sparse regions where the pixel density in the two-dimensional amplitude gradient distribution map is below a preset density threshold. The size of the two-dimensional amplitude gradient distribution map is... Pixels and All are 100. A square neighborhood is drawn centered on each pixel, and the side length of the neighborhood is calculated. The resolution is determined by the two-dimensional magnitude gradient distribution map. Set to 5 pixels. The rationale for using 5 pixels is as follows: the grid step size for dividing the coordinate space in a two-dimensional amplitude gradient distribution map is 0.01, corresponding to 100 grid cells. A statistical neighborhood of 5 pixels can cover an amplitude-gradient feature range of 0.05 in both the horizontal and vertical axes, which is sufficient to smooth local statistical fluctuations without excessively blurring density distribution details. For a two-dimensional amplitude gradient distribution map with coordinates... The pixels, of which , Calculate the number of original pixels falling within the statistical neighborhood. The original pixels refer to the number of pixels counted within each grid cell that constitutes the two-dimensional magnitude gradient distribution map. Each pixel in the two-dimensional magnitude gradient distribution map corresponds to a grid cell. By traversing all pixels in the two-dimensional magnitude gradient distribution map, the local density value at each location is obtained. Preset density threshold Set as all local density values The median multiplied by a scaling factor , Take 0.3. Proportionality coefficient. The rationale for setting the value to 0.3 is as follows: In diffuser samples, defective pixels typically account for a small proportion of the total number of pixels in the image. Regions with a local density below 30% of the overall median can effectively filter out sparsely distributed pixel clusters while eliminating background noise. The local density value... less than the preset density threshold The corresponding positions of the pixels on the two-dimensional magnitude gradient distribution map are marked as sparse regions.
[0059] The amplitude features corresponding to pixels in the sparse region are sorted, and pixels with amplitude features greater than a preset amplitude threshold are extracted from the sorted results, forming a set of pixels with drastic grayscale value jumps. Each pixel in the sparse region corresponds to one or more pixels in the original diffuser sample image space. The amplitude features of the original pixels are then associated with all pixels in the sparse region. The amplitude features are aggregated into a single set. The aggregated amplitude features are then sorted in descending order to obtain a sorted sequence. A preset amplitude threshold is set. Take the first element in the sorted sequence The values of each amplitude feature, where This represents the total number of original pixels associated with the sparse region. This is a preset ratio value. Take 0.15, This indicates rounding up to the nearest integer. The rationale for using 0.15 is to retain the top 15% of pixels with the largest amplitude characteristics in the sparse region. This proportion can cover most defective pixels with significant spectral jumps, while filtering out isolated high-amplitude points caused by noise. Pixels with amplitude characteristics greater than [a certain value] in the sparse region are [selected for other regions]. All the original pixels are extracted to form a set of pixels with drastic grayscale value changes.
[0060] Based on the spatial connectivity of a set of pixels with drastic grayscale value changes, pixel groups whose connectivity meets a preset clustering threshold are aggregated to generate candidate defect regions. The aggregation process is as follows: Eight-neighbor connectivity is labeled for the set of pixels with drastic grayscale value changes, generating multiple connected components. The eight-neighbor connectivity labeling method is as follows: For each pixel in the set of pixels with drastic grayscale value changes, for the current pixel, check whether its eight neighboring pixels also belong to the set of pixels with drastic grayscale value changes. The eight neighboring pixels include the pixel directly above, the pixel directly below, the pixel to the left, the pixel to the right, the pixel to the upper left, the pixel to the upper right, the pixel to the lower left, and the pixel to the lower right. If a neighboring pixel belongs to this set and has not yet been assigned a connectivity label, it is assigned the same connectivity label as the current pixel; if a neighboring pixel has already been labeled, the current pixel is assigned to the connected component corresponding to that label. After all pixels have been traversed, pixels with the same connectivity label form a connected component, and each connected component contains multiple neighboring pixels.
[0061] Calculate the ratio of the perimeter to the area of each connected component as an indicator of the compactness of the connected components. For connected components... The perimeter of a connected region The number of boundary pixels of a connected component. Boundary pixels are determined as follows: a pixel in a connected component is considered a boundary pixel if at least one pixel in its eight neighborhoods does not belong to the same connected component. The area of the connected component. This represents the total number of pixels within the connected component. The formula for calculating the compactness index is:
[0062]
[0063] in, For connected components Compactness index; For connected components The perimeter, expressed in pixels; For connected components Area, expressed in pixels. Compactness index. A larger value indicates a more complex boundary and a less compact shape of the connected domain, such as a slender, scratch-like defect; compactness index The smaller the value, the closer the shape of the connected region is to a circle or square, such as a point-like depression defect.
[0064] Connected regions whose compactness index meets a preset compactness threshold are selected as candidate defect regions. The preset compactness threshold is set to an interval. , Take 0.1, Take 1.0. The basis for choosing 0.1 is: the theoretical value of the compactness of a circular connected region is approximately... For circular connected regions with an area exceeding 300 pixels, the compactness value is usually less than 0.36. Setting a lower limit of 0.1 can eliminate extremely large blocky noise regions. The rationale for using 1.0 is that the perimeter-to-area ratio of slender scratches can approach 1.0, while connected regions exceeding 1.0 are typically chain-like artifacts composed of discrete noise points and are not treated as defects in the diffuser plate. The compactness index... satisfy The connected components are preserved and output as candidate regions for defects.
[0065] Example 4:
[0066] In the specific implementation, the mesh structure parameters of the diffuser sample are extracted to generate a mesh node coordinate matrix. The mesh structure parameters of the diffuser sample include the mesh row spacing, mesh column spacing, and the coordinates of the starting mesh node. The mesh row spacing is the pixel distance between two adjacent rows of mesh nodes, and the mesh column spacing is the pixel distance between two adjacent columns of mesh nodes. The method for extracting the mesh structure parameters is as follows: A band image of a defect-free diffuser sample is acquired under preset lighting conditions. A two-dimensional Fourier transform is performed on this band image to obtain a spectrum. The maximum energy peak point (excluding the DC component) is detected on the spectrum. The frequency coordinates of the maximum energy peak point correspond to the fundamental frequency of the diffuser mesh structure. The mesh column spacing is calculated from the frequency abscissa of the maximum energy peak point. The grid row spacing is calculated from the frequency ordinate of the point with the maximum energy peak. Grid start node coordinates Determined by: using coordinates in the band image. Starting from the step size and Move the grid and find the first coordinate point that simultaneously satisfies the condition of having the maximum local gray-level autocorrelation value in both its row and column directions. Use this coordinate point as the starting node coordinate of the grid. .
[0067] Based on grid row spacing Grid column spacing and grid start node coordinates Generate the grid node coordinate matrix. Let the width of the band image be... pixels, height is Pixel, row index in the grid node coordinate matrix and column indexes The scope is: , ; , ,in This indicates rounding down. The coordinates of the first node in the grid node coordinate matrix... Line 1 Column grid node coordinates for: , All Store the grid node coordinate matrix.
[0068] For each pixel in the defect candidate region, calculate the Euclidean distance between the pixel and the nearest grid node in the grid node coordinate matrix, which is used as the positional deviation. Let the coordinates of a pixel in the defect candidate region be... Traverse the coordinates of all grid nodes in the grid node coordinate matrix Calculate Euclidean distance Take all The minimum value in the range is used as the positional deviation of that pixel. : .
[0069] The positional deviation is normalized to generate a deviation score. The normalization process uses the grid half-interval as the normalization benchmark. Get grid row spacing Spacing between grid columns Half of the smaller value: Deviation score The calculation formula is:
[0070]
[0071] in, The deviation score has a range of values. ; This is the positional deviation, expressed in pixels. This represents the grid spacing in pixels. This means taking the smaller of the input value and 1 to ensure the bias score. No more than 1. Deviation score The closer the pixel is to 0, the closer it is to the grid node; deviation score The closer it is to 1, the farther the pixel is from the grid node.
[0072] Based on the deviation score, pixels exceeding a preset deviation threshold are classified as defective pixel ranges, while pixels less than or equal to the preset deviation threshold are classified as normal pixel ranges. Preset deviation threshold Set to 0.5. Preset deviation threshold. The basis for setting it to 0.5 is: when the deviation score... When the distance exceeds 0.5, the distance between the pixel and the nearest grid node is more than half the grid spacing, indicating that the pixel position deviates significantly from the regular grid structure. This belongs to an abnormal area of the diffuser plate grid structure and should be classified as a defective pixel range; deviation score. Pixels with a value less than or equal to 0.5 located near grid nodes or grid lines conform to the normal grid structure characteristics of a diffuser plate and should be classified as normal pixels. Traverse all pixels in the defect candidate region and... The pixels are classified into the defect pixel range, and the pixels are... The pixels are returned to the normal pixel range.
[0073] Example 5:
[0074] In practice, the average grayscale value of all pixels in the defective pixel range and the normal pixel range are calculated separately to generate the defective grayscale value and the normal grayscale value. From the enhanced image set, the reference band enhanced image with the most significant difference in the reflectivity of the diffuser material is selected. The band index of the reference band enhanced image is denoted as . The selection method is as follows: calculate the absolute value of the difference between the mean gray value of the defect pixel interval and the mean gray value of the normal pixel interval in the enhanced image of each band, and select the band with the largest absolute value of the difference as the reference band. For the defect pixel interval, assume that the defect pixel interval includes... There are 10 pixels, and the grayscale value of each pixel in the enhanced image of the reference band is denoted as . ,in , The index of the pixel within the defect pixel range, and the mean gray value of the defect. The calculation method is as follows: For the normal pixel range, let the normal pixel range include... There are 10 pixels, and the grayscale value of each pixel in the enhanced image of the reference band is denoted as . ,in , The index of the pixel within the normal pixel range, the normal grayscale mean. The calculation method is as follows: .
[0075] Calculate the grayscale variance of all pixels in the defective pixel range and the normal pixel range respectively, generating the defective grayscale variance and the normal grayscale variance. Defective grayscale variance The calculation method is as follows: ,in For the defective pixel range, the first The grayscale value of each pixel The grayscale average of the defects. This represents the total number of pixels within the defective pixel range. Normal grayscale variance. The calculation method is as follows: ,in The first pixel in the normal pixel range The grayscale value of each pixel This is the normal grayscale mean. This represents the total number of pixels within the normal pixel range.
[0076] Based on the difference between the defect grayscale mean and the normal grayscale mean, and combined with the ratio of the defect grayscale variance to the normal grayscale variance, a grayscale discrimination threshold is determined within the detection parameter set. Grayscale discrimination threshold The calculation formula is:
[0077]
[0078] in, The grayscale distinction threshold is used to separate defective pixels from normal pixels during the detection phase. This represents the normal grayscale average. The grayscale average of the defects; This is the adjustment coefficient. The range of values is Adjustment coefficient The method for obtaining this information is as follows: First, calculate the ratio of the defect grayscale variance to the normal grayscale variance. Then based on the ratio The adjustment coefficient is obtained through linear mapping. The mapping relationship is ,in For a pre-set ratio The maximum value that can be reached. The value is 3.0. Ratio The upper limit of 3.0 is based on the fact that, in diffuser plate defect detection scenarios, the grayscale dispersion in the defect area typically does not exceed three times the grayscale dispersion in the normal area. When the ratio... When the variance of defective grayscale is equal to the variance of normal grayscale, the adjustment coefficient... The grayscale distinction threshold is closer to the mean grayscale value of the defect; when the ratio At that time, the variance of defective grayscale is much larger than that of normal grayscale, and the adjustment coefficient... The grayscale distinction threshold is closer to the normal grayscale mean to adapt to situations where the grayscale distribution of defects has a large dispersion.
[0079] After generating the enhanced image set, histogram equalization based on the cumulative gray-level distribution function of pixels is performed on the images in the enhanced image set to generate an equalized enhanced image set. For each enhanced image in the enhanced image set, the histogram equalization process is as follows: The gray-level histogram of all pixels in the enhanced image is calculated, with 256 gray-level levels. The [missing information - likely a specific histogram or similar format] in the gray-level histogram... The frequency of each gray level is denoted as , ; Calculate the cumulative distribution function of gray levels ,in For the first Frequency of each gray level To increase the total number of pixels in an image, the original grayscale values in the image are enhanced using the cumulative grayscale distribution function. Mapped to equalized grayscale values The mapping formula is , This indicates rounding down. Replacing the original grayscale value with the equalized grayscale value yields an equalized enhanced image. The equalized enhanced images corresponding to all bands constitute an equalized enhanced image set.
[0080] Based on the offset between the gray value of each pixel and the average gray value of its local neighborhood in the equalization and enhancement image set, regions of abnormal brightness are located. For each equalization and enhancement image in the set, a local neighborhood window is taken centered on each pixel, with a side length of [missing information]. Pixels The value is 11. The reason for choosing 11 pixels is that the side length of the local neighborhood window needs to cover a complete period of the diffuser grid structure. The grid spacing of the diffuser is usually between 8 and 12 pixels. A window side length of 11 pixels can effectively calculate the local grayscale background without introducing too much background information. The average grayscale value of all pixels except the center pixel is calculated within the local neighborhood window. The grayscale value of the center pixel. Compared with the local neighborhood gray average The absolute difference is used as the offset. Preset offset threshold The value is 30. The rationale for choosing 30 is that in a 256-level grayscale image, a difference of 30 in grayscale values corresponds to approximately a 12% contrast difference, which can effectively distinguish between sudden brightness changes caused by defects and the regular grayscale variations inherent in the mesh structure itself. The offset will be... Greater than the preset offset threshold The pixels marked as having abnormal brightness are called abnormal brightness pixels, and the set of all abnormal brightness pixels is called the abnormal brightness region.
[0081] The spatial boundaries of the defect candidate region are corrected by using the brightness anomaly region as a constraint. The correction method is as follows: each pixel in the defect candidate region is checked. If a pixel in the defect candidate region also belongs to a brightness anomaly region, that pixel is retained; if a pixel in the defect candidate region does not belong to a brightness anomaly region, that pixel is removed from the defect candidate region. After correction, the retained pixels combine to form the final defect candidate region.
[0082] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A training method for a diffusion plate defect detection model based on image enhancement, characterized in that, Includes the following steps: Acquire a set of multi-band raw image data of the diffuser plate sample under preset light source conditions using a hyperspectral camera; Perform multi-directional correlation enhancement processing based on local texture directionality distribution on each band image in the multi-band original image dataset to generate an enhanced image set; Based on the gray value sequence of each pixel in the enhanced image set under different bands, a two-dimensional amplitude gradient distribution map of the pixel is constructed. The set of pixels with drastic gray value jumps is determined based on the two-dimensional amplitude gradient distribution map and used as candidate defect regions. Based on the positional deviation between the candidate defect region and the diffuser grid structure to which the pixel belongs, the defect pixel range and the normal pixel range are divided. Based on the pixel grayscale statistical characteristics of the defective pixel range and the normal pixel range, the detection parameter set of the diffuser plate sample is determined, and the detection model is constructed.
2. The training method for a diffusion plate defect detection model based on image enhancement according to claim 1, characterized in that, The step of performing multi-directional correlation enhancement processing based on local texture directionality distribution on each band image in the multi-band original image dataset to generate an enhanced image set includes: For each band image, a local neighborhood window is divided for each pixel, and the multi-directional gradient response value of the pixel gray value is calculated within the local neighborhood window. The pixel is assigned a directional weight based on the multi-directional gradient response value to generate a directional weight matrix; Using the directional weight matrix as the convolution kernel, a weighted convolution operation is performed on the band image to generate the enhanced image set.
3. The training method for a diffusion plate defect detection model based on image enhancement according to claim 1, characterized in that, The step of constructing a two-dimensional amplitude gradient distribution map of pixels based on the gray value sequence of each pixel in the enhanced image set under different bands includes: Extract the grayscale value of each pixel in all bands to construct the grayscale value sequence; Perform a difference operation on the gray value sequence to obtain a gray value change rate sequence between adjacent bands; The maximum value of the gray value change rate sequence is used as the amplitude feature of the pixel, and the standard deviation of the gray value change rate sequence is used as the gradient feature of the pixel. The two-dimensional amplitude gradient distribution map is constructed using the amplitude feature as the horizontal axis and the gradient feature as the vertical axis.
4. The training method for a diffusion plate defect detection model based on image enhancement according to claim 1, characterized in that, The step of determining the set of pixels with drastic grayscale value jumps based on the two-dimensional amplitude gradient distribution map as candidate defect regions includes: Perform spatial statistics based on pixel density on the two-dimensional amplitude gradient distribution map to determine sparse regions in the two-dimensional amplitude gradient distribution map where the pixel distribution density is lower than a preset density threshold; The amplitude features corresponding to the pixels in the sparse region are sorted, and the pixels with amplitude features greater than a preset amplitude threshold are extracted from the sorting results to form the set of pixels with drastic gray value changes. Based on the spatial connectivity of the set of pixels with drastic grayscale value changes, the pixel groups whose connectivity satisfies a preset clustering threshold are aggregated to generate the defect candidate region.
5. The training method for a diffusion plate defect detection model based on image enhancement according to claim 1, characterized in that, The step of dividing the defect pixel interval and the normal pixel interval based on the positional deviation between the defect candidate region and the diffuser plate mesh structure to which the pixel belongs includes: Extract the mesh structure parameters of the diffuser plate sample to generate a mesh node coordinate matrix; For each pixel in the defect candidate region, calculate the Euclidean distance between the pixel and the nearest grid node in the grid node coordinate matrix, and use it as the positional deviation. The positional deviation is normalized to generate a deviation score; Based on the deviation score, pixels with a deviation greater than a preset deviation threshold are classified as defective pixel intervals, and pixels with a deviation less than or equal to the preset deviation threshold are classified as normal pixel intervals.
6. The training method for a diffusion plate defect detection model based on image enhancement according to claim 1, characterized in that, The step of determining the detection parameter set of the diffusion plate sample based on the pixel grayscale statistical characteristics of the defective pixel range and the normal pixel range includes: Calculate the average grayscale value of all pixels in the defective pixel interval and the normal pixel interval respectively to generate the defective grayscale value and the normal grayscale value; Calculate the grayscale variance of all pixels in the defective pixel range and the normal pixel range respectively to generate the defective grayscale variance and the normal grayscale variance; Based on the difference between the mean gray level of the defect and the mean gray level of the normal, and combined with the ratio of the variance of the gray level of the defect to the variance of the gray level of the normal, the gray level discrimination threshold in the detection parameter set is determined.
7. The training method for a diffusion plate defect detection model based on image enhancement according to claim 1, characterized in that, Also includes: After generating the enhanced image set, the images in the enhanced image set are subjected to histogram equalization processing based on the pixel gray-level cumulative distribution function to generate an equalized enhanced image set. Based on the offset between the gray value of each pixel in the equalized and enhanced image set and the average gray value of the local neighborhood of the pixel, the region of abnormal brightness is located. The spatial boundary of the defect candidate region is corrected by using the abnormal brightness region as a constraint condition.
8. The training method for a diffusion plate defect detection model based on image enhancement according to claim 2, characterized in that, The step of performing a weighted convolution operation on the band image using the directional weight matrix as the convolution kernel includes: The directional weight matrix is rotated at multiple preset angles to generate multiple directional weight sub-matrices; The band image is subjected to parallel convolution operations using the multiple directional weight sub-matrices to obtain multiple directional convolution response maps; The enhanced image is generated by taking the maximum grayscale value at the same pixel location in the multiple directional convolution response maps.
9. The training method for a diffusion plate defect detection model based on image enhancement according to claim 3, characterized in that, The construction of the two-dimensional amplitude gradient distribution map, with the amplitude feature as the horizontal axis and the gradient feature as the vertical axis, includes: The magnitude feature and the gradient feature are respectively linearly normalized and mapped to a preset coordinate space range; Within the coordinate space, the grid is divided according to a preset grid step size, and the number of pixels falling into each grid cell is counted. The grid cells are grayscale-colored based on the number of pixels in each grid cell to generate the two-dimensional amplitude gradient distribution map.
10. The training method for a diffusion plate defect detection model based on image enhancement according to claim 4, characterized in that, The step of aggregating pixel groups whose connectivity satisfies a preset clustering threshold based on the spatial connectivity of the set of pixels with drastic grayscale value changes includes: The set of pixels with drastic grayscale value jumps is labeled with eight-neighbor connected components to generate multiple connected components, each of which contains multiple adjacent pixels. Calculate the ratio of the perimeter to the area of each connected component as an index of the compactness of the connected component; Connected regions that meet the preset compactness threshold are selected as candidate defect regions.