A hardware fitting quality defect detection method and system based on industrial vision

CN122966604APending Publication Date: 2026-10-23SHENZHEN KAISHENG HARDWARE & PLASTIC PROD CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611177925.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-05
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

[0005]本申请提供一种基于工业视觉的五金配件质量缺陷检测方法及系统,旨在解决现有工业视觉检测中因采用固定滤波参数处理不同表面粗糙度配件,导致细微划痕边缘被误平滑而引发漏检的技术问题

Benefits of technology

本申请提供的方法及系统,通过计算配件各子区域的区域粗糙指数,结合多尺度纹理能量分布识别疑似噪声区域,并进一步利用梯度直方图分析确定噪声干扰置信符,实现了缺陷检测过程的自适应图像处理。该方案突破了传统固定参数滤波的局限性,能够根据配件表面的粗糙度动态调整平滑滤波策略,有效在抑制噪声干扰的同时保护了微弱缺陷(如细微划痕)的边缘信息,极大地降低了混流生产模式下的系统性漏检率,显著提升了工业视觉检测的精度与鲁棒性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122966604A_ABST
    Figure CN122966604A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of quality defect detection, and provides a hardware fitting quality defect detection method and system based on industrial vision, which comprises the following steps: determining the area roughness indexes of multiple sub-regions according to original image data of the surface of a hardware fitting to be detected; determining suspected noise interference regions in the multiple sub-regions according to the original image data and the area roughness indexes of the multiple sub-regions; processing the region image data of the suspected noise interference regions in the original image data based on convolution operation to determine noise interference confidence symbols of the suspected noise interference regions; and performing defect detection on the hardware fitting to be detected according to the area roughness indexes of the multiple sub-regions and the noise interference confidence symbols of the suspected noise interference regions. Through the scheme, the efficiency of hardware fitting quality defect detection can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of quality defect detection technology, and in particular to a method and system for detecting quality defects in hardware accessories based on industrial vision. Background Technology

[0002] In the field of metal stamping parts production, in order to achieve online quality defect detection, industrial vision systems are usually used to collect and analyze images of parts.

[0003] Existing technologies often employ globally uniform image preprocessing schemes, such as using Gaussian filtering with fixed parameters for spatial smoothing to suppress sensor noise. However, modern production lines frequently adopt mixed-product production modes, resulting in significant batch-to-batch variations in the surface roughness of the parts being processed. When the production line switches from rough parts to smooth, precision-stamped parts, minute scratches appear as low-contrast, dark, fine lines in the image, with minimal edge gradient variation.

[0004] Because existing fixed-parameter filtering operators lack the ability to adaptively perceive the surface roughness of parts, they cannot dynamically protect the low-gradient defect edges while suppressing noise. As a result, scratch edges are treated as noise and smoothed out, leading to the loss of scratch information and systematic missed detection in subsequent feature extraction stages. Summary of the Invention

[0005] This application provides a method and system for detecting quality defects in hardware accessories based on industrial vision, aiming to solve the technical problem in existing industrial vision inspection where the use of fixed filtering parameters to process accessories with different surface roughness leads to the accidental smoothing of the edges of minor scratches, resulting in missed detection.

[0006] The technical solution of this application is as follows: In a first aspect, this application discloses a method for detecting quality defects in hardware accessories based on industrial vision, comprising the following steps: acquiring original image data of the surface of the hardware accessory to be inspected; dividing the surface of the hardware accessory to be inspected into multiple sub-regions; determining the regional roughness index of each sub-region based on the original image data of the surface of the hardware accessory to be inspected; determining suspected noise interference regions among the multiple sub-regions based on the original image data and the regional roughness index of the multiple sub-regions; processing the regional image data of the suspected noise interference regions in the original image data based on convolution operation to determine the noise interference confidence symbol of the suspected noise interference regions; the noise interference confidence symbol is used to indicate whether noise interference exists in the suspected noise interference regions; and performing defect detection on the hardware accessory to be inspected based on the regional roughness index of the multiple sub-regions and the noise interference confidence symbol of the suspected noise interference regions.

[0007] Optionally, based on the original image data of the surface of the hardware component to be inspected, the regional roughness index of each sub-region is determined, including: based on the original image data of the surface of the hardware component to be inspected, determining the gray-level co-occurrence matrix of each sub-region; based on the gray-level co-occurrence matrix of each sub-region, determining the contrast, energy value and correlation index of the gray-level co-occurrence matrix of each sub-region; and based on the contrast, energy value and correlation index of the gray-level co-occurrence matrix of each sub-region, determining the regional roughness index of each sub-region.

[0008] Optionally, the region roughness index of each sub-region is determined based on the contrast, energy value, and correlation index of the gray-level co-occurrence matrix of each sub-region. This includes: multiplying the contrast of the gray-level co-occurrence matrix of each sub-region by a preset contrast coefficient to obtain the contrast roughness index of each sub-region; multiplying the energy value of the gray-level co-occurrence matrix of each sub-region by a preset energy value coefficient to obtain the energy value roughness index of each sub-region; determining the gray value standard deviation of each sub-region based on the original image data of the surface of the hardware accessory to be inspected; multiplying the gray value standard deviation of each sub-region by a preset gray value coefficient to obtain the gray value roughness index of each sub-region; and taking the average of the contrast roughness index, energy value roughness index, and gray value roughness index of each sub-region as the region roughness index of each sub-region.

[0009] Optionally, based on the original image data and the regional coarseness index of multiple sub-regions, suspected noise interference regions in the multiple sub-regions are determined, including: performing multi-scale two-dimensional discrete wavelet transform on the original image data to obtain horizontal high-frequency sub-bands, vertical high-frequency sub-bands, and diagonal high-frequency sub-bands; using the absolute values ​​of the wavelet coefficients of each sub-region in the horizontal high-frequency sub-band as the horizontal high-frequency coefficients of each sub-region; using the absolute values ​​of the wavelet coefficients of each sub-region in the vertical high-frequency sub-band as the vertical high-frequency coefficients of each sub-region; using the absolute values ​​of the wavelet coefficients of each sub-region in the diagonal high-frequency sub-band as the diagonal high-frequency coefficients of each sub-region; using the sum of the horizontal high-frequency coefficients, vertical high-frequency coefficients, and diagonal high-frequency coefficients of each sub-region as the texture energy distribution measure of each sub-region; and determining the suspected noise interference regions in the multiple sub-regions based on the texture energy distribution measures of the multiple sub-regions and the regional coarseness index of the multiple sub-regions.

[0010] Optionally, based on the texture energy distribution measurement and the regional roughness index of multiple sub-regions, suspected noise interference regions in multiple sub-regions are determined, including: obtaining the detection accuracy index of the hardware accessory to be inspected; using the sum of the upper limit adjustment step and the upper limit value of the preset roughness index range as the upper limit value of the target roughness index range, and using the difference between the lower limit value of the preset roughness index range and the lower limit adjustment step as the lower limit value of the target roughness index range; the upper limit adjustment step is the product of the detection accuracy index and the upper limit value of the preset roughness index range, and the lower limit adjustment step is the product of the detection accuracy index and the lower limit value of the preset roughness index range; the sub-regions in which the regional roughness index of the multiple sub-regions is located within the target roughness index range are designated as the first sub-regions; and the sub-regions in which the texture energy distribution measurement of the first sub-regions is located within the preset energy distribution measurement range are designated as suspected noise interference regions.

[0011] Optionally, based on convolution operations, the region image data of the suspected noise interference region in the original image data is processed to determine the noise interference confidence symbol of the suspected noise interference region, including: performing convolution operations with the region image data of the suspected noise interference region in the horizontal and vertical directions respectively based on a preset Sobel operator to obtain the gray-level gradient magnitude and gradient direction angle of each pixel in the region image data of the suspected noise interference region; determining the gradient direction histogram of the suspected noise interference region based on the gradient direction histogram of the suspected noise interference region and the gray-level gradient magnitude of each pixel in the region image data of the suspected noise interference region to determine the noise interference confidence symbol of the suspected noise interference region.

[0012] Optionally, the gradient orientation histogram includes multiple directional angle intervals. Based on the gradient orientation histogram of the suspected noise interference region and the gray-level gradient magnitude of each pixel in the regional image data of the suspected noise interference region, a noise interference confidence symbol for the suspected noise interference region is determined, including: using the ratio of the number of targets to the total number of pixels in the regional image data of the suspected noise interference region as the dominant energy proportion of the suspected noise interference region; the number of targets is the number of pixels in the directional angle interval where the highest peak in the gradient orientation histogram of the suspected noise interference region is located; using the average gray-level gradient magnitude of all pixels in the regional image data of the suspected noise interference region as the average gray-level gradient magnitude of the suspected noise interference region; for each suspected noise interference region, determining whether the average gray-level gradient magnitude of the suspected noise interference region is less than a preset gray-level gradient magnitude threshold; determining whether the dominant energy proportion of the suspected noise interference region is greater than a preset energy proportion threshold; if both are true, determining that the noise interference confidence symbol of the suspected noise interference region indicates that there is no noise interference in the suspected noise interference region; otherwise, determining that the noise interference confidence symbol of the suspected noise interference region indicates that there is noise interference in the suspected noise interference region.

[0013] Optionally, defect detection is performed on the hardware parts to be inspected based on the regional roughness index of multiple sub-regions and the noise interference confidence symbol of the suspected noise interference region. This includes: taking the average of the regional roughness indices of multiple sub-regions as the overall roughness index of the surface of the hardware parts to be inspected; taking the product of the overall roughness index and the preset roughness filter coefficient as the reference filter intensity of the Gaussian filter kernel; performing defect detection on the second sub-region among the multiple sub-regions based on the Gaussian filter kernel; the second sub-region includes all sub-regions among the multiple sub-regions except for the suspected noise interference region, and includes the suspected noise interference region that is indicated by the noise interference confidence symbol to be free of noise interference; performing defect detection on the third sub-region among the multiple sub-regions based on the grayscale gradient magnitude of all pixels in the regional image data of the third sub-region among the multiple sub-regions; the third sub-region is the sub-region among the multiple sub-regions except for the second sub-region.

[0014] Optionally, based on the Gaussian filter kernel and the gray-level gradient magnitude of all pixels in the regional image data of the third sub-region among the multiple sub-regions, defect detection is performed on the third sub-region among the multiple sub-regions, including: determining the direction with the largest gray-level gradient change and the direction with the smallest gray-level gradient change based on the gray-level gradient magnitude of all pixels in the regional image data of the third sub-region; determining the diffusion coefficient corresponding to the direction with the largest gray-level gradient change as a first preset value, and determining the diffusion coefficient corresponding to the direction with the smallest gray-level gradient change as a second preset value; the second preset value is greater than the first preset value; and performing defect detection on the third sub-region among the multiple sub-regions based on the Gaussian filter kernel and the diffusion coefficient.

[0015] Secondly, this application discloses a hardware component quality defect detection system based on industrial vision, comprising: an acquisition device and a processing device; the acquisition device is used to acquire original image data of the surface of the hardware component to be inspected; the surface of the hardware component to be inspected is divided into multiple sub-regions; the processing device is used to determine the regional roughness index of each sub-region based on the original image data of the surface of the hardware component to be inspected; the processing device is further used to determine suspected noise interference regions among the multiple sub-regions based on the original image data and the regional roughness index of the multiple sub-regions; the processing device is further used to process the regional image data of the suspected noise interference regions in the original image data based on convolution operation to determine the noise interference confidence symbol of the suspected noise interference regions; the noise interference confidence symbol is used to indicate that there is noise interference in the suspected noise interference regions, or the noise interference confidence symbol is used to indicate that there is no noise interference in the suspected noise interference regions; the processing device is further used to perform defect detection on the hardware component to be inspected based on the regional roughness index of the multiple sub-regions and the noise interference confidence symbol of the suspected noise interference regions.

[0016] Beneficial effects The method and system provided in this application calculate the regional roughness index of each sub-region of a component, identify suspected noise regions by combining multi-scale texture energy distribution, and further determine noise interference confidence symbols using gradient histogram analysis, thus achieving adaptive image processing in the defect detection process. This scheme overcomes the limitations of traditional fixed-parameter filtering, dynamically adjusting the smoothing filtering strategy according to the surface roughness of the component. It effectively suppresses noise interference while protecting the edge information of weak defects (such as fine scratches), greatly reducing the systematic missed detection rate in mixed-flow production mode and significantly improving the accuracy and robustness of industrial vision inspection. Attached Figure Description

[0017] Figure 1 A flowchart illustrating a method for detecting quality defects in hardware accessories based on industrial vision, provided in this application; Figure 2 A flowchart illustrating another method for detecting quality defects in hardware accessories based on industrial vision provided in this application; Figure 3 This application provides a schematic diagram of the architecture of a hardware accessories quality defect detection system based on industrial vision. Detailed Implementation

[0018] The technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. The components of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application. It should be noted that similar reference numerals and letters in the following drawings indicate similar items; therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. Furthermore, in the description of this application, the terms "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0019] like Figure 1 As shown, the technical solution disclosed in this embodiment is as follows: S101. Obtain the original image data of the surface of the hardware accessory to be inspected; the surface of the hardware accessory to be inspected is divided into multiple sub-regions.

[0020] S102. Based on the original image data of the surface of the hardware accessories to be inspected, determine the regional roughness index of each sub-region.

[0021] S103. Based on the original image data and the regional coarseness index of multiple sub-regions, identify the suspected noise interference regions in the multiple sub-regions.

[0022] S104. Based on convolution operation, process the region image data of the suspected noise interference area in the original image data to determine the noise interference confidence symbol of the suspected noise interference area; the noise interference confidence symbol is used to indicate whether there is noise interference in the suspected noise interference area.

[0023] S105. Based on the regional roughness index of multiple sub-regions and the noise interference confidence symbol of suspected noise interference areas, perform defect detection on the hardware parts to be inspected.

[0024] The following will combine Figure 2 The proposed solution will be explained in detail.

[0025] In the overall technical solution described above, the system first acquires a full-view image of the component's surface using a visual acquisition device, and then divides it into multiple small grid-like sub-regions in the spatial domain, using these as the basic units for local feature analysis. The "full-view image" can be a single static image or a valid frame image selected after continuous acquisition as the component passes through the inspection station. To ensure the comparability of subsequent regional roughness indices, it is preferable to acquire the original image data under the same inspection station, the same exposure control strategy, and the same lighting arrangement, so that different batches of components have a consistent imaging basis before entering the analysis process. Subsequently, the system independently evaluates the surface roughness state of each sub-region and, combined with the pixel distribution characteristics of the original image, initially screens out areas that may be contaminated by sensor noise. The reason for performing local roughness state evaluation first, followed by suspected noise screening, is that the same grayscale fluctuation has different physical meanings on rough and smooth surfaces: on rough surfaces, local undulations themselves may bring about strong grayscale changes; while on extremely smooth surfaces, isolated and discontinuous abnormal fluctuations are more likely to originate from sensor noise. To prevent minor scratches from being misidentified as noise, the system further utilizes convolution operations to extract deep features from these suspected areas, generating clear confidence symbols to define the true attributes of the region. Finally, the system integrates local roughness information and noise confirmation results, dynamically adjusting the detection strategy to achieve high-precision defect identification. Specifically, for regions with low roughness indices and noise interference confidence symbols indicating "no noise interference," the system prioritizes preserving their weak edge information to avoid erasing minor scratches; for regions with low roughness indices and noise interference confidence symbols indicating "noise interference," the system prioritizes suppressing discrete outliers; for regions with high roughness indices, the system can combine texture background features to adopt a more robust defect determination method, reducing the possibility of misidentifying normal processing textures as defects.

[0026] Regarding the step of "acquiring the raw image data of the surface of the hardware component to be inspected; the surface of the hardware component to be inspected is divided into multiple sub-regions," in one possible example, an industrial-grade CCD camera deployed directly above the production line can be used to acquire grayscale images of the hardware component surface as raw image data under uniform shadowless light illumination. This industrial-grade CCD camera can be fixedly mounted above the inspection station or installed with a bracket in a position perpendicular to the conveyor direction, as long as it can stably cover the effective inspection area of ​​the hardware component to be inspected. The purpose of the shadowless light source is to minimize the interference of strong reflections, local shadows, and edge occlusion on the grayscale distribution, so that the grayscale changes in the image reflect the true surface condition rather than uneven illumination. To obtain effective images that can be used for subsequent local analysis, the camera focal length, working distance, exposure time, and gain can be calibrated before acquisition to ensure that the surface contours of the component are clear, the texture is not overexposed, and the dark areas are not overcompressed. After acquiring the image, the entire raw image is uniformly cut horizontally and vertically according to the preset pixel size to form multiple non-overlapping rectangular sub-regions, facilitating subsequent fine-grained calculations of local features. The preset pixel size here is not limited to a single fixed value, but can be set according to the surface texture scale of the parts, camera resolution, and target defect size. If the sub-region is too large, it is easy to mix local fine scratches with the surrounding background, weakening the sensitivity of local analysis; if the sub-region is too small, it is easy to cause statistical feature instability due to insufficient pixel count. Therefore, in implementation, several batches of samples can be selected for trial segmentation to compare the differentiation effect of regional roughness index under different sub-region sizes and the stability of subsequent suspected noise screening, and then determine the segmentation method suitable for the current production line. Furthermore, after cutting into multiple sub-regions, the position number of each sub-region in the original image can be recorded, for example, by establishing a region index in row and column order, so as to achieve one-to-one correspondence when identifying suspected noise interference areas, generating noise interference confidence symbols, and outputting defect locations.

[0027] Regarding the step of "determining the regional roughness index of each sub-region based on the original image data of the surface of the hardware accessories to be inspected," in one possible example, the grayscale values ​​of all pixels within a certain sub-region can be directly extracted. First, obviously distorted invalid pixels are removed. Then, the overall dispersion of grayscale values ​​within the sub-region is statistically analyzed to obtain a statistic that reflects the strength of local grayscale fluctuations. This statistic is then processed using a uniform scale and used as the regional roughness index of the sub-region. The "obviously distorted invalid pixels" mentioned here can include abnormal pixels caused by local overexposure, severe shadow occlusion, or momentary interference during acquisition. The purpose of initial removal is to avoid a very small number of outliers excessively affecting the roughness assessment of the entire sub-region. In practice, the grayscale values ​​of all pixels within the sub-region can be read first to obtain the grayscale distribution set of the sub-region. Then, it can be observed whether there are extreme abrupt changes in these grayscale values. If so, they are marked separately as candidate outliers. After marking the candidate outliers, the overall fluctuation of the region is evaluated based on the grayscale distribution of the remaining pixels. If most pixels within a sub-region have similar gray levels and gradual changes, it indicates that the surface of that region is relatively smooth, and its regional roughness index should be low. Conversely, if a sub-region experiences frequent gray level fluctuations and significant alternation between light and dark areas, it indicates that the surface texture of that region is richer or rougher, and its regional roughness index should be higher. The purpose of standardizing this statistic is to make the roughness indices comparable across different images, batches, and sub-regions. For example, the statistics of all sub-regions within the current image can be linearly mapped within the same evaluation range, or a roughness level interval can be established based on pre-collected standard samples, and then the current sub-region can be mapped to the corresponding level. After this processing, the regional roughness index is no longer just an isolated raw statistical value, but becomes a standardized indicator that can directly participate in subsequent threshold judgment and strategy switching.

[0028] Regarding the step of "identifying suspected noise interference areas among multiple sub-regions based on the original image data and the regional roughness index of multiple sub-regions," the following example can be used as a reference: The system traverses all sub-regions, and when a sub-region's regional roughness index is found to be lower than a set smoothness threshold, it is first classified into the smooth surface candidate set. This smoothness threshold can be obtained by pre-collecting sample images of different surface conditions. Specifically, it can be done by collecting samples of relatively smooth blanking parts, samples with normal processing textures, and samples with relatively rough surfaces. These samples are divided into sub-regions in the same way, and the regional roughness index is calculated. Then, the distribution range of the regional roughness index for different categories of samples is observed, and a threshold that can better distinguish smooth and non-smooth regions is selected accordingly. After completing the smooth region screening, the system further checks whether there are abnormal pixel fluctuations in the original image data of these smooth surface candidate sub-regions. Abnormal pixel fluctuations here do not simply refer to high or low grayscale values, but rather to a pixel exhibiting a significantly inconsistent abrupt change compared to its neighboring pixels, and this abrupt change lacks a spatially consistent extension relationship with the surrounding texture. For example, in a smooth sub-region with a gradual overall grayscale transition, if only a few pixels suddenly brighten or darken, and these pixels are scattered and lack continuous edge support, the system can consider them as discrete high-frequency pixels. Furthermore, the system can also perform a neighborhood consistency check, that is, check whether several adjacent pixels around the anomalous pixel also exhibit grayscale changes in the same direction and trend. If the surrounding pixels do not form a continuous transition, but only show single-point or a few scattered abrupt changes, it is more consistent with the characteristics of noise. In this case, the system will mark the sub-region as a suspected noise interference area and proceed to the subsequent review process. This two-level screening method of "first looking at the region's coarseness index, then looking at local abnormal fluctuations" can avoid a large number of false positives for suspected noise areas in coarse regions with complex textures, because high-frequency changes in coarse regions are often part of the actual surface texture and should not be directly included in the noise review.

[0029] Regarding the step of "processing the regional image data of suspected noise interference areas in the original image data based on convolution operations to determine the noise interference confidence symbols of the suspected noise interference areas," in some implementations, the system can construct a convolution kernel to highlight local gray-level abrupt changes and perform a sliding dot product summation operation on the image matrix of the suspected noise interference area using this convolution kernel. The purpose of convolution processing is not simply to enhance edges, but to use the local neighborhood response pattern to determine whether abnormal fluctuations are "random scattered points" or "continuous thin lines." To describe this processing process more clearly and completely, it can be implemented as follows: First, extract the regional image data of the areas marked as suspected noise interference from the original image data, and preserve the positional relationship of the area in the original image; then, perform boundary padding or edge duplication processing on the regional image data to avoid distortion response due to incomplete neighborhood when the convolution kernel slides to the edge position; next, scan the regional image data pixel by pixel using a preset convolution kernel to obtain a response map. Each position in this response map corresponds to the gray-level change intensity and change pattern of a local neighborhood in the original area. If the high response positions in the response graph are scattered and there is no continuous connection between adjacent high response points, it indicates that the abnormal fluctuations in this area are closer to random noise. If the high response positions in the response graph are arranged continuously along a certain direction, forming a thin strip or line structure, it indicates that there are weak edges with spatial continuity in this area, which are more likely to correspond to the boundaries of fine scratches or small indentations.

[0030] Through the above overall technical solution, this application effectively solves the technical problem of missed detection of low-gradient defects caused by fixed filtering parameters in mixed-flow production. Its core logic lies in the fact that the system no longer blindly smooths the entire image globally, but instead, by dividing it into multiple sub-regions and calculating the regional roughness index, it endows the vision system with adaptive perception capabilities of the local physical state of the component surface. Based on this, the system accurately locates suspected noise interference areas and innovatively introduces convolution operations for secondary verification, generating noise interference confidence symbols. This mechanism can keenly capture the weak but continuous gradient changes of minute scratches in local space, thus completely distinguishing them from isolated, random sensor noise. Its working mechanism can be further understood as follows: random noise usually manifests as local bursts, spatial discreteness, and directional disorder, while minute scratches, although exhibiting weak grayscale changes, often possess continuous extension and a relatively stable orientation in space. The regional roughness index first answers the question, "Is this region inherently prone to realistic texture undulations?", while the convolutional verification then answers, "Does the current abnormal fluctuation possess the continuous structure expected of a defect?" This combination of approaches allows the system to avoid simply treating all weak variations as noise in complex mixed-flow scenarios. In the final defect detection stage, based on the confidence symbol, the system selectively preserves low-contrast edge information that has been confirmed as minor scratches, avoiding feature loss caused by indiscriminate filtering. This significantly improves the detection accuracy of low-gradient defects such as minor scratches in mixed-flow inspection scenarios with vastly different surface roughness of various parts. Furthermore, because suspected noise interference areas are screened and verified locally, the system does not need to perform the same level of complex processing on the entire image, thus balancing detection accuracy and online detection efficiency.

[0031] In some preferred embodiments, determining the regional roughness index of each sub-region based on the original image data of the surface of the hardware component to be inspected includes: determining the gray-level co-occurrence matrix of each sub-region based on the original image data of the surface of the hardware component to be inspected; determining the contrast, energy value, and correlation index of the gray-level co-occurrence matrix of each sub-region based on the gray-level co-occurrence matrix of each sub-region; and determining the regional roughness index of each sub-region based on the contrast, energy value, and correlation index of the gray-level co-occurrence matrix of each sub-region.

[0032] This specific implementation scheme introduces a gray-level co-occurrence matrix (GLCM) for texture analysis. In practice, for each sub-region, the system first uniformly organizes the gray levels of that sub-region. If the original gray levels are too dense, direct statistical analysis would result in an overly sparse matrix, which is not conducive to stably reflecting texture relationships. Therefore, the gray values ​​can be compressed into several gray-level intervals before constructing the GLCM using the compressed gray levels. Subsequently, the system sets a spatial relative distance and several specific directional angles. Here, the spatial relative distance describes how far apart two pixels are, and the directional angles describe the relative orientation between these two pixels. Taking a sub-region as an example, if adjacent pixels are selected as the statistical objects, the system will sequentially examine the paired gray-level combinations in the horizontal, vertical, and two diagonal directions, and count the frequency of each gray-level combination in the sub-region. After the statistics are completed, the GLCM of the sub-region in different directions can be obtained. To reduce the influence of randomness in a single direction, the GLCMs in multiple directions can be obtained separately and then merged, or features can be extracted separately and then comprehensively evaluated.

[0033] Subsequently, the system extracts three key secondary statistical features from the matrix: contrast, energy value, and correlation index. Contrast reflects the degree of difference between gray levels. If adjacent pixels within a sub-region frequently exhibit large gray-level jumps, the contrast is usually high, often indicating more pronounced texture undulations in that region. Energy reflects the concentration of gray-level distribution and the uniformity of texture. If the gray-level combinations within a sub-region are relatively concentrated and repetitive, the energy value is usually high, often indicating more regular textures in that region. The correlation index reflects the dependency between adjacent pixel gray levels. If gray-level changes in a certain direction have strong continuity, the correlation index will show obvious spatial correlation characteristics. By observing these three features simultaneously, the system can not only determine "how large the gray-level changes are," but also "whether these changes are regular," "whether they have directionality," and "whether they belong to stable textures." For example, while random noise regions may cause local gray-level jumps, their directionality and spatial dependency are usually weak; whereas machined texture regions often have more stable repetitive structures in a certain direction. Based on this difference, the system can more accurately distinguish between real surface textures and random interference.

[0034] Through this specific implementation scheme, the system utilizes the gray-level co-occurrence matrix (GLCM) to deeply mine the second-order statistical properties of images. The combination of contrast, energy value, and correlation index not only measures the drasticness of local gray-level changes but also accurately captures the uniformity and directional patterns of texture. This multi-dimensional texture feature extraction method can effectively distinguish between random gray-level fluctuations and real surface processing textures, thereby generating a regional roughness index for each sub-region that closely matches its physical reality, providing extremely reliable data support for subsequent accurate noise removal. Furthermore, since the GLCM focuses on the "paired occurrence" relationship between pixels rather than the isolated value of a single pixel, it has a stronger expressive power for subtle but organized texture structures. This also enables the system to maintain a relatively stable roughness state recognition capability even when facing frequent surface state switching in mixed-production processes.

[0035] More specifically, based on the contrast, energy value, and correlation index of the gray-level co-occurrence matrix of each sub-region, the regional roughness index of each sub-region is determined, including: multiplying the contrast of the gray-level co-occurrence matrix of each sub-region by a preset contrast coefficient as the contrast roughness index of each sub-region; multiplying the energy value of the gray-level co-occurrence matrix of each sub-region by a preset energy value coefficient as the energy roughness index of each sub-region; determining the standard deviation of gray values ​​of each sub-region based on the original image data of the surface of the hardware accessory to be inspected; multiplying the standard deviation of gray values ​​of each sub-region by a preset gray value coefficient as the gray roughness index of each sub-region; and taking the average of the contrast roughness index, energy roughness index, and gray roughness index of each sub-region as the regional roughness index of each sub-region.

[0036] This specific implementation plan provides a multi-feature fusion roughness index calculation model. In practice, the system pre-sets preset contrast coefficients, preset energy coefficients, and preset grayscale coefficients in the configuration file. These "presets" are not arbitrarily specified but obtained through sample calibration. Specifically, they can be established as follows: First, prepare several sets of representative hardware component sample images, covering different states such as smooth fine-stamped surfaces, conventionally processed textured surfaces, and relatively rough surfaces; then, divide these sample images into sub-regions and extract the contrast, energy, and grayscale standard deviations respectively; subsequently, observe the contribution of each feature to the roughness differentiation under different surface states, and gradually adjust the three coefficients so that the final regional roughness index can stably distinguish different surface states. If, during the verification process, a certain feature is found to have a more significant effect on distinguishing smooth and rough areas, its corresponding coefficient can be appropriately increased; if a certain feature is significantly affected by lighting fluctuations, its corresponding coefficient can be appropriately decreased. After multiple batches of sample verification, the determined coefficients are written into the configuration file as preset coefficients used during production line operation.

[0037] In actual calculations, the system first multiplies the extracted gray-level co-occurrence matrix contrast with a preset contrast coefficient to obtain a scale-uniform contrast coarsening index. Similarly, it multiplies the energy value with a preset energy value coefficient to obtain the energy value coarsening index. Simultaneously, the system reverts to the original image data, calculates the standard deviation of the gray-level values ​​of all effective pixels within the sub-region, and uses this to characterize the absolute gray-level dispersion of the region. This standard deviation is then multiplied with a preset gray-level coefficient to obtain the gray-level coarsening index. The reason for introducing the gray-level standard deviation in addition to the gray-level co-occurrence matrix features is that the former is better at describing the structural relationships between adjacent pixels, while the latter more directly reflects the dispersion of the overall brightness and darkness distribution of the region. Combining the two can simultaneously take into account both "texture structure information" and "absolute gray-level fluctuation information." Finally, the system integrates the calculated contrast coarsening index, energy value coarsening index, and gray-level coarsening index, and uses the average of the three as the final output region coarsening index. The advantage of using the average method is that it avoids excessive influence on the final result when a single feature is abnormally high or low, maintaining a good balance and stability in the region coarsening index.

[0038] Furthermore, during implementation, a validity check mechanism can be set for the three roughness index components. For example, when a sub-region experiences an abnormal increase in grayscale standard difference due to localized reflection, but the grayscale co-occurrence matrix features do not show corresponding texture enhancement, the system can mark this sub-region as a region requiring review, avoiding misinterpreting occasional lighting anomalies as a sudden change in surface roughness. As another example, when both the contrast roughness index and the grayscale roughness index are low, while the energy roughness index is high, it often indicates that the grayscale distribution in this region is relatively concentrated and the texture is more regular, more closely resembling the appearance of a smooth or regularly processed surface; conversely, if both the contrast roughness index and the grayscale roughness index increase simultaneously, it is more likely to correspond to regions with significant texture undulations or a rougher surface condition. Through this cross-verification between components, the interpretability of the regional roughness index will be stronger, facilitating consistency in the subsequent screening logic for suspected noise interference regions.

[0039] Through this specific implementation scheme, the system cleverly integrates the co-occurrence matrix features reflecting the spatial relative texture structure with the statistical features reflecting the absolute photometric distribution. By introducing preset coefficients for multiplication, not only is scale unification achieved among different features, balancing the role of each feature in the final evaluation, but the robustness of the algorithm to changes in industrial lighting conditions is also enhanced. The regional roughness index, obtained by calculating the average value, can stably and comprehensively characterize the true microscopic morphology of the hardware component surface, ensuring that in multi-variety mixed-flow production, regardless of changes in the surface state of the components, the system can output an accurate roughness evaluation benchmark. Furthermore, because the regional roughness index is based on multi-feature fusion, the subsequent screening of suspected noise interference areas no longer relies on a single gray-level fluctuation phenomenon, but is based on the premise that "the local surface state has been reliably identified." Therefore, it can reduce false screening and missed screening from the source, providing support for the stability of the final defect detection results.

[0040] In some preferred embodiments, determining suspected noise interference regions among multiple sub-regions based on the original image data and the regional coarseness index of multiple sub-regions includes: performing a multi-scale two-dimensional discrete wavelet transform on the original image data to obtain a horizontal high-frequency sub-band, a vertical high-frequency sub-band, and a diagonal high-frequency sub-band; using the absolute values ​​of the wavelet coefficients of each sub-region in the horizontal high-frequency sub-band as the horizontal high-frequency coefficients of each sub-region; using the absolute values ​​of the wavelet coefficients of each sub-region in the vertical high-frequency sub-band as the vertical high-frequency coefficients of each sub-region; using the absolute values ​​of the wavelet coefficients of each sub-region in the diagonal high-frequency sub-band as the diagonal high-frequency coefficients of each sub-region; using the sum of the horizontal high-frequency coefficients, vertical high-frequency coefficients, and diagonal high-frequency coefficients of each sub-region as the texture energy distribution measure of each sub-region; and determining suspected noise interference regions among multiple sub-regions based on the texture energy distribution measures of multiple sub-regions and the regional coarseness index of multiple sub-regions.

[0041] This specific implementation scheme introduces multi-scale two-dimensional discrete wavelet transform (DFT) technology. DFT can decompose image signals into frequency components of different scales and directions. The low-frequency sub-band reflects the overall outline and background of the image, while the high-frequency sub-band concentrates on reflecting details such as edges, textures, and noise. For ease of understanding, the original image can be viewed as composed of "overall slowly changing information" and "locally rapidly changing information." The former mainly corresponds to the approximate shape, brightness distribution, and background transition of the components, while the latter mainly corresponds to edges, fine lines, grain disturbances, and random noise. Specifically, the horizontal high-frequency sub-band mainly captures edges that change vertically (i.e., horizontal textures), the vertical high-frequency sub-band mainly captures edges that change horizontally, and the diagonal high-frequency sub-band captures details that change diagonally. Since the textures or scratches of real hardware components usually have a certain directionality, their energy is often concentrated in one or two specific high-frequency sub-bands; while random noise is isotropic, and its energy is relatively evenly distributed and prevalent in the horizontal, vertical, and diagonal high-frequency sub-bands. For example, when there is a thin, elongated scratch on the surface of a component that extends approximately horizontally, the high-frequency information corresponding to the scratch is more likely to stand out in the direction subband that is vertically related to it; however, if the anomaly in the image is only due to random jumps in the sensor, then there will often be scattered and dispersed responses in the three direction subbands, without forming a clear single-direction cluster.

[0042] In practice, the system first acquires the raw image data. Then, the system selects a suitable wavelet basis function and performs a two-dimensional discrete wavelet transform on the raw image data. The wavelet basis function can be predetermined through sample experiments based on the texture characteristics of the surface to be inspected. For example, from several candidate wavelet basis functions, one that can more stably distinguish between "fine directional texture" and "random noise response" can be selected as the preset wavelet basis function. This "preset" is not arbitrarily specified but can be obtained through historical samples: multiple batches of raw image data containing normal surfaces, surfaces with minor scratches, surfaces with dust interference, and surfaces with thermal noise interference are collected. Different candidate wavelet basis functions are transformed separately, and then the separation effect of the high-frequency sub-bands under each candidate wavelet basis function on real scratches and random noise is compared. The one with the highest screening accuracy is selected and recorded as the system's default wavelet basis function. To obtain richer detailed information, multi-scale decomposition can be performed to extract high-frequency sub-bands at specific levels. If the surface defects of the parts are small in scale, the shallower decomposition results are prioritized; if the surface has fine lines or fluctuations of a slightly larger range, multiple levels of high-frequency sub-bands can also be used in combination for analysis.

[0043] Subsequently, for each predefined sub-region, the system extracts wavelet coefficients from its horizontal, vertical, and diagonal high-frequency sub-bands. These "sub-regions" can maintain a one-to-one correspondence with the sub-regions used to calculate the regional roughness index, meaning they use the same spatial segmentation method to directly correlate the frequency domain analysis results with the regional roughness index. Since wavelet coefficients can be positive or negative, the system takes the absolute values ​​of these coefficients to measure energy levels, obtaining the horizontal, vertical, and diagonal high-frequency coefficients. Absolute values ​​are used because the sign of the coefficients primarily reflects the direction of local grayscale changes, while the noise filtering stage focuses more on the intensity of the change itself, rather than the direction of the transition between light and dark. Next, the high-frequency coefficients in these three directions are summed to obtain the texture energy distribution metric for the sub-region. This metric comprehensively reflects the total energy of the sub-region across all high-frequency directions. If the texture energy distribution metric of a sub-region is abnormally high, and its regional roughness index indicates that the region should be smooth, then this high-frequency energy is highly likely to originate from random noise or isolated dust interference.

[0044] The working principle of this specific implementation scheme is to transform the image from the spatial domain to the time-frequency domain through wavelet transform. Utilizing the high sensitivity of high-frequency subbands to details and noise, a texture energy distribution metric reflecting the local high-frequency energy distribution is extracted. Combined with the previously calculated regional roughness index, the system can establish a dual "spatial domain-frequency domain" verification mechanism. The logic can be further explained as follows: the regional roughness index answers whether the surface of the region should appear relatively smooth, while the texture energy distribution metric answers whether the region exhibits abnormal activity in high-frequency details. Only when both "smoothness" and "high-frequency abnormality" are satisfied simultaneously does it better match the typical behavior of a noise interference region. In hardware component inspection scenarios, when faced with electromagnetic interference or sensor thermal noise, this scheme can effectively identify regions that appear smooth in the spatial domain but exhibit abnormal high-frequency energy in the frequency domain, accurately pinpointing them as suspected noise interference regions. This screening method combining frequency domain energy distribution overcomes the defect of easily misjudging subtle textures as noise by single spatial domain statistical features, significantly improving the accuracy and robustness of suspected noise region localization, and providing high-quality candidate targets for subsequent convolution verification. Furthermore, since random noise typically lacks a stable spatial structure, its high-frequency response often manifests as simultaneous occurrence in multiple directions and discrete distribution. Therefore, this scheme not only helps to identify noise regions but also helps to distinguish between real fine lines and scratches with continuous orientations and disordered disturbances.

[0045] In a preferred embodiment of this application, determining suspected noise interference regions among multiple sub-regions based on texture energy distribution measurements and regional roughness indices of multiple sub-regions includes: obtaining the detection accuracy index of the hardware accessory to be inspected; using the sum of the upper limit adjustment step and the upper limit value of a preset roughness index range as the upper limit value of the target roughness index range, and using the difference between the lower limit value of the preset roughness index range and the lower limit adjustment step as the lower limit value of the target roughness index range; the upper limit adjustment step is the product of the detection accuracy index and the upper limit value of the preset roughness index range, and the lower limit adjustment step is the product of the detection accuracy index and the lower limit value of the preset roughness index range; designating sub-regions among the multiple sub-regions whose regional roughness indices fall within the target roughness index range as first sub-regions; and designating sub-regions among the first sub-regions whose texture energy distribution measurements fall within a preset energy distribution measurement range as suspected noise interference regions.

[0046] This specific implementation plan introduces a detection accuracy index to dynamically adjust the judgment range of the roughness index. The detection accuracy index is a quantitative indicator reflecting the stringency of current component quality requirements, and it can be automatically obtained by reading work order information issued by the production management system or scanning the identification code on the component.

[0047] To clarify the acquisition method, the following implementation path can be adopted: When the production management system issues a work order, in addition to basic information such as product model, batch number, and workstation number, it also simultaneously issues the corresponding inspection level for that model. After receiving the inspection level, the system obtains the inspection accuracy index of the part to be inspected based on a pre-established correspondence table of level and inspection accuracy index. If an identification code method is used, a QR code or barcode can be set on the part tray, accompanying label, or tooling fixture. After the workstation scanning device reads the identification information, it queries the corresponding quality level from the local database or server database and then converts it to obtain the inspection accuracy index. The preset roughness index range is a benchmark range used to define "surfaces that are relatively smooth and susceptible to noise interference," derived by the system through statistical analysis of a large amount of historical data under standard inspection mode. This "preset" can also be obtained through a specific data establishment process: First, collect several batches of images of normal hardware parts, noise-interference sample images, and sample images containing micro-defects. Calculate the regional roughness index of each sub-region according to a predetermined block division method. Then, manually verify which regions are indeed "relatively smooth and easily affected by noise." Summarize the regional roughness indices corresponding to these regions to form a statistical distribution. Based on this, select a benchmark interval that can better cover such regions and record this interval as the preset roughness index range. By multiplying the detection accuracy index by the upper and lower limits of the benchmark interval respectively, calculate the upper limit adjustment step size and the lower limit adjustment step size. Then, dynamically expand and shrink the benchmark interval to obtain the target roughness index range.

[0048] The working principle of this specific implementation scheme lies in establishing a dynamic threshold adjustment mechanism based on the detection accuracy index. By calculating and adjusting the step size, the system can adaptively expand or shrink the judgment boundary of the roughness index according to the quality requirements of different parts, thereby dynamically generating the target roughness index range. This mechanism enables the system to flexibly switch detection scales when facing multi-product mixed production. In practical applications, this scheme effectively solves the problem of "missed detection of high-precision parts and false alarms of low-precision parts" caused by fixed thresholds. The reason is that fixed thresholds can only adapt to a single quality requirement, while dynamic thresholds can keep the coverage of "candidate suspected noise areas" consistent with the requirements of the current work order: when the detection accuracy requirement is higher, the system first expands the candidate range, and then continues to screen through texture energy distribution measurement, thereby retaining more areas that may contain weak anomalies; when the detection accuracy requirement is lower, the system shrinks the candidate range, reducing excessive attention to normal fluctuation areas. By combining the dynamically adjusted roughness index range with the frequency domain texture energy distribution measurement, the system achieves accurate and flexible screening of suspected noise interference areas. This ensures both the rigorous testing of high-standard parts and the testing efficiency of ordinary parts, greatly improving the adaptability and intelligence of industrial vision systems in complex production environments.

[0049] Optionally, based on convolution operations, the region image data of the suspected noise interference region in the original image data is processed to determine the noise interference confidence symbol of the suspected noise interference region, including: performing convolution operations with the region image data of the suspected noise interference region in the horizontal and vertical directions respectively based on a preset Sobel operator to obtain the gray-level gradient magnitude and gradient direction angle of each pixel in the region image data of the suspected noise interference region; determining the gradient direction histogram of the suspected noise interference region based on the gradient direction histogram of the suspected noise interference region and the gray-level gradient magnitude of each pixel in the region image data of the suspected noise interference region to determine the noise interference confidence symbol of the suspected noise interference region.

[0050] This specific implementation scheme employs a pre-defined Sobel operator for local gradient feature extraction. The Sobel operator is a discrete difference operator that combines Gaussian smoothing and differential differentiation, effectively suppressing some high-frequency random noise while extracting edge gradients. The Sobel operator was chosen because it is sensitive to subtle edge changes without over-amplifying isolated noise points as easily as some overly simplistic difference methods. By performing convolution operations in both the horizontal and vertical directions, the system can obtain the degree of grayscale change (i.e., grayscale gradient magnitude) and the direction of the fastest grayscale change (i.e., gradient direction angle) for each pixel in two-dimensional space. The gradient direction histogram is a statistical tool used to classify and statistically analyze the gradient direction angles of all pixels within a region according to a certain angle range, thus intuitively reflecting the main direction and distribution pattern of edge gradients within that region. The "preset Sobel operator" here can directly use the standard horizontal Sobel convolution kernel and the standard vertical Sobel convolution kernel commonly used in image processing. Alternatively, without changing the basic gradient extraction idea, the boundary processing method before and after the application of the convolution kernel can be preset according to the imaging resolution and noise level. For example, it can be specified to uniformly process the boundary by using mirror filling, edge copying, or ignoring the outermost pixels, so as to ensure that the gradient extraction results between different regions are comparable.

[0051] The working principle of this specific implementation scheme lies in using the Sobel operator to transform the grayscale information of an image into gradient magnitude and direction information, and then using a gradient direction histogram to macroscopically and statistically represent the microscopic pixel-level directional features. Even with slight grayscale changes, genuine minute scratches exhibit a high degree of consistency in the gradient direction of their edge pixels, forming significant peaks in the gradient direction histogram. In contrast, the gradient directions of random noise are chaotic, appearing uniformly distributed with no clear dominant direction in the histogram. In hardware component inspection scenarios, this scheme, by deeply mining the gradient direction distribution patterns within suspected noise areas, can keenly capture those weak continuous structures masked by noise. This verification mechanism based on gradient direction statistics completely overcomes the limitations of solely relying on grayscale intensity, providing a reliable quantitative basis for accurately distinguishing random noise from minute defects, and ensuring the accuracy and scientific validity of the noise interference confidence symbol. Furthermore, the gradient magnitude and direction after Sobel convolution are jointly determined by the local neighborhood. Therefore, it does not only look at a single isolated pixel, but examines whether a stable transition relationship is formed between the pixel and its surrounding pixels. This is the key to distinguishing between "continuous defect structure" and "random noise jump".

[0052] In practical applications, the gradient orientation histogram includes multiple directional angle intervals. Based on the gradient orientation histogram of the suspected noise interference region and the gray-level gradient magnitude of each pixel in the regional image data of the suspected noise interference region, a noise interference confidence symbol for the suspected noise interference region is determined. This includes: using the ratio of the number of targets to the total number of pixels in the regional image data of the suspected noise interference region as the dominant energy proportion of the suspected noise interference region; the number of targets being the number of pixels within the directional angle interval where the highest peak in the gradient orientation histogram of the suspected noise interference region is located; using the average gray-level gradient magnitude of all pixels in the regional image data of the suspected noise interference region as the average gray-level gradient magnitude of the suspected noise interference region; for each suspected noise interference region, determining whether the average gray-level gradient magnitude of the suspected noise interference region is less than a preset gray-level gradient magnitude threshold; determining whether the dominant energy proportion of the suspected noise interference region is greater than a preset energy proportion threshold; if both are true, the noise interference confidence symbol for the suspected noise interference region indicates that there is no noise interference in the suspected noise interference region; otherwise, the noise interference confidence symbol for the suspected noise interference region indicates that there is noise interference in the suspected noise interference region.

[0053] This specific implementation plan defines two key quantitative indicators: dominant energy percentage and average grayscale gradient magnitude. Dominant energy percentage measures the concentration of gradient directions within a region. The system finds the angle interval (i.e., the highest peak) containing the most pixels in the gradient direction histogram and uses the corresponding number of pixels as the target number. Dividing the target number by the total number of pixels in the region yields the dominant energy percentage. A higher percentage indicates that grayscale changes within the region tend to extend along a specific direction, which is a typical characteristic of linear defects such as scratches. Average grayscale gradient magnitude measures the severity of overall grayscale changes within the region. Preset grayscale gradient magnitude thresholds and preset energy percentage thresholds are pre-defined judgment benchmarks that can be obtained through statistical learning on a large number of known samples. To more fully explain the source of the "preset" thresholds, the following method can be used: Collect multiple sets of samples from suspected noise interference areas whose categories have been manually confirmed, including areas of real random noise, dust interference, minor scratches, and normal light textures; extract the dominant energy percentage and average grayscale gradient amplitude for each sample; then observe the distribution differences of different categories of samples on these two indicators based on the manual annotation results, select two boundary values ​​that can better distinguish between "random noise" and "real minor defects," and write them into the system parameter table to form the preset grayscale gradient amplitude threshold and preset energy percentage threshold. If the production line subsequently changes the light source, camera, or inspection object, these two thresholds can be resampled and updated to maintain stable judgment results.

[0054] The working principle of this specific implementation scheme lies in constructing a two-dimensional logical judgment model based on "intensity + directional concentration". By requiring the average gray-level gradient amplitude to be less than a threshold, the system excludes obvious high-contrast textures or strong interference; by requiring the dominant energy ratio to be greater than a threshold, the system accurately identifies weak continuous structures with high directional consistency. In the mixed-production scenario of hardware accessories, this rigorous joint judgment mechanism can extremely accurately identify hairline scratches with extremely low contrast on extremely smooth surfaces, which are easily mistaken for noise. Its technical effect can be further deduced and explained as follows: Although random noise may also manifest as local weak changes, due to the lack of a continuous extension direction, its pixel gradient direction usually does not occupy a significant advantage in a single directional range, thus making it difficult to meet the dominant energy ratio condition; while fine scratches, although having a small overall change amplitude, have edges that continuously extend along the length direction, causing a considerable portion of pixels in the area to produce approximately consistent gradient directions, thus making it easier to simultaneously satisfy the two conditions of "low average gray-level gradient amplitude" and "high dominant energy ratio". This scheme not only gives the noise interference confidence symbol a clear physical meaning and quantitative basis, but also completely opens up the logical closed loop from suspected screening to final qualitative analysis, minimizing the possibility of low-gradient defect edges being mistakenly filtered out in subsequent filtering stages, and providing a decisive technical guarantee for achieving high-precision industrial visual defect detection.

[0055] In a preferred embodiment of this application, defect detection of the hardware component to be inspected is performed based on the regional roughness index of multiple sub-regions and the noise interference confidence symbol of the suspected noise interference region. This includes: using the average regional roughness index of the multiple sub-regions as the overall roughness index of the surface of the hardware component to be inspected; using the product of the overall roughness index and a preset roughness filter coefficient as the baseline filtering intensity of the Gaussian filter kernel; performing defect detection on a second sub-region among the multiple sub-regions based on the Gaussian filter kernel; the second sub-region includes all sub-regions among the multiple sub-regions except for the suspected noise interference region, and includes the suspected noise interference region whose noise interference confidence symbol indicates that the suspected noise interference region does not have noise interference; and performing defect detection on a third sub-region among the multiple sub-regions based on the Gaussian filter kernel and the grayscale gradient magnitude of all pixels in the regional image data of a third sub-region among the multiple sub-regions; the third sub-region is the sub-region among the multiple sub-regions excluding the second sub-region.

[0056] This specific implementation scheme establishes an adaptive defect detection strategy based on a combination of macroscopic surface conditions and microscopic local attributes. In practice, the system first sums and averages the regional roughness indices of all sub-regions calculated earlier to obtain the overall roughness index. This overall roughness index macroscopically reflects the average physical texture state of the surface of the hardware component to be inspected. Subsequently, the system multiplies this overall roughness index by a preset roughness filter coefficient to calculate the baseline filter strength of the Gaussian filter kernel. This baseline filter strength typically corresponds to the standard deviation parameter of the Gaussian function, which determines the basic strength of the smoothing process. The preset roughness filter coefficient can be obtained through calibration tests on historical samples to ensure that the calculated baseline filter strength can just enough to smooth out background fluctuations caused by normal processing textures without excessively blurring the image. In this way, when a component with a rough surface flows through the inspection station, the system automatically generates a larger baseline filter strength to suppress strong background textures; when a finely stamped part with an extremely smooth surface flows through, the system generates a smaller baseline filter strength, thus laying the foundation for preserving minor scratches.

[0057] After determining the baseline filter strength, the system classifies all sub-regions based on the noise interference confidence symbols generated earlier. The system divides all sub-regions into second and third sub-regions. The second sub-region includes regular sub-regions not initially screened as suspected noise, and sub-regions that, although initially suspected of noise, were confirmed as genuine weak defects after convolution verification (i.e., the noise interference confidence symbol indicates no noise interference). For the second sub-region, the system directly uses a Gaussian filter kernel with the calculated baseline filter strength for image smoothing, and then applies conventional edge extraction or threshold segmentation algorithms to complete defect detection. Since the baseline filter strength has adapted to the overall surface smoothness, and there is no confirmed random noise in these regions, direct filtering can smooth the normal background while perfectly preserving the weak edges confirmed as genuine defects. The third sub-region consists of sub-regions that, after rigorous verification, are clearly determined to have random noise interference. For such areas, simply using the baseline filter strength may not be enough to completely remove stubborn noise points. Therefore, the system needs to combine the grayscale gradient magnitude of the pixels in the area and introduce a more targeted special filtering mechanism for defect detection.

[0058] The working principle of this specific implementation scheme lies in breaking away from the traditional "one-size-fits-all" filtering mode in industrial visual inspection. By dynamically adjusting the baseline filter intensity through the overall roughness index, macroscopic adaptation to the surface conditions of different batches of parts is achieved. By dividing the sub-region into second and third sub-regions, microscopic differentiation processing of real defects and random noise is achieved. This macro-micro combined strategy ensures that areas identified as minor scratches are not subjected to excessive smoothing, thereby effectively protecting the edge information of low-gradient defects and significantly reducing the false negative rate.

[0059] To address the special processing of the aforementioned third sub-region, and in order to powerfully remove confirmed noise while minimizing disruption of any potential subtle texture patterns, this application further proposes a method for defect detection in the third sub-region among multiple sub-regions. This method is based on a Gaussian filter kernel and the gray-level gradient magnitude of all pixels in the regional image data of the third sub-region within multiple sub-regions. Specifically, this includes: determining the direction of the largest gray-level gradient change and the direction of the smallest gray-level gradient change based on the gray-level gradient magnitude of all pixels in the regional image data of the third sub-region; determining the diffusion coefficient corresponding to the direction of the largest gray-level gradient change as a first preset value, and determining the diffusion coefficient corresponding to the direction of the smallest gray-level gradient change as a second preset value; the second preset value being greater than the first preset value; and performing defect detection in the third sub-region among multiple sub-regions based on the Gaussian filter kernel and the diffusion coefficient.

[0060] This specific implementation introduces an anisotropic diffusion filtering mechanism based on gradient direction. For the third sub-region identified as having noise interference, the system no longer uses isotropic standard Gaussian filtering, but dynamically adjusts the smoothing intensity in different directions according to the gray-level gradient magnitude distribution of local pixels. In practice, the system first analyzes the gray-level gradient magnitude of all pixels in the third sub-region, and uses mathematical tools such as structure tensors or Hessian matrices to calculate the direction of the most drastic local gray-level change (i.e., the direction of the largest gray-level gradient change, usually perpendicular to the potential edge or texture direction) and the direction of the most gradual gray-level change (i.e., the direction of the smallest gray-level gradient change, usually parallel to the potential edge or texture direction).

[0061] Subsequently, the system assigns different diffusion coefficients to the two orthogonal directions. The diffusion coefficient determines the degree of information diffusion (i.e., smoothing) in that direction. The system sets the diffusion coefficient corresponding to the direction with the largest change in gray-level gradient to a smaller first preset value, and the diffusion coefficient corresponding to the direction with the smallest change in gray-level gradient to a larger second preset value. The first and second preset values ​​can be pre-programmed into the system configuration through experimental calibration. Next, the system combines the Gaussian filter kernel determined above with these two diffusion coefficients to construct a direction-selective elliptic filter kernel or anisotropic diffusion equation, and uses this to filter the third sub-region. Finally, it performs defect feature extraction and judgment.

[0062] The working principle of this specific implementation scheme lies in using gradient direction to guide the filtering process, achieving intelligent processing of "strong smoothing along the edge and weak smoothing perpendicular to the edge." In the direction with the smallest gray-level gradient change (i.e., along the texture direction), a larger second preset value is used for strong smoothing, effectively smoothing out random noise points scattered in that direction. Conversely, in the direction with the largest gray-level gradient change (i.e., across the edge), a smaller first preset value is used to limit the smoothing intensity, thus preventing edge blurring. This anisotropic processing method allows the system to thoroughly remove confirmed random noise in the third sub-region while maximally protecting any remaining real structural boundaries within that region. This avoids local image distortion caused by conventional strong filtering, providing a high-quality image foundation for the final high-precision defect detection results.

[0063] like Figure 3 As shown, this application also proposes a hardware accessory quality defect detection system based on industrial vision, including: an acquisition device and a processing device; the acquisition device is used to acquire original image data of the surface of the hardware accessory to be inspected; the surface of the hardware accessory to be inspected is divided into multiple sub-regions; the processing device is used to determine the regional roughness index of each sub-region based on the original image data of the surface of the hardware accessory to be inspected; the processing device is also used to determine suspected noise interference regions among the multiple sub-regions based on the original image data and the regional roughness index of the multiple sub-regions; the processing device is also used to process the regional image data of the suspected noise interference regions in the original image data based on convolution operation to determine the noise interference confidence symbol of the suspected noise interference regions; the noise interference confidence symbol is used to indicate that there is noise interference in the suspected noise interference regions, or the noise interference confidence symbol is used to indicate that there is no noise interference in the suspected noise interference regions; the processing device is also used to perform defect detection on the hardware accessory to be inspected based on the regional roughness index of the multiple sub-regions and the noise interference confidence symbol of the suspected noise interference regions.

[0064] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.

Claims

1. A method for detecting quality defects in hardware accessories based on industrial vision, characterized in that, Includes the following steps: Acquire raw image data of the surface of the hardware component to be inspected; the surface of the hardware component to be inspected is divided into multiple sub-regions; Based on the original image data of the surface of the hardware accessories to be inspected, the regional roughness index of each sub-region is determined; Based on the original image data and the regional coarseness index of the multiple sub-regions, the suspected noise interference regions in the multiple sub-regions are determined; Based on convolution operations, the regional image data of suspected noise interference areas in the original image data are processed to determine the noise interference confidence symbols of the suspected noise interference areas; The noise interference confidence symbol is used to indicate whether noise interference exists in a suspected noise interference area; Based on the regional roughness index of the multiple sub-regions and the noise interference confidence symbol of the suspected noise interference region, defect detection is performed on the hardware parts to be inspected.

2. The method for detecting quality defects in hardware accessories based on industrial vision according to claim 1, characterized in that, Based on the original image data of the surface of the hardware fittings to be inspected, the regional roughness index of each sub-region is determined, including: Based on the original image data of the surface of the hardware accessories to be inspected, determine the gray-level co-occurrence matrix of each sub-region; The contrast, energy value, and correlation index of the gray-level co-occurrence matrix of each sub-region are determined based on the gray-level co-occurrence matrix of each sub-region. The regional roughness index of each sub-region is determined based on the contrast, energy value, and correlation index of the gray-level co-occurrence matrix of each sub-region.

3. The method for detecting quality defects in hardware accessories based on industrial vision according to claim 2, characterized in that, Based on the contrast, energy value, and correlation index of the gray-level co-occurrence matrix of each sub-region, the regional coarsening index of each sub-region is determined, including: The product of the contrast of the gray-level co-occurrence matrix of each sub-region and the preset contrast coefficient is used as the contrast coarsening index of each sub-region. The product of the energy value of the gray-level co-occurrence matrix of each sub-region and the preset energy value coefficient is used as the energy value coarsening index of each sub-region. Based on the original image data of the surface of the hardware accessories to be inspected, determine the standard deviation of the grayscale value of each sub-region; The product of the standard deviation of the gray value of each sub-region and the preset gray value coefficient is used as the gray value roughness index of each sub-region. The average of the contrast roughness index, energy value roughness index, and grayscale value roughness index of each sub-region is used as the region roughness index of each sub-region.

4. The method for detecting quality defects in hardware accessories based on industrial vision according to claim 1, characterized in that, Based on the original image data and the regional coarsening index of the multiple sub-regions, suspected noise interference regions are identified among the multiple sub-regions, including: Multi-scale two-dimensional discrete wavelet transform is performed on the original image data to obtain horizontal high-frequency sub-bands, vertical high-frequency sub-bands, and diagonal high-frequency sub-bands. The absolute value of the wavelet coefficients of each sub-region in the horizontal high-frequency sub-band is taken as the horizontal high-frequency coefficient of each sub-region. The absolute value of the wavelet coefficients of each sub-region in the vertical high-frequency sub-band is taken as the vertical high-frequency coefficient of each sub-region. The absolute values ​​of the wavelet coefficients of each sub-region in the diagonal high-frequency sub-band are used as the diagonal high-frequency coefficients of each sub-region. The sum of the horizontal high-frequency coefficient, vertical high-frequency coefficient, and diagonal high-frequency coefficient of each sub-region is used as a measure of the texture energy distribution of each sub-region. Based on the texture energy distribution metric of the multiple sub-regions and the regional roughness index of the multiple sub-regions, suspected noise interference regions are identified among the multiple sub-regions.

5. The method for detecting quality defects in hardware accessories based on industrial vision according to claim 4, characterized in that, Based on the texture energy distribution metric and the regional coarseness index of the multiple sub-regions, suspected noise interference regions are identified among the multiple sub-regions, including: Obtain the inspection accuracy index of the hardware parts to be inspected; The upper limit adjustment step size is the sum of the upper limit value and the upper limit value of the preset roughness index range as the upper limit value of the target roughness index range, and the difference between the lower limit value of the preset roughness index range and the lower limit adjustment step size is the lower limit value of the target roughness index range; the upper limit adjustment step size is the product of the detection accuracy index and the upper limit value of the preset roughness index range, and the lower limit adjustment step size is the product of the detection accuracy index and the lower limit value of the preset roughness index range. The sub-region whose regional roughness index falls within the range of the target roughness index among the plurality of sub-regions is designated as the first sub-region. Sub-regions whose texture energy distribution measurement falls within a preset energy distribution measurement range within the first sub-region are designated as suspected noise interference regions.

6. The method for detecting quality defects in hardware accessories based on industrial vision according to claim 1, characterized in that, Based on convolution operations, the region image data of suspected noise interference areas in the original image data are processed to determine the noise interference confidence symbols of the suspected noise interference areas, including: Based on the preset Sobel operator, convolution operations are performed with the regional image data of the suspected noise interference area in the horizontal and vertical directions respectively to obtain the gray-level gradient magnitude and gradient direction angle of each pixel in the regional image data of the suspected noise interference area. Based on the gradient direction angles of all pixels in the regional image data of the suspected noise interference area, determine the gradient direction histogram of the suspected noise interference area. Based on the gradient direction histogram of the suspected noise interference region and the gray-level gradient magnitude of each pixel in the regional image data of the suspected noise interference region, the noise interference confidence symbol of the suspected noise interference region is determined.

7. The method for detecting quality defects in hardware accessories based on industrial vision according to claim 6, characterized in that, The gradient orientation histogram includes multiple directional angle intervals. Based on the gradient orientation histogram of the suspected noise interference region and the gray-level gradient magnitude of each pixel in the regional image data of the suspected noise interference region, noise interference confidence symbols for the suspected noise interference region are determined, including: The ratio of the number of targets to the total number of pixels in the regional image data of the suspected noise interference area is taken as the dominant energy proportion of the suspected noise interference area; the number of targets is the number of pixels in the direction angle interval where the highest peak of the gradient direction histogram of the suspected noise interference area is located. The average gray-level gradient magnitude of all pixels in the image data of the suspected noise interference area is taken as the average gray-level gradient magnitude of the suspected noise interference area. For each suspected noise interference area, determine whether the average gray-level gradient amplitude of the suspected noise interference area is less than the preset gray-level gradient amplitude threshold. Determine whether the dominant energy percentage of the suspected noise interference area is greater than a preset energy percentage threshold; If both are true, the noise interference confidence symbol for the suspected noise interference area indicates that there is no noise interference in the suspected noise interference area; otherwise, the noise interference confidence symbol for the suspected noise interference area indicates that there is noise interference in the suspected noise interference area.

8. The method for detecting quality defects in hardware accessories based on industrial vision according to claim 1, characterized in that, Based on the regional roughness index of the multiple sub-regions and the noise interference confidence symbols of the suspected noise interference regions, defect detection is performed on the hardware parts to be inspected, including: The average roughness index of the multiple sub-regions is taken as the overall roughness index of the surface of the hardware accessory to be tested. The product of the overall coarsening index and the preset coarsening filter coefficient is used as the benchmark filtering strength of the Gaussian filter kernel. Defect detection is performed on the second sub-region of the plurality of sub-regions based on the Gaussian filter kernel; the second sub-region includes all sub-regions of the plurality of sub-regions except for the suspected noise interference region, and includes the suspected noise interference region that includes the noise interference confidence symbol indicating that the suspected noise interference region does not have noise interference; Based on the Gaussian filter kernel and the grayscale gradient magnitude of all pixels in the regional image data of the third sub-region among the multiple sub-regions, defect detection is performed on the third sub-region among the multiple sub-regions; the third sub-region is the sub-region other than the second sub-region among the multiple sub-regions.

9. The method for detecting quality defects in hardware accessories based on industrial vision according to claim 8, characterized in that, Based on the Gaussian filter kernel and the grayscale gradient magnitude of all pixels in the regional image data of the third sub-region among the multiple sub-regions, defect detection is performed on the third sub-region among the multiple sub-regions, including: Based on the gray-level gradient magnitude of all pixels in the regional image data of the third sub-region, determine the direction of the largest gray-level gradient change and the direction of the smallest gray-level gradient change. The diffusion coefficient corresponding to the direction with the largest change in gray-level gradient is determined as a first preset value, and the diffusion coefficient corresponding to the direction with the smallest change in gray-level gradient is determined as a second preset value; the second preset value is greater than the first preset value. Defect detection is performed on the third sub-region among the multiple sub-regions based on the Gaussian filter kernel and diffusion coefficient.

10. A quality defect detection system for hardware accessories based on industrial vision, characterized in that, include: Acquisition device and processing device; Acquisition device, used to acquire raw image data of the surface of the hardware fittings to be inspected; The surface of the hardware component to be inspected is divided into multiple sub-regions; The processing device is used to determine the regional roughness index of each sub-region based on the original image data of the surface of the hardware fittings to be inspected. The processing device is also configured to determine suspected noise interference regions in the plurality of sub-regions based on the original image data and the regional coarsening index of the plurality of sub-regions; The processing device is also used to process the region image data of the suspected noise interference region in the original image data based on convolution operation, and to determine the noise interference confidence symbol of the suspected noise interference region. The noise interference confidence symbol is used to indicate that there is noise interference in a suspected noise interference area, or the noise interference confidence symbol is used to indicate that there is no noise interference in a suspected noise interference area; The processing device is also used to perform defect detection on the hardware parts to be inspected based on the regional roughness index of the plurality of sub-regions and the noise interference confidence symbol of the suspected noise interference region.