An industrial equipment image edge feature extraction method and system
By using gradient magnitude and orientation image processing and geometric constraint clustering, the problem of poor edge continuity in industrial equipment images is solved, achieving efficient and accurate edge feature extraction, which is suitable for quality assessment and defect detection of industrial equipment images.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TAIYUAN UNIVERSITY OF SCIENCE AND TECHNOLOGY
- Filing Date
- 2026-03-20
- Publication Date
- 2026-06-19
AI Technical Summary
Existing edge feature extraction methods suffer from poor edge continuity and insufficient response to complex geometric structures in industrial equipment images, and are prone to introducing redundant feature interference, resulting in low task efficiency.
Gradient magnitude and orientation image processing are used, combined with preset thresholds and geometric constraints for clustering. Pixels are classified into background, gradient, and edge pixels by using gradient magnitude thresholds. Feature distance verification is performed during the clustering process to ensure the continuity and integrity of edge features.
It improves the targeting and accuracy of edge feature extraction, reduces false detection and false negative rates, and achieves precise extraction from pixel level to region level, providing a more reliable basis for image quality assessment and defect detection.
Smart Images

Figure CN121883869B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology, and in particular relates to a method and system for extracting edge features from images of industrial equipment. Background Technology
[0002] In the field of industrial visual inspection, images of industrial equipment have become an important data foundation for tasks such as defect identification and equipment status monitoring. They are characterized by complex structures, rich edge details, and a high proportion of background areas. Accurately extracting edge and structural features from images can improve the understanding of industrial equipment images.
[0003] Currently, edge feature extraction from grayscale industrial equipment images mainly relies on two approaches: the first is a local edge detection method based on traditional gradient operators, and the second is a semantic feature extraction method based on deep convolutional networks. Traditional gradient operators use convolution kernels for computation, which is highly efficient, but the fixed weights are difficult to adapt to the complex edge structures of industrial equipment images, easily leading to edge breaks. Although deep convolutional networks can extract high-level semantic information from images, most models are pre-trained on natural image datasets, which differs from the prior texture and structure of industrial equipment images. Moreover, multiple downsampling and nonlinear activation operations can lose edge information, resulting in discontinuous edge features.
[0004] Meanwhile, the aforementioned methods are all limited to the single-pixel level in terms of feature representation and have not effectively modeled the geometric topology formed by multiple pixels, resulting in insufficient structural integrity and edge continuity of image edge features. Furthermore, industrial equipment images contain large areas of uniform background. If the indiscriminate global computation used in the above methods is applied to feature extraction from industrial equipment images, redundant feature interference will be introduced, reducing task efficiency. Summary of the Invention
[0005] The purpose of this invention is to provide a method and system for extracting edge features from industrial equipment images, which solves the problems of poor edge continuity and insufficient response to complex geometric structures in existing edge feature extraction methods when dealing with industrial equipment images.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] A method for extracting edge features from industrial equipment images, comprising the following steps:
[0008] S1: Acquire the input industrial equipment image, calculate the gradient magnitude and gradient direction of each pixel in the image, and generate a gradient magnitude map and a gradient direction map;
[0009] S2: Based on a preset gradient magnitude threshold, the pixels in the gradient magnitude map are classified into background pixels, gradient pixels, and edge pixels to obtain a pixel marker map.
[0010] S3: Based on the pixel marker map and the gradient direction map, the image is clearly distinguished into the background part and the main part. Geometric constraint clustering is performed on pixels of the same category. During the clustering process, the accuracy of the classification is verified according to the feature distance between the pixel and its cluster center. The classification of the pixel is adjusted, and the region-level edge feature map is output.
[0011] Preferably, the gradient calculation steps for each pixel in step S1 are as follows:
[0012] S101: Read the local industrial equipment image dataset and use the preset edge detection operator to calculate the gradient components of all pixels in the horizontal and vertical directions;
[0013] S102: First, sum the squares of the two gradient components of each pixel, and then take the square root to obtain the gradient magnitude of each pixel. This is used to characterize the intensity of structural abrupt change at the pixel and to provide a reference for subsequent pixel classification.
[0014] S103: Solve the inverse trigonometric function for the gradient components of each pixel to obtain the gradient direction of each pixel. The gradient direction is used to characterize the normal direction of the edge at that pixel, providing a reference for the geometric constraint clustering of subsequent pixels.
[0015] Preferably, the preset edge detection operator in step S101 is the Sobel operator, and the gradient magnitude in step S102 is... The calculation formula is:
[0016] ,in, and Each pixel Gradient components in the horizontal and vertical directions.
[0017] Preferably, the pixel classification steps in step S2 are as follows:
[0018] S201: Obtain the grayscale value range and distribution trend of the image, define it as global grayscale statistical features, and use it to determine the difference in grayscale values between the subject and background parts in a single image and the main distribution interval of grayscale values in each part. Combined with the statistical distribution model of gradient magnitude in the image dataset, determine the first gradient magnitude threshold used for classification. Second gradient magnitude threshold ,in The establishment of the statistical distribution model relies on the analysis and fitting of the distribution pattern of gradient magnitude in the image dataset.
[0019] S202: Compare the gradient magnitude of each pixel in the image with the threshold: Select pixels with gradient magnitudes lower than the threshold. The pixels are determined to be background pixels. ; Set the gradient magnitude higher than The pixel is determined to be an edge pixel. ; Set the gradient magnitude between and The pixels between them are determined to be gradient pixels. .
[0020] Preferably, in step S201, the upper limit threshold of the background gradient is calculated based on a statistical distribution model by setting a confidence probability. This ensures that the gradient magnitude of over 90% of background pixels is below this threshold, effectively distinguishing the background from the effective structural region. Background pixels exhibit uniform or gradual gradient changes in the image, with low and concentrated gradient magnitudes, statistically fitting an exponential distribution model. For the gradient magnitude distribution of the entire image, a statistical boundary determination method based on the mean and standard deviation is used. Utilizing Chebyshev's inequality, without assuming a specific distribution pattern, the upper bound threshold of the gradient magnitude is calculated based on a preset upper limit for the false positive probability. This threshold ensures that, theoretically, only pixels with significantly higher gradient magnitudes are identified as edge points, thus improving the strictness and anti-interference ability of edge extraction.
[0021] Preferably, the specific steps for pixel clustering and verification in step S3 are as follows:
[0022] S301: Connects consecutive edge pixels in geometric topological relationships The set is constructed based on the consistency of the gradient direction of the eight neighboring pixels to build geometric connection constraints. The pixels that satisfy the direction continuity are clustered to form a continuous edge structure, resulting in strong edges with clear gradient values and directions.
[0023] S302: Move edge pixels Gradient pixels around The data is aggregated and clustered based on spatial proximity and gradient feature similarity to form a uniform region. This provides a gradually changing boundary region between the edge and background parts, helping the model to understand the accuracy of the image.
[0024] S303: Clustering process based on pixel points and its cluster The feature distance from the center is used to verify the accuracy of the initial classification of the pixel; if the feature distance exceeds the adaptive tolerance... If so, the category of that pixel will be re-determined and adjusted.
[0025] Preferably, in step S301, the gradient direction consistency constraint means: when pixel point With the current cluster average gradient direction The absolute angular difference is less than the direction tolerance threshold. Only then can It is classified into this cluster; among them, Determined based on statistical values of gradient direction consistency within edge segments of the dataset.
[0026] Preferably, in step S303, the pixels To its cluster Feature distance The calculation formula is:
[0027] ,in, For pixels gradient magnitude, For clustering The average gradient magnitude; For pixels gradient direction, For clustering The average gradient direction; It is an angle difference function, and its calculation method is as follows: ; These are the weighting coefficients for the gradient magnitude. The weights are the gradient direction weights. and Respectively with clustering The variance of the gradient magnitude and gradient direction is inversely proportional.
[0028] Preferably, the adaptive tolerance in step S303 It is associated with the local gradient feature statistics of the clustered region, based on its cluster. Standard deviation of characteristic distance The calculation formula is dynamically determined as follows: ,in The proportionality coefficient is determined based on a preset significance level.
[0029] On the other hand, the present invention also provides an industrial equipment image edge feature extraction system, comprising:
[0030] The gradient calculation module is used to acquire the input image and calculate the gradient magnitude and gradient direction of each pixel, generating a gradient magnitude map and a gradient direction map.
[0031] The pixel classification module is connected to the gradient calculation module. It compares the gradient magnitude of each pixel with a preset threshold, classifies the pixels into background pixels, gradient pixels, and edge pixels, and outputs a pixel marker map.
[0032] The pixel clustering and verification module is connected to the pixel classification module. It is used to receive the pixel label map, gradient magnitude map and gradient direction map, perform geometric constraint clustering on pixels of the same category, and verify and adjust the pixel classification according to the feature distance during the clustering process, and finally output a region-level edge feature map with geometric consistency.
[0033] Compared with the prior art, the beneficial effects achieved by the present invention are as follows:
[0034] (1) By using gradient magnitude-guided pixel three-level classification, the image is separated into background, edge and gradient region, which improves the pertinence of the feature extraction model and its understanding of key parts;
[0035] (2) By integrating geometrically constrained clustering with consistent gradient directions, the continuity and integrity of the extracted edge structures are improved, overcoming the edge breakage problem in the extraction process of traditional models;
[0036] (3) Enhance the robustness of pixel category discrimination and reduce false detection and false negative rates by verifying and adaptively adjusting the classification results during the clustering process;
[0037] (4) This method achieves accurate extraction from pixel-level response to region-level structural features by hierarchical processing of pixel gradient characteristics and geometric topology clustering. It extracts continuous and geometrically high-fidelity edge features from complex industrial equipment images, solving the problems of poor edge continuity and insufficient response to complex geometric structures in existing edge feature extraction methods when dealing with industrial equipment images. It provides a more reliable data foundation for subsequent advanced vision tasks such as image quality assessment and defect detection. Attached Figure Description
[0038] Figure 1 This is a schematic diagram of the overall process of the edge feature extraction method according to an embodiment of the present invention;
[0039] Figure 2 This is a schematic diagram of the pixel classification effect in an embodiment of the present invention, wherein (a) represents the original image of the input industrial equipment, (b) represents the image of the processing area, (c) represents the gradient magnitude map of the area, (d) represents the gradient direction map of the area, and (e) represents the pixel marker map of the area.
[0040] Figure 3This is a schematic diagram of the pixel clustering and judgment verification process in an embodiment of the present invention, wherein (a) represents the pixel classification result, (b) represents edge pixel clustering, (c) represents gradient pixel clustering, (d) represents the preliminary clustering map (edge + gradient), (e) represents clustering verification and adjustment, and (f) represents the corrected region and feature map;
[0041] Figure 4 This is a schematic diagram of the module connections of the edge feature extraction system according to an embodiment of the present invention. Detailed Implementation
[0042] The technical solution of the present invention will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that the following embodiments are implemented based on the technical solution of the present invention, and detailed implementation methods and specific operation processes are given. However, the protection scope of the present invention is not limited to the following embodiments.
[0043] This embodiment provides a method for extracting edge features from industrial equipment images, including three sequentially executed steps: pixel gradient feature calculation (S1), pixel classification (S2), and pixel clustering and judgment verification (S3), aiming to extract complete and geometrically high edge structure features from grayscale industrial equipment images.
[0044] To elaborate on the implementation process and technical details of the method of this invention, the subsequent analysis and experiments in this embodiment use a self-constructed Industrial Equipment Images Dataset (IEID) as the experimental object. The sources of IEID include three categories: the first category is publicly available online resources; the second category is images obtained by multi-view 3D rendering of core industrial equipment components using SolidWorks 2022 software; and the third category is synthetic images generated based on the StyleGAN3 framework.
[0045] Before model training and feature extraction, all images are processed using the system's preprocessing workflow to standardize and enhance key information. First, all images are linearly scaled to a resolution of 512×512 pixels. Then, a three-step enhancement process is performed to improve detail sharpness, including using a contrast enhancer to achieve a 20% contrast increase; using a brightness enhancer to achieve a 10% increase in global illumination; and using a sharpness enhancer and edge convolution kernels for filtering.
[0046] The IEID dataset contains five types of industrial equipment: gears, robotic arms, robotic claws, electric motors, and hydraulic pumps, totaling 5,000 single-channel grayscale images, all of which are losslessly saved in PNG format. The dataset is divided into training, testing, and validation sets through stratified random sampling, with a ratio of 70:20:10.
[0047] The images in the dataset exhibit characteristics of complex subject structures, rich edge details, and large areas of uniform background. Therefore, edge feature extraction from such images requires balancing two issues: maintaining the continuity of the geometric structure and suppressing invalid background interference. This provides a representative validation scenario for the method of this invention.
[0048] like Figure 1 As shown, step S1: Calculate the basic gradient features of each pixel from the input grayscale image, including the gradient magnitude representing the intensity of structural abrupt changes and the gradient direction representing the geometric orientation of the edges. The specific operation is as follows:
[0049] S101: Calculate gradient components based on preset edge detection operators.
[0050] Specifically, the edge detection operator preset in this embodiment adopts the Sobel operator, and its horizontal convolution kernel is defined respectively. Convolution kernel in the vertical direction as follows:
[0051] ,
[0052] For any input image I in IEID, its pixels The gray value at that location is Performing a two-dimensional convolution operation yields the gradient components of that point in the horizontal and vertical directions. and , , ,in," The "" indicates a convolution operation, which iterates through all pixels in the image to obtain a horizontal gradient component matrix of the same size as the original image. With the vertical gradient component matrix .
[0053] S102: Calculate gradient magnitude
[0054] Based on the obtained gradient components and Calculate pixel points gradient magnitude at This is used to quantify the severity of the grayscale change at that point, and the calculation formula is: .
[0055] S103: Calculate gradient direction
[0056] Calculate pixels gradient direction at The gradient direction is perpendicular to the edge direction at that point, and the calculation formula is: To ensure the stability of the calculation, Special handling will be provided for certain situations; the handling rule is as follows: =0 and When >0, let =90 degrees; when =0 and When <0, let =-90 degrees; if both are 0, then the gradient direction at that point is undefined, and its magnitude is set to 0.
[0057] After processing in step S1, for any input image in IEID, two feature maps of the same size as the original image will be output, namely the gradient magnitude map. With gradient direction pattern The value of each pixel in the gradient magnitude map reflects the edge strength of that pixel; the gradient direction map encodes the geometric orientation information of the edge, and the two together constitute the basic features for subsequent pixel classification and geometric clustering.
[0058] Step S2: Using the gradient magnitude map calculated in Step S1 as the base data, label each pixel in the image with a category label. Through this gradient-based hierarchical approach, the complex image scene is deconstructed into three categories: background region, gradient region, and significant edge region. This achieves a preliminary understanding of the image structure and feature extraction, providing a clear processing target for subsequent geometric clustering. The specific operations are as follows:
[0059] S201: Obtain global statistical features and set gradient magnitude threshold
[0060] The accuracy of classification directly depends on two gradient magnitude thresholds, the first threshold... Second threshold ,and In this embodiment, the gradient threshold is determined based on the analysis of the "global grayscale statistical features" of the image.
[0061] Based on the empirical thresholding method using prior dataset statistics, statistical modeling is performed on the gradient magnitude of the IEID dataset training set to determine the specific values of the background and edge thresholds. During the statistical process, 1 / 10 of the images are randomly selected from the training set to form a representative sample set. The gradient magnitude map of each image in the sample set is calculated, and the i-th gradient magnitude map is denoted as... The gradient magnitude map of the image is as follows The gradient magnitude data of all sample images are merged to construct a total gradient magnitude sample set. Its form is: The set contains The observed gradient magnitude values are denoted as... Determine the background threshold. At that time, it was first assumed that the gradient magnitude of the background region mainly came from imaging noise and slight changes in illumination, and its statistical characteristics were modeled by exponential distribution.
[0062] From the sample set Extract all that satisfy The observed values, of which for The 20th percentile constitutes the background candidate subset. .
[0063] Analysis revealed The observed values in the data follow an exponential distribution, and its probability density function is:
[0064] The scaling parameter is calculated using the maximum likelihood estimation method. The estimated value, the likelihood function is: Taking the logarithm and then differentiating, we can obtain The estimated value is: ,in For set Sample size; at confidence level At a value of 0.95, the exponential distribution parameter The confidence interval can be determined by the chi-square distribution, specifically: Take the upper bound of the confidence interval as The conservative estimate is denoted as Background threshold Defined as the exponential distribution with a cumulative probability of The quantile at 0.90, i.e. This step ensures that at least 90% of the background pixels have a gradient magnitude lower than [the specified value]. .
[0065] Determine the edge threshold At that time, based on the overall sample set The statistical moments are derived and calculated. sample mean with sample standard deviation The formulas are as follows: and According to Chebyshev's inequality, for any distribution, the observed values fall within the interval [0, 1]. The probability of anything other than that does not exceed t is the standard deviation multiple of the deviation from the mean as defined in Chebyshev's inequality, and the upper bound of the probability of mistakenly classifying an interior point as an edge point is set as follows: =0.05, then from Solving Substitute worth Edge threshold Defined as: This definition ensures that, under any distribution, the gradient magnitude is greater than 1 / 2. Theoretically, the percentage of pixels should not exceed five percent, thus ensuring strict edge detection; through the above statistical modeling and rigorous derivation, the background threshold... With edge threshold It is uniquely determined by the dataset itself, and possesses reproducibility and objectivity.
[0066] S202: Threshold-based three-level pixel classification decision
[0067] The threshold was determined and Next, a systematic pixel classification and determination process begins, which involves traversing the gradient magnitude map. The position of each pixel in:
[0068] First, initialize the matrix by creating an empty matrix with the same size as the input image. , used to store the classification label for each pixel, where Indicates background, Indicates the transition point, Indicates an edge point.
[0069] Next, a pixel-by-pixel traversal and judgment are performed for each pixel in the image. Its coordinates are Obtain its gradient magnitude .
[0070] Finally, the three-level decision logic is executed:
[0071] like If the pixel is located in a background region with uniform grayscale and no significant structure, its gradient response is considered to originate primarily from noise or extremely smooth changes. This point is then placed in the label image. The middle mark is point;
[0072] like If the pixel is located at the boundary of an object or structure in the image, and its grayscale level changes drastically, corresponding to a significant physical edge, then the pixel is placed in the label image. The middle mark is point;
[0073] like If the gradient intensity of this pixel is at an intermediate level, it is located in a region with weak texture inside the object, a slightly shadowed transition area, or a blurry, incomplete edge part. This point will be placed in the label image. The middle mark is point.
[0074] After traversing and determining all pixels, output the final pixel category label image. This graph is spatially aligned with the original gradient magnitude and gradient direction graphs, and together they serve as input data for clustering and validation.
[0075] like Figure 2 As shown, (a) is the original image of the industrial equipment input, i.e., the input of the pixel classification module; (b) is the area to be processed selected by the display module function; (c) and (d) are the pixel-level gradient magnitude map and gradient direction map obtained after edge detection operator processing; and (e) is the pixel label map obtained after threshold judgment. After this step, the original grayscale image is converted into a color-coded category label map, which intuitively shows the separation effect of different regions.
[0076] In summary, the method of this invention transforms continuously distributed gradient information in an image into discrete region divisions, enabling preliminary structured analysis of industrial equipment images and providing a foundation for subsequent refined feature extraction based on geometric constraints.
[0077] Step S3: Moving beyond the pixel classification based on a single image value threshold in Step S2, this step achieves refined pixel organization and self-validation optimization of the classification results by fusing spatial geometric constraints and local statistical characteristics. This process transforms discrete pixel labels, which may contain misclassifications, into region-level structural feature maps with geometric consistency and statistical homogeneity. The category labels provided in Step S2 serve as important prior guidance, rather than immutable absolute criteria. The entire clustering validation process dynamically explores and adjusts based on the actual spatial relationships and feature consistency of the pixels. The specific operations are as follows:
[0078] S301: Edge pixel clustering based on gradient direction consistency and geometric constraints
[0079] This sub-step specifically handles those marked as The goal is to aggregate a set of points into several continuous, smooth physical edge segments with a consistent geometric orientation. Gradient direction consistency is used as the core constraint for geometric connectivity to ensure that pixels belonging to the same edge are not only adjacent in position, but their local edge orientations also change continuously.
[0080] The input data for this sub-step includes a set of coordinates of edge pixels. , corresponding gradient magnitude and gradient direction and the gradient direction map of the entire image. .
[0081] First, create an empty list of edge clusters. This is used to store the final edge segments;
[0082] Next, a status map, Status, is created with the same size as the original image. In the initial state, all edge pixels are marked as... This means it was not visited.
[0083] The main loop for edge segment clustering is as follows:
[0084] When the state is When the edge pixel is reached, the following region growing process is performed to generate a new edge fragment. :
[0085] First, select a seed point, that is, start from the state. Select a point from the edge pixels as the seed point The selection principle is to prioritize gradient magnitude. Larger point.
[0086] Then, the current cluster is initialized:
[0087] Create an empty set of points. A queue for points to be expanded .
[0088] Will join in and In, and update its status to This means that the cluster has already been visited, and the average gradient direction of the current cluster is initialized. for .
[0089] Then, the iterative growth of the clustered regions is achieved according to the following principles:
[0090] when If not empty, perform the following operations:
[0091] (1) From Extract a current point from the head. ;
[0092] (2) Inspection Each pixel in the 8-neighborhood To explore the neighborhood;
[0093] (3) Determine whether each point meets the connection condition. When all three of the following conditions are met, then... Connect to the current edge fragment:
[0094] Condition 1: These are the edge pixels in the initial classification of step S2;
[0095] Condition 2: The state is ;
[0096] Condition 3: gradient direction The value of is related to the average direction of the current cluster. The absolute angular difference is less than the preset direction tolerance threshold. The calculation of angle difference needs to take into account the circularity of the angle, that is:
[0097] Orientation tolerance threshold The determination is based on the statistical consistency of gradient directions within edge segments of the dataset, specifically using the following method:
[0098] Extract all points labeled as edge pixels from the training set, calculate the standard deviation of the gradient direction of pixels within each edge cluster, and take the average of the standard deviations of all clusters as the mean. The baseline value is then multiplied by a safety factor to ensure the clustering process is inclusive of naturally curved edges. Ultimately... The calculation formula is: ,in, Indicates the first The standard deviation of the gradient direction within each edge cluster The total number of clusters, For safety reasons, this embodiment takes... =1.8. If Then it is believed It is geometrically continuous with the current edge segment;
[0099] (4) If If the connection conditions are met, then... join in and ,Will Status updated to Simultaneously, incremental updates are used to dynamically update the average direction of the current cluster. This ensures that the clustering process can adapt to the curvature of the edges;
[0100] when When empty, it indicates that the continuous edge segment grown from the current seed point is complete. Saved as a separate edge List;
[0101] After the loop ends, It contains all continuous edge segments aggregated from discrete edge pixels. Each segment It is a collection of pixels and has an average gradient direction that represents its overall orientation. .
[0102] S302: Spatial-feature similarity clustering of gradient pixels
[0103] For marked as The pixels are aggregated to form a gradient amplitude that gradually decreases around the edge until it becomes a uniform transition area to the background area.
[0104] The clustering of these pixels employs a dual criterion based on spatial proximity and gradient feature similarity, as detailed below:
[0105] First, define two internal pixels. and The conditions for whether something belongs to the same cluster are as follows:
[0106] (1) Calculate the Euclidean distance between two pixels. Determine if it is less than the adaptive spatial distance threshold. Its value is determined based on prior knowledge of image resolution and object structure, and the specific formula is as follows:
[0107] ,in and These represent the width and height of the image, in pixels. This setting ensures that unreasonable clustering across obvious structural boundaries is avoided while maintaining local connectivity.
[0108] (2) Calculate the absolute value of the gradient magnitude difference between the two pixels. Determine if it is less than the adaptive gradient magnitude difference threshold. Its value is dynamically determined based on the gradient magnitude distribution of the current image.
[0109] ,in and These are the mean and standard deviation of the gradient magnitudes of all gradient pixels in the current image, respectively. This setting allows the threshold to adapt to contrast variations in different images, enhancing the adaptability of clustering.
[0110] Then, an improved region growing algorithm was used to analyze regions belonging to the same cluster. The pixel clustering operation is similar to step S301, but the growth conditions are replaced with the spatial and feature similarity criteria mentioned above, and the seed points can be arbitrarily labeled. Gradient pixels are generated and then grown.
[0111] After the operation is complete, all gradient pixels will be marked as a series of internal region clusters. Output the data, and cluster each gradient region. It can calculate its statistical characteristics such as average gradient magnitude.
[0112] S303: Clustering Validation and Adjustment Based on Feature Distance and Adaptive Tolerance
[0113] The initial classification in step S2 may contain errors, such as misclassifying high-intensity noise as an edge or weak edges as internal points. Therefore, a feedback adjustment mechanism based on statistical learning was designed.
[0114] First, define the feature distance:
[0115] For a given cluster pixels Clustering This refers to a cluster of edge pixels or a cluster of gradient pixels. (Definition) arrive The characteristic distance of the center is .
[0116] This invention proposes to use weighted Euclidean distance to perform the calculation in the feature space. The calculation method is as follows:
[0117] ,in, For pixels gradient magnitude, For clustering The average gradient magnitude; For pixels gradient direction, For clustering The average gradient direction; It is an angle difference function, and its calculation method is as follows: ; These are the weighting coefficients for the gradient magnitude. These are the weighting coefficients in the gradient direction. Used to handle angular circumference.
[0118] Weighting coefficient and The value is determined through feature normalization and contribution balancing strategies, specifically:
[0119] ,in and The current clusters are respectively The variance of gradient magnitude and gradient direction for all pixels is set. This setting allows the feature distance to automatically adapt to the different discreteness of features during calculation, achieving an automatic balance between the influence of magnitude and direction.
[0120] Then, based on each cluster Its own internal consistency dynamic calculation adaptive tolerance The method is as follows:
[0121] First, calculate the clustering. Feature distance of all pixels Standard deviation .
[0122] Then set ,in It is a proportionality coefficient, the value of which is determined based on the statistical significance level under the assumption of normality, and specifically takes the following values:
[0123] ,in It is the inverse cumulative distribution function of the standard normal distribution. For significance level, in this embodiment, we take... =0.05, corresponding to 2.576. Statistically, this value means that if the feature distance of a pixel exceeds 2.576 times the standard deviation of the cluster center, it is considered to be an outlier with a confidence level of over 95%.
[0124] This hypothesis states that in a cluster with relatively concentrated feature distribution, if the feature distance of a point exceeds the discrete range of most points in the cluster, there is reason to suspect that it is an outlier.
[0125] For each cluster and all the pixels inside it The following decision loop is executed:
[0126] (1) Calculation ,like Then the point Mark as a candidate outlier;
[0127] (2) For each candidate outlier Perform context analysis as follows:
[0128] (2.1) Check candidate outliers Based on its spatial location, determine whether it is located in the current cluster. On the spatial boundary.
[0129] (2.2) Examine its characteristics Determine the characteristics of the current cluster center The difference mainly comes from whether it is the amplitude or the direction.
[0130] After completing the decision loop for pixel classification, the type of outlier pixels is re-determined using the following method:
[0131] (1) If point Features and current clustering The differences are significant, primarily due to orientation, but also related to another spatially adjacent cluster. The central features are very close, that is The system then determines the pixel. The initial classification or cluster assignment is incorrect.
[0132] (2) After determining that a pixel is misclassified, the point will be... From the current clustering Remove them from the cluster and merge them into a more suitable cluster based on their feature similarity. If no suitable existing cluster exists, pixels of that type are considered transitional or noise points that cannot be assigned to at this time, and the processing method is as follows:
[0133] (1) Preserve its location information in the feature map and mark it as... state;
[0134] (2) In subsequent image analysis tasks, this type of point does not participate in geometric structure modeling, but its existence can be recorded as a potential anomalous region;
[0135] (3) If the same region continuously produces Undefined points in multiple consecutive frames of images, the local feature review mechanism is triggered to re-evaluate the classification threshold or clustering parameters of the region.
[0136] This re-determination process is entirely driven by the data calculated in step S303, and may overturn the initial label in step S2.
[0137] An initial label is If an edge pixel is identified as an outlier by a strong edge clustering, and its magnitude matches the adjacent internal region better, then it is reclassified as an outlier. point.
[0138] Finally, iteratively optimize using the following steps:
[0139] Whenever a pixel is reassigned, the affected clusters... and The number of pixels changed, so the center features of both were recalculated. and its adaptive tolerance .
[0140] Based on the updated features and tolerances, a new round of outlier detection and adjustment is initiated locally or globally until the assignment of all pixels becomes stable or the preset number of iterations is reached.
[0141] like Figure 3As shown, (a) is the pixel label map obtained after S2; (b) and (c) are the edge pixel cluster map obtained after step S301 and the gradient pixel cluster map obtained after step S302, respectively; (d) is the preliminary cluster label map obtained by combining (b) and (c), and the pixel categories marked in this map may deviate from the actual situation; (e) is the verification of each pixel category by performing step S303, and the pixel points that are misclassified after the verification algorithm is calculated are marked in the map; (f) is the corrected pixel label map obtained after modifying the misclassified pixel points marked in (e), and this map can be used as the final result of this region to output to the subsequent model.
[0142] After step S3, the final output is an optimized edge feature map with region-level annotations. This map can accurately depict the continuous geometry of each edge and its internal consistency, providing a high-fidelity structured feature basis for subsequent quality assessment or defect detection.
[0143] like Figure 4 As shown, this embodiment also provides an industrial equipment image edge feature extraction system, including:
[0144] Gradient calculation module: used to acquire the input image and calculate the gradient magnitude and gradient direction of each pixel, generating gradient magnitude map and gradient direction map;
[0145] Pixel classification module: Connected to the gradient calculation module, it compares the gradient magnitude of each pixel with a preset threshold, classifies the pixels, and outputs pixel category labels;
[0146] Pixel clustering and verification module: connected to the pixel classification module, used to receive pixel marker map, gradient magnitude map and gradient direction map, perform geometric constraint clustering on pixels of the same category, and verify and adjust pixel classification according to feature distance during the clustering process, and finally output a region-level edge feature map with geometric consistency.
[0147] Specifically, the gradient calculation module receives the input grayscale image and performs pixel gradient feature calculation in step S1. Internally, it encapsulates logic such as Sobel operator convolution, gradient magnitude and direction calculation, and finally outputs gradient magnitude map and gradient direction map to the downstream module.
[0148] The pixel classification module receives the gradient magnitude map and performs pixel classification in step S2. The module determines the strategy based on a preset threshold, completes the three-level classification of each pixel, and generates a pixel category label map.
[0149] The clustering validation module, as the core processing unit, receives gradient magnitude maps, gradient direction maps, and pixel category label maps from the first two modules. First, based on the category labels, different clustering engines are activated for edge pixels and internal pixels respectively. Then, a validation and adjustment loop based on feature distance and adaptive tolerance is executed. Finally, this module outputs an optimized, geometrically consistent region-level edge feature map, marking the complete transformation from raw data to structured knowledge. The modules exchange data through well-defined interfaces, forming an automated and interpretable feature extraction pipeline.
Claims
1. An industrial equipment image edge feature extraction method, characterized by, The specific steps are as follows: S1: Acquire the input industrial equipment image, calculate the gradient magnitude and gradient direction of each pixel in the image, and generate a gradient magnitude map and a gradient direction map; S2: Based on a preset gradient magnitude threshold, the pixels in the gradient magnitude map are classified into background pixels, gradient pixels, and edge pixels to obtain a pixel marker map. S3: Based on the pixel marker map and the gradient direction map, the image is clearly distinguished into the background part and the main part. Geometric constraint clustering is performed on pixels of the same category. During the clustering process, the accuracy of the classification is verified according to the feature distance between the pixel and its cluster center. The classification of the pixel is adjusted, and the region-level edge feature map is output. The specific steps for pixel classification in step S2 are as follows: S201: Obtain the grayscale value range and distribution trend of the image, define it as global grayscale statistical features, and use it to determine the difference in grayscale values between the subject and background parts in a single image and the main distribution interval of grayscale values in each part. Combined with the statistical distribution model of gradient magnitude in the image dataset, determine the first gradient magnitude threshold used for classification. Second gradient magnitude threshold ,in The establishment of the statistical distribution model relies on the analysis and fitting of the distribution pattern of gradient magnitude in the image dataset. S202: Compare the gradient magnitude of each pixel in the image with the threshold: Select pixels with gradient magnitudes lower than the threshold. The pixels are determined to be background pixels. ; Set the gradient magnitude higher than The pixel is determined to be an edge pixel. ; Set the gradient magnitude between and The pixels between them are determined to be gradient pixels. ; In step S201, based on a statistical distribution model, the upper limit threshold of the background gradient is calculated by setting a confidence probability. This ensures that the gradient magnitude of more than 90% of the background pixels is below this threshold, effectively distinguishing the background from the effective structural region. The background pixels exhibit uniform or gradual gradient changes in the image, with low and concentrated gradient magnitudes, statistically fitting an exponential distribution model. For the gradient magnitude distribution of the entire image, a statistical boundary determination method based on the mean and standard deviation is employed. Using Chebyshev's inequality, without assuming a specific distribution pattern, the upper bound threshold of the gradient magnitude is calculated based on a preset upper limit for the false positive probability. This threshold ensures that, theoretically, only pixels with significantly higher gradient magnitudes are identified as edge points, thus improving the strictness and anti-interference ability of edge extraction.
2. The method of claim 1, wherein, The gradient calculation steps for each pixel in step S1 are as follows: S101: Read the local industrial equipment image dataset and use the preset edge detection operator to calculate the gradient components of all pixels in the horizontal and vertical directions; S102: First, sum the squares of the two gradient components of each pixel, and then take the square root to obtain the gradient magnitude of each pixel. This is used to characterize the intensity of structural abrupt change at the pixel and to provide a reference for subsequent pixel classification. S103: Solve the inverse trigonometric function for the gradient components of each pixel to obtain the gradient direction of each pixel. The gradient direction is used to characterize the normal direction of the edge at that pixel, providing a reference for the geometric constraint clustering of subsequent pixels.
3. The method for extracting edge features of industrial equipment images according to claim 2, characterized in that, The preset edge detection operator in the step S101 adopts a Sobel operator, and the calculation formula of the gradient amplitude in the step S102 is as follows: The calculation formula is as follows: wherein, with are the gradient components in horizontal and vertical directions respectively. are the gradient components in horizontal and vertical directions respectively.
4. The method of claim 1, wherein, The specific steps for pixel clustering and verification in step S3 are as follows: S301: Connects consecutive edge pixels in geometric topological relationships The set is constructed based on the consistency of the gradient direction of the eight neighboring pixels to build geometric connection constraints. The pixels that satisfy the direction continuity are clustered to form a continuous edge structure, resulting in strong edges with clear gradient values and directions. S302: Move edge pixels Gradient pixels around The data is aggregated and clustered based on spatial proximity and gradient feature similarity to form a uniform region. This provides a gradually changing boundary region between the edge and background parts, helping the model to understand the accuracy of the image. S303: Clustering process based on pixel points and its cluster The feature distance from the center is used to verify the accuracy of the initial classification of the pixel; if the feature distance exceeds the adaptive tolerance... If so, the category of that pixel will be re-determined and adjusted.
5. The method for extracting edge features of industrial equipment images according to claim 4, characterized in that, In step S301, the gradient direction consistency constraint refers to: when pixel point With the current cluster average gradient direction The absolute angular difference is less than the direction tolerance threshold. Only then can It is classified into this cluster; among them, Determined based on statistical values of gradient direction consistency within edge segments of the dataset.
6. The method for extracting edge features of industrial equipment images according to claim 4, characterized in that, In step S303, the pixels To its cluster Feature distance The calculation formula is: ,in, For pixels gradient magnitude, For clustering The average gradient magnitude; For pixels gradient direction, For clustering The average gradient direction; It is an angle difference function, and its calculation method is as follows: ; These are the weighting coefficients for the gradient magnitude. The weights are the gradient direction weights. and Respectively with clustering The variance of the gradient magnitude and gradient direction is inversely proportional.
7. The method for extracting edge features of industrial equipment images according to claim 4, characterized in that, The adaptive tolerance in step S303 It is associated with the local gradient feature statistics of the clustered region, based on its cluster. Standard deviation of characteristic distance The calculation formula is dynamically determined as follows: ,in The proportionality coefficient is determined based on a preset significance level.
8. An industrial equipment image edge feature extraction system characterized by, include: The gradient calculation module is used to acquire the input image and calculate the gradient magnitude and gradient direction of each pixel, generating a gradient magnitude map and a gradient direction map. The pixel classification module is connected to the gradient calculation module. It compares the gradient magnitude of each pixel with a preset threshold, classifies the pixels into background pixels, gradient pixels, and edge pixels, and outputs a pixel marker map. The range and distribution trend of grayscale values in an image are obtained and defined as global grayscale statistical features. These features are used to determine the difference in grayscale values between the subject and background in a single image and the main distribution interval of grayscale values in each part. Combined with the statistical distribution model of gradient magnitudes in the image dataset, the first gradient magnitude threshold used for classification is determined. Second gradient magnitude threshold ,in The establishment of the statistical distribution model relies on the analysis and fitting of the distribution pattern of gradient magnitude in the image dataset. Based on the statistical distribution model, the upper threshold of the background gradient is calculated by setting the confidence probability The gradient amplitude of more than 90% of the background pixels is lower than the threshold, effectively distinguishing the background from the effective structure region. The background pixels exhibit uniform or gradual gradient changes in the image, with low and concentrated gradient magnitudes, statistically fitting an exponential distribution model. For the gradient magnitude distribution of the entire image, a statistical boundary determination method based on the mean and standard deviation is employed. Using Chebyshev's inequality, without assuming a specific distribution pattern, the upper bound threshold of the gradient magnitude is calculated based on a preset upper limit for the false positive probability. This threshold ensures that, theoretically, only pixels with significantly higher gradient magnitudes are identified as edge points, thus improving the strictness and anti-interference ability of edge extraction. The gradient magnitude of each pixel in the image is compared with the threshold: pixels with gradient magnitudes lower than the threshold are considered lower. The pixels are determined to be background pixels. ; Gradient magnitude higher than The pixel is determined to be an edge pixel. ; Set the gradient magnitude between and The pixels between them are determined to be gradient pixels. ; The pixel clustering and verification module is connected to the pixel classification module. It is used to receive the pixel label map, gradient magnitude map and gradient direction map, perform geometric constraint clustering on pixels of the same category, and verify and adjust the pixel classification according to the feature distance during the clustering process, and finally output a region-level edge feature map with geometric consistency.
Citation Information
Patent Citations
Human body infrared image small target detection method based on improved FGLCM features
CN121190750A
Packaging defect automatic detection system based on computer vision
CN121304619A