A Machine Vision-Based Method and System for Impurity Analysis in Metal Powder
By using a machine vision-based method for analyzing impurities in metal powder, a preliminary classification model is constructed using color features and grayscale information. The recognition results are then optimized by combining pixel density and gradient values. This solves the problems of accuracy and efficiency in impurity detection in existing technologies and enables efficient identification of impurities in metal powder.
Patent Information
- Application Number
- CN202510698003.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-28
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2045-05-28
AI Technical Summary
Existing technologies for detecting impurities in metal powders rely on manual microscopic observation, which is inefficient and highly subjective. X-ray analysis equipment is expensive and cannot achieve online detection. Traditional image analysis methods are difficult to distinguish foreign particles with different compositions but similar morphologies, resulting in inaccurate impurity classification results. In particular, in scenarios where color and brightness contrasts are not obvious, misjudgments or missed detections are serious.
A machine vision-based method for analyzing impurities in metal powders is adopted. By collecting image data, color features and grayscale information are extracted to construct a preliminary classification model. The classification results are optimized using feature parameters such as pixel density, gradient value, and perturbation intensity to improve the accuracy of impurity identification, including multi-view re-identification and importance threshold screening.
It enables accurate identification of impurities in metal powders, reduces the rate of missed detections and false detections, and improves detection efficiency. It is suitable for intelligent detection of powder metallurgy and metal materials.
Smart Images

Figure CN120543532B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of metal material detection and image processing technology, specifically to a method and system for analyzing impurities in metal powder based on machine vision. Background Technology
[0002] In industrial applications such as metal additive manufacturing and powder metallurgy, the purity of metal powder directly impacts product quality. Impurities mixed into metal powder can lead to problems like porosity, inclusions, and even reduced strength in the finished product. Therefore, identifying and analyzing impurities before the production and use of metal powder is crucial. Currently, commonly used methods for detecting impurities in metal powder include manual microscopic observation, optical image analysis, and X-ray composition analysis. Manual microscopic observation relies on human experience, resulting in low efficiency and high subjectivity; while X-ray analysis is accurate, the equipment is expensive and cannot be performed online; traditional image analysis methods mostly rely on geometric features such as particle outlines or sizes, making it difficult to distinguish foreign impurities with different compositions but similar morphologies, leading to inaccurate impurity classification results. Especially in scenarios where color and brightness contrast are not significant, methods based on single threshold segmentation or simple filtering algorithms struggle to effectively identify foreign particles that are similar to metal powder but have different compositions, causing misjudgments or missed detections, severely hindering the practical application of intelligent and automated detection systems. Summary of the Invention
[0003] The purpose of this invention is to provide a method and system for analyzing metal powder impurities based on machine vision, which classifies foreign matter components according to color differences and grayscale value changes to solve the problem of low accuracy in impurity identification.
[0004] To achieve the above objectives, the present invention provides the following technical solution: a machine vision-based method for analyzing impurities in metal powder, the method comprising: S1, acquiring image data of metal powder and extracting color features and grayscale value information; S2, constructing a preliminary classification model for foreign objects based on the extracted color features and grayscale value information, including calculating foreign object feature scores in multiple dimensions for each region in the image, listing all scores into an array, removing the maximum and minimum values, calculating the average confidence level of the region, setting an average confidence level threshold as a classification boundary, and considering a region with an average confidence level greater than the threshold as a preliminary identification of impurities; S3, using the preliminary classification model to screen for foreign objects. The process involves generating candidate impurity categories, including dividing the image into multiple regions, calculating the pixel density of each region, calculating the grayscale gradient value or color gradient value of the region, calculating the region perturbation intensity value, setting a region perturbation intensity threshold, and identifying regions with a perturbation intensity greater than the threshold as candidate impurities. S4: Based on the feature parameters of the candidate impurity categories, the classification results are optimized to improve impurity identification accuracy. This includes re-identifying all candidate impurity regions from multiple feature perspectives, recording the number of times each region is identified as an impurity and the total number of rounds of judgment, calculating the identification importance value, setting an identification importance threshold as the final screening criterion, and removing regions with an identification importance value lower than the threshold.
[0005] Preferably, step S1 includes dividing the image into multiple small blocks according to a sliding window, calculating the total gray value for each block, extracting the maximum inscribed circle diameter of the block using morphological calculation, calculating the brightness density index of each block, setting a brightness density index threshold, considering areas higher than the brightness density index threshold as potential impurity areas, and extracting the color distribution of each block as a color feature.
[0006] Preferably, the specific method for calculating the total gray value of each region in S1 includes dividing the image into multiple small regions of fixed size. For each small region, the values of the red, green, and blue color channels of each pixel are read sequentially. For each pixel, the red value is multiplied by 0.299, the green value by 0.587, and the blue value by 0.114 according to a fixed weighting ratio. Then, the three values are added together to obtain the gray value of the pixel. The gray values of all pixels in the region are accumulated to obtain the total gray value of the region.
[0007] Preferably, the specific method for calculating the brightness density index of each region in S1 includes performing morphological analysis on the region, extracting the largest inscribed circular region of the region, measuring the diameter of the largest inscribed circular region as a region scale reference, and dividing the total brightness value of the region by the square of the diameter to obtain the brightness density index of the region.
[0008] Preferably, the specific method for calculating the multi-dimensional foreign object feature score in S2 includes traversing each region in the image and extracting multiple aspects of image features for the region. First, the brightness contrast score is obtained by comparing the difference between the average gray value of pixels in the region and the average gray value of surrounding pixels, thus obtaining the brightness difference value between the region and the surrounding regions. Next, the deviation degree of the region in the color space is extracted, and the color deviation is compared with the neighboring regions in the three channels of hue, saturation, and brightness to obtain the color anomaly score.
[0009] Preferably, the specific method for calculating the pixel density of each region in S3 includes dividing the entire image into multiple regular regions. For each region block, all pixels inside the region block are traversed pixel by pixel. An edge detection method is used to determine whether a pixel belongs to an edge pixel. If the grayscale change value or color gradient value of a pixel exceeds a set threshold, it is considered an edge pixel. The total number of edge pixels identified in the region is counted. The number of edge pixels in the region is divided by the area of the region to obtain the pixel density of the region.
[0010] Preferably, the specific method for calculating the grayscale gradient value or color gradient value of the region in S3 includes reading the grayscale value or color channel value of each pixel in the small regions that have been divided in the image, selecting four adjacent pixels (top, bottom, left, and right) with each pixel as the center, calculating the difference between the grayscale value or color value and the center pixel, recording the magnitude of the difference in each direction, accumulating or averaging the differences in the four directions to obtain the local change intensity of the center pixel, repeating the above operation, traversing all pixels in the region, calculating the local change intensity of each pixel, and statistically analyzing the local change intensity of all pixels in the entire region, summing or averaging them to obtain the overall grayscale gradient value or color gradient value of the region.
[0011] Preferably, the specific method for calculating the regional disturbance intensity in S3 includes combining the obtained pixel density with the grayscale gradient value or color gradient value, using the pixel density as the basic distribution of regional changes, and using the grayscale gradient value or color gradient value as a disturbance factor multiplication term, and obtaining the regional disturbance intensity value by multiplying the two.
[0012] Preferably, the specific method for calculating the recognition importance in S4 includes performing feature recognition from multiple angles on all image regions that have been identified as candidate impurities, recording the number of times each region is judged as an impurity, and recording the total number of rounds in which the region is detected or participates in the judgment in all recognition processes. The recognition importance value is obtained by dividing the number of times each region is judged as an impurity by the total number of rounds in which the region is detected or participates in the judgment in all recognition processes.
[0013] A machine vision-based metal powder impurity analysis system is provided to implement the steps of the machine vision-based metal powder impurity analysis method. The system includes: an image acquisition module for acquiring image data of metal powder and extracting color features and grayscale value information; a preliminary classification construction module for constructing a preliminary classification model of foreign objects based on color features and grayscale value information; a candidate impurity screening module for screening foreign objects using the preliminary classification model and generating candidate impurity categories; and a classification optimization module for optimizing the classification results based on the feature parameters of the candidate impurity categories to improve the accuracy of impurity identification.
[0014] As can be seen from the above technical solution, the present invention has the following beneficial effects: This machine vision-based metal powder impurity analysis method and system collects image data of metal powder and extracts color features and grayscale information. Based on the extracted color features and grayscale information, a preliminary classification model of foreign matter is constructed. The preliminary classification model is used to screen foreign matter and generate candidate impurity categories. According to the feature parameters of the candidate impurity categories, the classification results are optimized to improve the accuracy of impurity identification. This effectively makes up for the limitations of traditional contour and size analysis methods in component classification, improves the ability to identify impurities with different compositions, enables the system to distinguish different types of foreign matter particles, solves the problem of misjudging impurities with similar morphology in traditional methods, achieves accurate analysis of areas with indistinct color and brightness contrast, significantly reduces the false negative and false positive rates, avoids the problems of strong subjectivity and low efficiency caused by manual microscopic observation, and has good engineering adaptability and application prospects. It classifies the types of foreign matter components according to color differences and grayscale value changes to solve the problem of low impurity identification accuracy. Attached Figure Description
[0015] Figure 1 This is a flowchart of the method of the present invention.
[0016] Figure 2 This is a connection diagram of the system modules of the present invention. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] like Figure 1As shown, this invention provides a technical solution: a method for analyzing impurities in metal powder based on machine vision. The method includes: S1, acquiring image data of metal powder and extracting color features and grayscale value information; S2, constructing a preliminary classification model for foreign objects based on the extracted color features and grayscale value information, including calculating foreign object feature scores in multiple dimensions for each region in the image, listing all scores into an array, removing the maximum and minimum values, calculating the average confidence level of the region, and setting an average confidence level threshold as a classification boundary. A region with an average confidence level greater than the threshold is considered to be preliminarily identified as an impurity; S3, using the preliminary classification model to screen foreign objects and generate candidate models. Selecting impurity categories involves dividing the image into multiple regions, calculating the pixel density of each region, calculating the grayscale gradient value or color gradient value of the region, calculating the region perturbation intensity value, and setting a region perturbation intensity threshold. Regions with a perturbation intensity greater than the region perturbation intensity threshold are considered candidate impurities. S4. Based on the feature parameters of the candidate impurity categories, optimize the classification results to improve the impurity identification accuracy. This includes re-identifying all candidate impurity regions from multiple feature perspectives, recording the number of times each region is identified as an impurity and the total number of rounds of judgment, calculating the identification importance value, setting an identification importance threshold as the final screening criterion, and removing regions with an identification importance value lower than the identification importance threshold.
[0019] This implementation method achieves intelligent identification of potential impurities in metal powder by constructing an image analysis process based on machine vision. First, in step S1, the metal powder sample is imaged using a high-definition industrial camera. After acquiring the image data, image processing algorithms (such as mean filtering and edge enhancement) are used to extract the color features (e.g., RGB three-channel values or converted HSV values) and grayscale information of each pixel, ensuring that subsequent analysis has a sufficient foundation of original information.
[0020] In step S2, the system divides the image into multiple fixed-size or adaptive regions. By calculating the feature scores of each region across multiple dimensions (such as color difference, brightness shift, and texture discontinuity), a preliminary foreign object discrimination model is constructed. To suppress the influence of random outliers on the average value, the maximum and minimum values are removed to obtain a more robust confidence assessment. The average confidence value of each region represents its probability of being a "foreign object," and a preliminary classification is achieved by setting a threshold.
[0021] In step S3, pixel density analysis and gradient detection techniques are introduced. Regions with low pixel density or drastic changes in grayscale / color gradients usually indicate structural discontinuities or color abrupt changes, potentially indicating the presence of impurities. The perturbation intensity is calculated by integrating indicators such as the standard deviation of the regional gradient distribution or the local noise index, representing the degree of image texture change. Perturbation intensities exceeding a set threshold suggest that the region may contain non-metallic powder foreign matter, thus forming a candidate impurity library.
[0022] In step S4, a multi-view recognition mechanism is introduced, which involves repeatedly recognizing candidate regions under different feature combinations (such as color + texture, grayscale + shape, etc.) and statistically analyzing the recognition results each time. Based on the total number of recognition rounds and the frequency of being identified as impurities, a recognition importance (which can be expressed as a normalized value of the recognition frequency) is defined. By setting a recognition importance threshold, regions with low recognition confidence can be filtered out, ultimately improving the stability and accuracy of the overall recognition system. This process embodies the complete working logic from low-level image feature extraction and region feature fusion modeling to multi-round strategy selection, ensuring high detection accuracy and anti-interference capability even under complex backgrounds and non-ideal lighting conditions.
[0023] This method enables effective identification of impurities in metal powders through image feature analysis without relying on complex physical detection equipment. The preliminary classification model improves the robustness of impurity identification by eliminating extreme values, while perturbation intensity and pixel density analysis enhance the system's sensitivity to minute foreign objects. Finally, a strategy based on the importance of identification improves the accuracy and repeatability of impurity identification, thereby increasing overall detection efficiency and reducing the false positive rate. It is applicable to various industrial scenarios such as powder metallurgy and metal material screening.
[0024] Taking titanium alloy powder as an example, after acquiring powder images via camera during a single batch of processing, the system identified a region with a sudden change in grayscale and a bluish hue, significantly different from the typical color (light gray or metallic luster) of metal powder. The initial classification model determined the region's confidence level to be 0.82 (higher than the set threshold of 0.75), thus placing it in the candidate library. In multiple rounds of identification, this region was identified as an impurity in 9 out of 10 judgments, with a recognition importance of 0.9, significantly higher than the screening threshold of 0.6. Combined with manual verification, it was ultimately confirmed that the impurity was blue plastic fiber, validating the high accuracy and operability of this method in practical testing.
[0025] S1 includes dividing the image into multiple small blocks by a sliding window, calculating the total gray value for each block, extracting the maximum inscribed circle diameter of the block using morphological calculations, calculating the brightness density index of each block, setting a brightness density index threshold, considering areas higher than the brightness density index threshold as potential impurity areas, and extracting the color distribution of each block as color features.
[0026] In the image preprocessing stage, to achieve more refined local feature recognition, the acquired metal powder images are divided into equally spaced sections using a sliding window strategy. Each sliding window corresponds to a small region and can overlap to cover the entire image. The system first sums the gray values within each small region to reflect the overall brightness intensity level of that region. Then, morphological calculation methods, such as dilation, erosion, and edge detection, are used to determine the largest inscribed circle of the area that provides the most significant contrast with the background, and its diameter is extracted as a reference parameter for the region's scale. Based on this, the system calculates the brightness density index, which can be defined as the ratio of the total gray value to the square of the largest inscribed circle's diameter, used to quantify the degree of brightness concentration per unit area. A brightness density index threshold is set through experimental statistics to filter out areas of abnormal brightness concentration as potential impurity targets from all sliding window regions. Simultaneously, the main color distribution features (such as the mean of the main color channels, hue distribution, saturation statistics, etc.) of each window region are extracted as one of the important dimensions for subsequent model construction. Through these steps, earlier and more refined perception and recognition of impurity regions are achieved.
[0027] Compared to whole-image processing methods, this implementation utilizes a sliding window partitioning strategy to achieve more detailed data extraction and analysis at a local scale, significantly improving the algorithm's ability to perceive subtle impurities. By calculating the brightness density index, regions with significantly different optical characteristics are effectively identified, thereby reducing the risk of impurities being masked by background grayscale. The maximum inscribed circle parameter extracted morphologically provides scale normalization capability for the brightness index, further enhancing the comparability between regions and the reliability of identification. This method combines color distribution information to establish a multi-feature fusion foundation, providing strong support for the accuracy of subsequent foreign object classification models.
[0028] The specific method for calculating the total grayscale value of each region in S1 includes dividing the image into multiple small regions of fixed size. For each small region, the values of the red, green, and blue color channels of each pixel are read sequentially. For each pixel, the red value is multiplied by 0.299, the green value by 0.587, and the blue value by 0.114 according to a fixed weighting ratio. Then, the three values are added together to obtain the grayscale value of the pixel. The grayscale values of all pixels in the region are accumulated to obtain the total grayscale value of the region.
[0029] To improve the physical accuracy of grayscale value calculation and adapt to the standardized processing of image information under different color conditions, the internationally accepted RGB weighted grayscale conversion algorithm is adopted. The specific steps are as follows: First, the entire image is divided into several small regions of a fixed size, such as 16×16 or 32×32 pixels, with each region serving as a separate analysis unit. Then, for all pixels within each region, the values of their RGB color channels are read. Using the weighting formula: Grayscale value = 0.299×R + 0.587×G + 0.114×B, each value is multiplied by its corresponding coefficient and summed to obtain the grayscale value of a single pixel. This weighting coefficient originates from a weighted perception model of human eye sensitivity to different colors, effectively reflecting visual brightness levels. After completing the above pixel-level calculations, the grayscale values of all pixels within the current small region are accumulated to obtain the overall grayscale value of that region. The total grayscale value serves as the basis for subsequent calculations of the brightness density index and other features, exhibiting good adaptability to lighting changes and visual consistency, ensuring the stability and noise resistance of the overall model.
[0030] The specific method for calculating the luminance density index of each region in S1 includes performing morphological analysis on the region, extracting the largest inscribed circular region of the region, measuring the diameter of the largest inscribed circular region as a region scale reference, and dividing the total luminance value of the region by the square of the diameter to obtain the luminance density index of the region.
[0031] To enhance the comparability and scale normalization of brightness features between image regions, this embodiment introduces a brightness density index as a key recognition parameter. The specific calculation process is as follows: First, the image is divided into several regions using a fixed or sliding window strategy, and morphological analysis is performed on each region. During this analysis, morphological operators such as edge detection and region filling are used to identify the largest inscribed circular region within each region, which serves as a representative region of the truly perceptible brightness range. The diameter of this inscribed circle is measured, and the square of this diameter is used as the scale normalization benchmark for that region. Subsequently, combining the total brightness value (i.e., the sum of gray levels) obtained by weighted summation of all pixel gray values, this total brightness value is divided by the square of the largest inscribed circle diameter to obtain the region brightness density index. This index actually expresses the brightness concentration level within a unit area, possessing strong regional comparative analysis capabilities. Compared to simple brightness values, this index is more stable and can effectively eliminate the influence of differences in area between different regions on the judgment, thereby enabling the impurity detection algorithm to have higher accuracy and robustness.
[0032] This implementation effectively improves the lateral comparability of image region features by normalizing and fusing regional brightness information with regional shape and size. Especially in metal powder images, impurities often exhibit abnormal brightness but irregular shape. The introduction of the brightness density index can more accurately identify abnormal regions with concentrated brightness but limited area, effectively improving the accuracy of early screening. At the same time, the selection of the inscribed circular region enhances the physical meaning of the scale parameter, which is beneficial for uniformly handling image segmentation problems at different scales.
[0033] The specific method for calculating the multi-dimensional foreign object feature score in S2 includes traversing each region in the image and extracting multiple aspects of image features for each region. First, the brightness contrast score is obtained by comparing the difference between the average gray value of pixels in the region and the average gray value of surrounding pixels, thus obtaining the brightness difference value between the region and the surrounding regions. Next, the degree of deviation of the region in the color space is extracted, and the color deviation is compared with the neighboring regions in the three channels of hue, saturation and brightness to obtain the color anomaly score.
[0034] To achieve preliminary identification of potential foreign object regions in an image, this implementation employs a multi-dimensional image feature extraction strategy. Specifically, it includes two core dimensions: brightness contrast and color deviation. First, the image is traversed according to preset regions (such as sliding windows or grid divisions). For each target region, the average grayscale value of all pixels within that region is calculated. Then, the average grayscale values of the surrounding neighboring regions (such as one region each on the top, bottom, left, and right sides) are also calculated, and the difference between these average values and the target region's average grayscale value is obtained to obtain a brightness contrast score. This score reflects the brightness prominence of the region within the overall image, helping to capture bright or dark spot-type impurities. Second, to enhance the color dimension's discriminative power, the image is converted from RGB color space to HSV color space. This conversion facilitates the analysis of color differences from a perspective closer to human visual perception. The average values of the target region across the H, S, and V channels are extracted in the HSV space and compared with the average values of the corresponding channels in neighboring regions. The differences in each channel are quantified separately and then combined to obtain a color anomaly score. This score measures the inconsistency in color distribution between the region and its background, serving as a key basis for identifying color-specific impurities. The feature scores of the two dimensions mentioned above will serve as the basis for subsequent credibility calculations, achieving a highly robust preliminary impurity screening.
[0035] By constructing a composite feature model using both grayscale and color dimensions, the system's adaptability to various types of impurities (including bright spot-like objects and colored spots) can be significantly improved. Brightness-contrast scores enable the system to maintain good discrimination performance when dealing with uneven lighting or reflective particles, while color anomaly scores further supplement the ability to identify foreign objects that exhibit abnormalities in the color space. The combination of these two factors enhances the sensitivity and accuracy of the initial classification model in detecting minute foreign objects against complex backgrounds.
[0036] The specific method for calculating the pixel density of each region in S3 includes dividing the entire image into multiple regular regions. For each region block, all pixels inside the region block are traversed pixel by pixel. An edge detection method is used to determine whether a pixel belongs to an edge pixel. If the grayscale change value or color gradient value of a pixel exceeds a set threshold, it is considered an edge pixel. The total number of edge pixels identified in the region is counted. The number of edge pixels in the region is divided by the area of the region to obtain the pixel density of the region.
[0037] This implementation calculates the pixel density of each region of an image using edge analysis to identify areas with potential structural abrupt changes or texture anomalies, thereby screening for potential impurity areas. First, the entire image is divided into multiple regular grid regions, for example, cut to a fixed pixel size (e.g., 32×32 or 64×64 pixels), ensuring coverage of all parts of the image. Then, for each region, all pixels within it are traversed one by one. During the traversal, the system applies edge detection algorithms (such as Sobel, Prewitt, or Canny operators) to determine whether each pixel exhibits significant grayscale or color gradient changes. Specifically, the system calculates the difference between the pixel and its neighboring pixels in grayscale value (single channel) and color component (multi-channel), and compares it to a preset threshold. If the difference exceeds the threshold, it is identified as an edge pixel. After completing pixel edge detection for the entire region, the number of pixels identified as edges in the region is counted, and this number is divided by the total number of pixels in the region (i.e., the region area) to obtain the pixel density value of that region. Higher pixel density indicates more texture variation or structural complexity in the region, typically corresponding to the presence of foreign objects or areas with uneven material. This indicator serves as one of the important bases for subsequent candidate impurity screening, providing the system with spatial structure recognition capabilities.
[0038] By introducing an edge pixel density calculation method, the system's recognition capability in the spatial structure analysis dimension is effectively improved. Compared with traditional color analysis methods, pixel density evaluation emphasizes the local structural complexity within a region, making it particularly suitable for identifying non-metallic impurities (such as fibers and fragments) with shape edges or abrupt structural changes. This method exhibits strong illumination adaptability and noise resistance, and can stably identify regions with complex textures under different imaging conditions, improving the effectiveness and accuracy of subsequent candidate screening stages.
[0039] The specific method for calculating the grayscale gradient or color gradient value of a region in S3 includes: reading the grayscale value or color channel value of each pixel in a small region that has been divided in the image; selecting four adjacent pixels (top, bottom, left, and right) around each pixel; calculating the difference between the grayscale value or color value and the center pixel; recording the magnitude of the difference in each direction; summing or averaging the differences in the four directions to obtain the local change intensity of the center pixel; repeating the above operation to traverse all pixels in the region and calculate the local change intensity of each pixel; and statistically analyzing the local change intensities of all pixels in the entire region, summing or averaging them to obtain the overall grayscale gradient or color gradient value of the region.
[0040] To achieve sensitive perception of local changes in an image, this implementation method reflects the degree of texture, brightness, or color change within a region by calculating the grayscale gradient or color gradient values of that region. The specific steps are as follows: First, the image is divided into multiple small regions. Pixels within each region are read one by one, and grayscale values (for single-channel images) or color channel values (such as the R, G, and B channels in RGB) are extracted. Taking each pixel as the center, four adjacent pixels (up, down, left, and right) are selected, and the difference between the channel value in each direction and the center pixel is calculated. For example, for a grayscale image, the grayscale difference values in the four directions are calculated; for a color image, the above difference calculation can be performed on each color channel separately. This operation captures the degree of local change, representing the intensity of brightness or color abrupt change in the region where the pixel is located in that direction. The differences in the four directions are accumulated or averaged to obtain the "local change intensity" index of the center pixel. The above operation is repeated, traversing all pixels in the entire region, and the local change intensities of all pixels are accumulated or averaged to finally obtain the overall grayscale gradient or color gradient value of the region. The higher the value of this indicator, the more significant the internal structural complexity, the number of edges, or the color variation of the region, thus indicating a higher probability of containing foreign objects or non-uniform structures.
[0041] This embodiment provides an image analysis mechanism based on pixel-level gradient differences, enabling the system to achieve higher resolution and sensitivity in texture judgment and color change recognition. By using grayscale or color gradient statistics, it can effectively distinguish between uniformly textured metal powder backgrounds and impurity regions with complex textures or prominent edges, improving the accuracy of subsequent perturbation intensity analysis and candidate impurity screening. This method is simple to calculate, robust, and applicable to various image resolutions and lighting conditions.
[0042] The specific method for calculating the regional disturbance intensity in S3 includes combining the obtained pixel density with the gray-level gradient value or color gradient value, using the pixel density as the basic distribution of regional changes, and using the gray-level gradient value or color gradient value as the disturbance factor multiplication term. By multiplying the two, the regional disturbance intensity value is obtained.
[0043] To comprehensively reflect the structural complexity and texture abruptness in local image regions, this implementation proposes a method for calculating regional perturbation intensity by combining pixel density and gradient information. Specifically, firstly, the pixel density index and grayscale gradient value or color gradient value of each segmented region in the image are obtained according to the aforementioned steps. Pixel density represents the richness of edge information within the region and is a basic distribution index of image changes; while the gradient value represents the intensity of color or brightness abrupt changes and is an important characterizing factor of foreign object perturbation. The system uses pixel density as the "baseline perturbation amount" and performs a point-to-point product operation with the corresponding gradient value, i.e., perturbation intensity value = pixel density × gradient value. This product form not only reflects the structural complexity (through pixel density) but also incorporates the influence of change intensity (through grayscale or color gradient), achieving coupling of the two information, thereby constructing a more discriminative regional perturbation intensity model. Finally, the regional perturbation intensity value serves as an important screening parameter for candidate impurity identification; regions exceeding a certain threshold are judged to have abnormal perturbation and further used for initial impurity screening.
[0044] This implementation significantly improves the accuracy of identifying impurity-sensitive regions by coupling edge density information of image regions with grayscale or color gradient changes. Compared to methods that rely solely on edge density or gradient as a single indicator, this composite perturbation intensity indicator has stronger discriminative power, especially suitable for processing background regions with dense edges but little variation or regions with abrupt color changes but smooth structures, effectively reducing false positives and false negatives. The product calculation method is simple and efficient, facilitating rapid implementation and system integration.
[0045] The specific method for calculating the importance of identification in S4 includes performing feature recognition from multiple angles on all image regions that have been identified as candidate impurities, recording the number of times each region is judged as an impurity, and recording the total number of rounds in which the region is detected or participates in the judgment in all identification processes. The importance value is obtained by dividing the number of times each region is judged as an impurity by the total number of rounds in which the region is detected or participates in the judgment in all identification processes.
[0046] To improve the accuracy and robustness of impurity identification, this implementation introduces an "identification importance" index in the final classification stage to verify the judgment results of candidate impurity regions from multiple angles and in multiple rounds. The specific method is as follows: First, all image regions identified as candidate impurities after S3 screening are processed using various feature dimensions or combinations. For example, independent identification can be performed using different parameter combinations based on brightness, color, texture, and shape features. During each round of feature identification, the system records whether each candidate region is identified as an impurity. By continuously performing multiple rounds of identification (e.g., repeating the judgment each time with different feature combinations, threshold settings, or model structures), a complete statistical record of the "number of correct judgments" and "number of rounds in which a region is identified as an impurity" is formed. Finally, the "identification importance" value of the region is obtained by dividing the number of times the region is identified as an impurity by the total number of rounds in which it participates in the judgment. A higher identification importance value indicates that the region is identified as an impurity from most feature perspectives, possessing higher consistency and confidence; conversely, a lower importance value indicates that the identification result of the region is unstable or tends towards the background, resulting in poor reliability.
[0047] By introducing an importance recognition mechanism, misjudgments that might arise from a single recognition perspective or judgment condition are effectively avoided, thus improving the robustness of the overall recognition strategy and the system's fault tolerance. The multi-angle evaluation strategy enhances the model's adaptability to different types of impurity manifestations, and the importance value provides a reliable numerical basis for setting the final recognition threshold, achieving precise screening and reducing false and false recognition rates. This is particularly suitable for industrial applications with extremely high requirements for detection accuracy.
[0048] like Figure 2 As shown, a machine vision-based metal powder impurity analysis system is also provided to implement the steps of the machine vision-based metal powder impurity analysis method. The system includes: an image acquisition module for acquiring image data of metal powder and extracting color features and grayscale value information; a preliminary classification construction module for constructing a preliminary classification model of foreign objects based on color features and grayscale value information; a candidate impurity screening module for screening foreign objects using the preliminary classification model and generating candidate impurity categories; and a classification optimization module for optimizing the classification results based on the feature parameters of the candidate impurity categories to improve the accuracy of impurity identification.
[0049] The system is built upon a modular image recognition workflow, aiming to achieve intelligent identification and automatic screening of impurities in metal powder. First, the image acquisition module acts as the front end, performing image acquisition and preprocessing tasks. It uses a high-definition industrial camera to capture images of the metal powder and combines image processing algorithms (such as image enhancement and color space conversion) to extract the color features (such as RGB and HSV values) and grayscale information of each pixel, providing basic data support for subsequent analysis. Then, the preliminary classification module, based on the extracted information, constructs a foreign object identification model by combining multiple feature dimensions such as brightness contrast, color deviation, and grayscale difference. This model uses a pre-defined confidence calculation strategy to make preliminary judgments on multiple regions in the image, generating a batch of preliminary identification results and filtering out areas that may contain impurities. The candidate impurity screening module, based on the preliminary classification results, further integrates structural parameters (such as pixel density, grayscale / color gradient, and perturbation intensity) to perform more refined feature analysis and spatial evaluation of the identified regions, forming high-confidence candidate impurity categories as the objects of subsequent judgment. Finally, the classification optimization module inputs all candidate regions into a multi-round, multi-feature recognition process, re-judges them from multiple angles and feature combinations, records the recognition count and rounds of each region, and performs final screening based on the recognition importance calculation logic to achieve accurate and highly reliable impurity recognition results.
[0050] This system features a modular design for image acquisition, classification modeling, region screening, and result optimization, exhibiting high integration and scalability. Through the combination and optimization of multiple recognition steps, the system maintains high recognition accuracy and stability even when faced with metal powder images of different types and under varying lighting conditions. The collaborative work between modules significantly improves processing efficiency and reduces the false recognition rate, demonstrating excellent industrial applicability and promotion potential. It is particularly suitable for applications requiring strict impurity control, such as powder metallurgy and metal material manufacturing.
[0051] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for analyzing impurities in metal powder based on machine vision, characterized by, The method comprises: S1, collecting image data of metal powder, and extracting color features and gray value information; S2, constructing a preliminary classification model of foreign matter based on the extracted color features and gray value information, including calculating a plurality of dimensions of foreign matter feature scores for each region in the image, listing all the scores as an array, eliminating the maximum and minimum values therefrom, calculating the average credibility of the region, setting the average credibility threshold as the classification boundary, and regarding a region with an average credibility greater than the threshold as preliminarily identified as impurities; S3, screening foreign matter by using the preliminary classification model to generate a candidate impurity category, including dividing the image into a plurality of regions, calculating the pixel density of each region, calculating the gray gradient value or color gradient value of the region, calculating the region disturbance intensity value, setting a region disturbance intensity threshold, and regarding a region with a region disturbance intensity greater than the region disturbance intensity threshold as a candidate impurity; S4, optimizing the classification result according to the feature parameters of the candidate impurity category to improve the impurity recognition accuracy, including re-identifying all candidate impurity regions from multiple feature perspectives, recording the number of times each region is identified as impurities and the total number of judgment rounds, calculating the recognition importance value, setting the recognition importance threshold as the final screening standard, and removing regions with a recognition importance lower than the recognition importance threshold; The specific method for calculating the pixel density of each region in S3 includes dividing the entire image into a plurality of regular regions, traversing all pixel points in each region block pixel by pixel, using an edge detection method to determine whether a pixel belongs to an edge pixel, regarding a pixel with a gray value change or color gradient value exceeding a set threshold as an edge pixel, counting the total number of edge pixels in the region, and dividing the number of edge pixels in the region by the area size of the region to obtain the pixel density of the region; The specific method for calculating the gray gradient value or color gradient value of the region in S3 includes reading the gray value or color channel value of each pixel in the divided small region in the image, selecting four adjacent pixels above, below, left and right of each pixel as the center, calculating the difference between the gray value or color value and the center pixel in each direction, recording the difference size in each direction, and accumulating or averaging the differences in the four directions to obtain the local change intensity of the center pixel. The above operation is repeated to traverse all pixel points in the region, calculate the local change intensity of each pixel, and calculate the sum or average of the local change intensities of all pixels in the region to obtain the overall gray gradient value or color gradient value of the region; The specific method for calculating the region disturbance intensity in S3 includes combining the pixel density and the gray gradient value or color gradient value, taking the pixel density as the basic distribution of the region change, taking the gray gradient value or color gradient value as the disturbance factor multiplier, and multiplying the two to obtain the region disturbance intensity value.
2. The method for analyzing impurities in metal powder based on machine vision according to claim 1, characterized in that: The S1 includes dividing the image into multiple small blocks by a sliding window, calculating the total gray value of each block, extracting the maximum inscribed circle diameter of the block by a morphological calculation method, calculating the brightness density index of each block, setting a brightness density index threshold, regarding the region higher than the brightness density index threshold as a potential impurity region, and extracting the color distribution of each block as a color feature.
3. The method of claim 2, wherein: The specific method for calculating the total gray value of each block in the S1 includes dividing the image into multiple small regions of fixed size, for each small region, sequentially reading the values of the red, green and blue color channels of each pixel point in the small region, for each pixel point, multiplying the red value by 0.299, the green value by 0.587, and the blue value by 0.114 according to a fixed weighting ratio, then adding the three values to obtain the gray value of the pixel, and accumulating the gray values of all pixels in the region to obtain the total gray value of the region.
4. The method for analyzing impurities in metal powder based on machine vision according to claim 2, characterized in that: The specific method for calculating the brightness density index of each block in the S1 includes performing morphological analysis on the region, extracting the maximum inscribed circular region of the region, measuring the diameter of the maximum inscribed circular region as a reference for the size of the region, and dividing the total brightness value of the region by the square of the diameter to obtain the brightness density index of the region.
5. The method for analyzing impurities in metal powder based on machine vision according to claim 1, characterized in that: The specific method for calculating the foreign matter feature score in multiple dimensions in the S2 includes traversing each region in the image, extracting multiple image features of the region, first obtaining the brightness contrast score of the region by comparing the difference between the average pixel gray value in the region and the average pixel gray value around the region, obtaining the brightness difference value between the region and the surrounding region, then extracting the deviation degree of the region in the color space, comparing the color deviation with the adjacent region in the hue, saturation and brightness channels to obtain the color deviation score.
6. The method for analyzing impurities in metal powder based on machine vision according to claim 1, characterized in that: The specific method for calculating the recognition importance in the S4 includes performing feature recognition from multiple angles for all image regions identified as candidate impurities, recording the number of times each region is judged as an impurity, recording the total number of rounds of detection or participation in judgment of the region in all recognition processes, dividing the number of times each region is judged as an impurity by the total number of rounds of detection or participation in judgment of the region in all recognition processes to obtain the recognition importance value.
7. A machine vision-based metal powder impurities analysis system for implementing the steps of the machine vision-based metal powder impurities analysis method according to any one of claims 1 to 6, characterized in that, The system comprises: An image acquisition module for acquiring image data of metal powder and extracting color feature and gray value information; A preliminary classification construction module for constructing a preliminary classification model of foreign matter based on color feature and gray value information; A candidate impurity screening module for screening foreign matter using the preliminary classification model to generate a candidate impurity category; A classification optimization module for optimizing the classification result according to the feature parameters of the candidate impurity category to improve the impurity recognition accuracy.
Citation Information
Patent Citations
System for identifying impurities of edible funguses on line
CN102495067A
Edible oil impurity detection method based on image background probability graph
CN105973904A