Colorful treasure color high-precision sorting method based on machine vision

By preprocessing and extracting features from colored gemstone images and combining HSV color space with density clustering of DBScan algorithm, the accuracy and stability issues of traditional colored gemstone color sorting methods are solved, and efficient and reliable colored gemstone color sorting is achieved.

CN120635514AInactive Publication Date: 2025-09-12王德祥
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510755916.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-07
Publication Date
2025-09-12
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional colored gemstone color sorting methods rely on manual recognition, which is inefficient and has a high recognition error rate. Algorithm-based methods have low sorting accuracy under lighting changes and dust pollution, making it difficult to achieve multi-level segmentation of the same color. Machine learning and deep learning also have difficulties in parameter adjustment and the risk of overfitting.

Method used

By acquiring colored gemstone images, cropping, splicing and denoising them, converting them into HSV color space, extracting and fusion of color histograms and statistical features, using DBScan algorithm for density clustering, and adaptively optimizing the neighborhood radius to achieve high-precision sorting.

Benefits of technology

It improves the accuracy and efficiency of colored gemstone color sorting, enhances the stability and adaptability of sorting, can cope with lighting changes and dust pollution at the production site, and adapt to the color distribution characteristics of different types of colored gemstones.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120635514A_ABST
    Figure CN120635514A_ABST
Patent Text Reader

Abstract

The invention relates to a high-precision color sorting method for colored treasures based on machine vision. The method comprises the following steps: acquiring a plurality of colored gemstone images, and performing cutting, splicing and noise reduction processing on the colored gemstone images to generate a pre-processed image; converting the image into an HSV color space, dividing the HSV color space into a plurality of sub-regions, extracting and fusing color histogram features and statistical features of the sub-regions, and generating a multi-dimensional feature vector; performing standardization processing on the multi-dimensional feature vector, and determining a neighborhood radius of a DBScan algorithm through adaptive optimization to obtain an optimal neighborhood radius; and performing density clustering processing by adopting a DBScan algorithm according to the optimal neighborhood radius and the standardized feature matrix to generate a color classification result. According to the method, through the technical means of image processing, feature extraction, optimization clustering and the like, not only is the precision of color sorting of the colored treasure improved, but also the similar colors can be distinguished more accurately, the stability and adaptability of sorting are enhanced, and an efficient and reliable colored treasure color sorting solution is provided for the jewelry industry.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of machine vision, and in particular relates to a high-precision method for sorting colored gemstone colors based on machine vision. Background Art

[0002] Amidst global economic recovery and rising consumer purchasing power, the jewelry industry's market size continues to grow. Colored gemstones, a key segment of the jewelry industry, are a crucial sector, and their color attributes directly determine their quality and value. Therefore, achieving accurate color classification is crucial for the healthy development of the entire jewelry industry. Traditionally, color sorting of colored gemstones relies primarily on manual labor, using color standard charts to visually identify color differences. However, long hours of work can fatigue workers, leading to increased error rates and low efficiency, making it difficult to meet the demands of large-scale production. Furthermore, different personnel use inconsistent judgment criteria, resulting in significant color fluctuations within each type of sorted gemstone.

[0003] On the other hand, color classification methods based on traditional algorithms are widely used in certain scenarios due to their high efficiency. These methods primarily rely on classic color space models such as RGB (Red, Green, Blue) and HSV (Hue, Saturation, Value) to extract color feature values ​​from the target area and set static thresholds to achieve classification. However, lighting fluctuations and dust pollution at production sites can introduce significant background noise into captured images, significantly interfering with color segmentation of the main gemstone area and leading to inaccurate feature extraction. Furthermore, for gemstone samples with similar hues, static threshold-based classification methods struggle to achieve multi-level segmentation within the same color family, effectively classifying samples within the threshold range into a single category. Furthermore, these methods lack dynamic adaptability when gemstones exhibit color variations from multiple angles due to their optical properties. Specifically, machine learning offers the advantages of fast processing speed, low cost, and strong adaptability. While this method can be leveraged for color classification, it suffers from limited subdivision levels and significant limitations when segmenting within the same color category. Furthermore, machine learning requires manual parameter adjustment, which is inefficient and difficult to adapt to the color distribution characteristics of different colored gemstones, resulting in unstable sorting results. In addition, although deep learning has strong anti-interference ability and high sorting accuracy, manual sample sorting is inefficient, and the scarcity of samples can easily lead to the risk of overfitting of the model, resulting in a significant increase in missed detection rate and false alarm rate. Summary of the Invention

[0004] Based on this, it is necessary to provide a high-precision color sorting method for colored gemstones based on machine vision to address the above technical problems, so as to improve the accuracy and efficiency of colored gemstone color sorting and enhance the stability and adaptability of sorting.

[0005] In a first aspect, the present application provides a method for high-precision color sorting of colored gemstones based on machine vision, comprising:

[0006] Acquire multiple colored gemstone images, and perform cropping, splicing, and noise reduction on each colored gemstone image to generate a pre-processed image;

[0007] Convert the preprocessed image to HSV color space to generate an HSV image, divide the HSV image into multiple sub-regions, extract and fuse the color histogram features and statistical features of each sub-region, and generate a multi-dimensional feature vector;

[0008] The multi-dimensional feature vector is normalized to obtain a normalized feature matrix, and the neighborhood radius of the DBScan algorithm is determined by adaptive optimization to obtain the optimal neighborhood radius;

[0009] According to the optimal neighborhood radius and the standardized feature matrix, the DBScan algorithm is used to perform density clustering and generate color classification results.

[0010] In one embodiment, a DBScan algorithm is used to perform density clustering based on the optimal neighborhood radius and the standardized feature matrix to generate a color classification result, including:

[0011] Obtain the preset minimum number of samples, and for each sample point in the standardized feature matrix, count the number of samples in the neighborhood corresponding to the optimal neighborhood radius;

[0012] If the number of samples is greater than the preset minimum number of samples, the corresponding sample points are determined to be core points, and a core point set is generated;

[0013] Select an unmarked core point from the core point set, traverse the unmarked sample points in the neighborhood of the corresponding optimal neighborhood radius of the unmarked core point, mark the points in the unmarked sample points that meet the sample number greater than the preset minimum number as new core points, and recursively traverse the samples in the neighborhood of the optimal neighborhood radius corresponding to the new core point until no updated core points are added, and generate the maximum set of density-connected samples as the density cluster;

[0014] Store each density cluster in the corresponding folder and generate color classification results.

[0015] In one embodiment, converting the pre-processed image into the HSV color space to generate the HSV image includes:

[0016] Normalize the RGB channel values ​​of each pixel of the preprocessed image to obtain a normalized RGB value;

[0017] According to the maximum channel value type judgment rule, the hue value of the normalized RGB value is calculated to obtain the hue component of each pixel;

[0018] If the maximum channel value of the normalized RGB value is 0, the saturation is determined to be 0. Otherwise, the saturation calculation is performed on the normalized RGB value using a preset saturation calculation formula to obtain the saturation component of each pixel.

[0019] The maximum channel value in the normalized RGB value is used as the brightness value to obtain the brightness component of each pixel;

[0020] Generate an HSV image based on the hue component, saturation component, and lightness component.

[0021] In one embodiment, the HSV image is divided into multiple sub-regions, and the color histogram features and statistical features of each sub-region are extracted and fused to generate a multi-dimensional feature vector, including:

[0022] According to the preset rectangular coordinate parameters, the HSV image is cropped to obtain 6 sub-regions;

[0023] According to the pixel distribution of each sub-region, the histogram statistical processing of the hue channel, saturation channel and brightness channel is performed respectively to obtain the color histogram features of each channel;

[0024] Based on the color histogram features, the mean and standard deviation of each channel are calculated to obtain statistical features;

[0025] According to the preset feature fusion rules, the color histogram features and statistical features are spliced ​​together to obtain a multi-dimensional feature vector.

[0026] In one embodiment, the neighborhood radius of the DBScan algorithm is determined by adaptive optimization to obtain the optimal neighborhood radius, including:

[0027] Define the minimum candidate value and the maximum candidate value of the neighborhood radius, set the search space of the neighborhood radius based on the minimum candidate value and the maximum candidate value, and set the search step size;

[0028] Taking maximizing the number of effective clusters as the optimization goal, an optimization function is constructed based on the search space and optimization goal;

[0029] According to the optimization function, the gradient descent method is used to iteratively calculate in the search space, and the optimal neighborhood radius is solved by the following formula:

[0030]

[0031] Among them, ε * is the optimal neighborhood radius obtained by solving, ε is the neighborhood radius, ε' is the candidate parameter set of the neighborhood radius ε, and C(ε) is the number of valid clusters.

[0032] In one embodiment, each colored gemstone image is cropped, spliced, and subjected to noise reduction processing to generate a pre-processed image, including:

[0033] Crop each colored gemstone image according to a preset rectangular frame to obtain each cropped gemstone image;

[0034] According to the preset splicing rules, the cropped gemstone images are spliced ​​together to obtain a composite image;

[0035] A Gaussian filter device is used to perform Gaussian filtering on the synthetic image to obtain a preprocessed image, wherein the radius of the filter is 3 and the standard deviation is 1.5.

[0036] In one embodiment, the neighborhood corresponding to the optimal neighborhood radius is:

[0037] N ε (p)={q∈F′∣||pq||2≤ε}

[0038] Among them, N ε (p) represents the neighborhood with the target sample point p as the center and the neighborhood radius ε, ε is the optimal neighborhood radius, p is the target sample point, and p belongs to the standardized feature vector set, q is the sample point in the neighborhood, that is, the sample that satisfies the Euclidean distance ≤ ε from the target sample point p.

[0039] In a second aspect, the present application also provides a high-precision color sorting system for colored gemstones based on machine vision, comprising:

[0040] An image preprocessing module is used to obtain multiple colored gemstone images, and perform cropping, splicing and noise reduction on each colored gemstone image to generate a preprocessed image;

[0041] The feature space conversion and extraction module is used to convert the preprocessed image into the HSV color space to generate an HSV image, and then divide the HSV image into multiple sub-regions, extract and fuse the color histogram features and statistical features of each sub-region, and generate a multi-dimensional feature vector;

[0042] The feature standardization and parameter optimization module is used to standardize the multi-dimensional feature vector to obtain the standardized feature matrix, and determine the neighborhood radius of the DBScan algorithm through adaptive optimization to obtain the optimal neighborhood radius;

[0043] The density clustering classification module is used to perform density clustering processing based on the optimal neighborhood radius and the standardized feature matrix using the DBScan algorithm to generate color classification results.

[0044] In a third aspect, the present application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps in the first aspect when executing the computer program.

[0045] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the first aspect when the computer program is processed.

[0046] This high-precision machine vision-based method for color sorting of colored gemstones removes redundant information and noise interference from colored gemstone images by capturing them and performing cropping, splicing, and noise reduction. This improves image quality and provides high-quality basic data for subsequent feature extraction. Secondly, the preprocessed image is converted to the HSV color space and divided into regions. The color histogram is extracted and fused with statistical features to generate a multidimensional feature vector. This fully and accurately captures the color characteristics of colored gemstones. Compared to single feature extraction, this enriches the feature dimensions and facilitates color differentiation. Normalizing the multidimensional feature vector and adaptively optimizing the neighborhood radius of the DBScan algorithm not only ensures consistency and comparability of feature data but also finds clustering parameters that are appropriate for the distribution of colored gemstone color data, further improving clustering accuracy. Finally, density clustering using the DBScan algorithm based on the optimal neighborhood radius and the standardized feature matrix effectively classifies colored gemstone colors. This method also considers the density distribution of data points, adapting to complex situations with diverse and partially similar colored gemstone colors and improving classification accuracy.

[0047] Compared with traditional colored gemstone color sorting methods, this method uses technical means such as image processing, feature extraction and optimized clustering to not only improve the accuracy of colored gemstone color sorting, but also be able to more accurately distinguish similar colors and achieve multi-level segmentation of the same color system. It also enhances the stability and adaptability of sorting, can cope with interference factors such as lighting changes and dust pollution at the production site, and adapt to the color distribution characteristics of different categories of colored gemstones, providing the jewelry industry with an efficient and reliable colored gemstone color sorting solution. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0049] Figure 1 A flow chart of a method for high-precision color sorting of colored gemstones based on machine vision, provided as an exemplary embodiment of the present invention;

[0050] Figure 2 A schematic diagram of the structure of a high-precision colored gemstone color sorting system based on machine vision is provided as an exemplary embodiment of the present invention. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0052] In one embodiment, Figure 1 As shown, a method for high-precision color sorting of colored gemstones based on machine vision is provided. This embodiment uses the method applied to a terminal as an example for illustration. It is understandable that the method can also be applied to a server, or to a system including a terminal and a server, and implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0053] S101: Acquire multiple colored gemstone images, and perform cropping, splicing, and noise reduction on each colored gemstone image to generate a pre-processed image.

[0054] Specifically, a CCD camera can be fixed. As the colored gemstone rolls from right to left on a roller, the front light source is illuminated and four consecutive images are captured. After the capture is complete, the front light source is turned off, the back light source is illuminated, and two more images are taken to fully capture the gemstone's color characteristics. The captured images are then transferred to a computer via a USB port. Subsequently, to ensure image consistency and regularity, the colored gemstone is cropped using a 224×224 pixel rectangular frame and the cropped image is spliced ​​onto a 762×448 pixel black background image. A Gaussian filter is then used to denoise the spliced ​​image, effectively removing high-frequency noise and smoothing the image's color distribution. This produces a high-quality preprocessed image, laying the foundation for subsequent color feature extraction.

[0055] S102: Convert the preprocessed image into the HSV color space to generate an HSV image, divide the HSV image into multiple sub-regions, extract and fuse the color histogram features and statistical features of each sub-region, and generate a multi-dimensional feature vector.

[0056] Specifically, the HSV color space can more clearly separate or express the color information of an image. First, the RGB color channel values ​​are normalized to the 0-1 range. Then, a specific algorithm is used to calculate the hue, saturation, and lightness values ​​and convert them into an HSV image. After the conversion is complete, the image can be divided into multiple subregions. The color histogram and statistical features are calculated for each subregion to capture local differences in the color of the colored gemstones and avoid the bias caused by a single global feature. The color histogram features reflect the distribution of pixel values ​​at each grayscale level, while the statistical features describe the central tendency and dispersion of the color distribution. After normalizing these features, the normalized histogram features are concatenated with the statistical features to form a multidimensional feature vector. This vector comprehensively characterizes the color characteristics of the colored gemstones and provides rich information for subsequent clustering analysis.

[0057] S103: performing normalization processing on the multi-dimensional feature vector to obtain a normalized feature matrix, and determining the neighborhood radius of the DBScan algorithm through adaptive optimization to obtain an optimal neighborhood radius.

[0058] Specifically, by calculating the global mean and standard deviation of the eigenvector, each dimension of the eigenvector can be normalized to the range of 0 to 1 to generate a standardized feature matrix, ensuring that each feature dimension has equal importance in the cluster analysis, and avoiding the clustering algorithm being overly sensitive to certain dimensions due to differences in the range of feature values. For the key parameter of the neighborhood radius in the DBScan algorithm, a parameter optimization strategy of the gradient descent method can be adopted. Schematically, within the preset parameter search space, the optimal neighborhood radius can be determined through iterative search with the maximization of the number of effective clusters as the objective function. This adaptive optimization process not only avoids the tediousness and inaccuracy of manual parameter adjustment in traditional methods, but also further improves the algorithm's adaptability to the color distribution of different colored gemstones and the clustering accuracy, providing a strong guarantee for achieving high-precision color sorting.

[0059] S104: Based on the optimal neighborhood radius and the standardized feature matrix, a DBScan algorithm is used to perform density clustering processing to generate a color classification result.

[0060] Specifically, the DBScan algorithm is a density-based clustering algorithm that can identify density-connected points and group them into the same cluster. Through the density clustering process based on the DBScan algorithm, with the standardized feature matrix as input and the optimal neighborhood radius determined by adaptive optimization, the natural clustering structure in the color data of colored gemstones can be identified. Schematically, the DBScan algorithm automatically identifies different categories of colored gemstone colors by defining the neighborhood range of sample points, distinguishing core points, boundary points, and noise points, and generating clusters based on density connectivity. This allows for high-precision classification of colored gemstone colors, accurately distinguishing different color categories and different levels of the same color, and meeting the jewelry industry's demand for refined colored gemstone color sorting. In addition, the algorithm can discover clusters of any shape, overcoming the shortcomings of traditional clustering algorithms such as K-means that can only discover spherical clusters.

[0061] In this method, by acquiring multiple colored gemstone images and performing cropping, splicing, and noise reduction, noise interference and redundant information in the images are effectively removed, image clarity is improved, and a high-quality data foundation is established for subsequent color feature extraction. Secondly, the preprocessed image is converted to the HSV color space and divided into subregions. The color histogram and statistical features are combined to generate a multidimensional feature vector. This can capture the distribution characteristics and statistical laws of colored gemstone colors from multiple angles, enhancing the ability to distinguish gemstones of similar hues. Furthermore, the multidimensional feature vectors are normalized to eliminate the influence of feature dimension differences. At the same time, the optimal clustering parameters are dynamically matched according to the data distribution, avoiding classification bias caused by traditional static thresholds and improving the algorithm's adaptability to the color distribution of different colored gemstone categories. Finally, DBScan density clustering is performed based on the optimal neighborhood radius and the standardized feature matrix. It can achieve natural clustering based on the spatial density distribution of data points, effectively addressing the multi-angle color rendering differences caused by the optical properties of colored gemstones, and making the generated color classification results more in line with actual quality grading requirements.

[0062] In one embodiment, each colored gemstone image is cropped, spliced, and subjected to noise reduction processing to generate a pre-processed image, including:

[0063] Crop each colored gemstone image according to a preset rectangular frame to obtain each cropped gemstone image;

[0064] According to the preset splicing rules, the cropped gemstone images are spliced ​​together to obtain a composite image;

[0065] A Gaussian filter device is used to perform Gaussian filtering on the synthetic image to obtain a preprocessed image, wherein the radius of the filter is 3 and the standard deviation is 1.5.

[0066] Specifically, the preset rectangular frame can be a 224×224 pixel frame. Using this preset rectangular frame, the six captured colored gemstone images are cropped. Specifically, the image is expanded from the geometric center of the colored gemstone to a 224×224 pixel range, ensuring that the gemstone's primary facets are contained within the cropping frame. The target image for stitching can then be defined as a 762×448 pixel image with a black background, denoted as image0. Schematically, the cropped gemstone images can be arranged from left to right and top to bottom in the order in which they were captured. Images 1-2 are front-facing images from the first and second angles, positioned at the top left corner (0,0) of image0; images 3-4 are front-facing images from the third and fourth angles, positioned at the top right; and images 5-6 are back-lit images, positioned at the bottom, forming a 2-row, 3-column matrix. A 10-pixel black gap is maintained between adjacent images. A 3×3 Gaussian filter can then be used to convolve the composite image image0. The radius is 3, meaning the convolution kernel size is 7×7. This covers the typical sizes of dust particles and illumination noise, while also preventing color edge blurring caused by an excessively large kernel size. A standard deviation of 1.5 ensures that the Gaussian function has a weight of 0.368 at the center pixel, while weights for edge pixels decrease with distance. This suppresses high-frequency noise while preserving color gradient detail. The resulting denoised preprocessed image lays the data foundation for subsequent high-precision color sorting.

[0067] In one embodiment, converting the preprocessed image to the HSV color space to generate an HSV image includes:

[0068] Normalize the RGB channel values ​​of each pixel of the preprocessed image to obtain a normalized RGB value;

[0069] According to the maximum channel value type judgment rule, the hue value of the normalized RGB value is calculated to obtain the hue component of each pixel;

[0070] If the maximum channel value of the normalized RGB value is 0, the saturation is determined to be 0. Otherwise, the saturation calculation is performed on the normalized RGB value using a preset saturation calculation formula to obtain the saturation component of each pixel.

[0071] The maximum channel value in the normalized RGB value is used as the brightness value to obtain the brightness component of each pixel;

[0072] Generate an HSV image based on the hue component, saturation component, and lightness component.

[0073] Specifically, for preprocessed images, the RGB color channel values ​​can be converted from the integer range of [0, 255] to the floating-point range of [0, 1] to reduce the impact of numerical range differences on subsequent calculations. Subsequently, different calculations can be performed based on the type of maximum channel value to obtain the hue component of each pixel. For example, if the maximum channel value in R, G, or B equals the minimum channel value, the hue is 0, indicating a colorless image. The calculated hue value is then multiplied by 60 to bring it within the range of 0-360 degrees to obtain the hue component. This hue calculation converts color information in the RGB color space into a color type description that is closer to human visual perception, facilitating subsequent color classification and analysis. Furthermore, if the maximum channel value of the normalized RGB values ​​is 0, the saturation is 0, indicating a gray color. Otherwise, a preset saturation calculation formula, such as 1-(minimum channel value / maximum channel value), can be used to obtain the saturation component. The saturation component reflects the color purity, namely the proportion of gray in the color. High saturation indicates a bright color, while low saturation indicates a color closer to gray. The saturation component helps to distinguish the difference in color intensity.

[0074] Furthermore, lightness represents the brightness of a color. The maximum channel value in the normalized RGB values ​​can be directly used as the lightness value to obtain the lightness component of each pixel. This lightness component reflects the brightness of the color, helping to account for the effects of lighting and brightness variations in color analysis. Finally, based on the hue, saturation, and lightness components, an HSV image can be generated. This HSV image reorganizes and represents the color information of the RGB image, making it more suitable for color feature extraction and analysis. Furthermore, in the color sorting of colored gemstones, the HSV color space can more effectively capture subtle color differences, improving the accuracy and adaptability of color classification.

[0075] In one embodiment, the HSV image is divided into multiple sub-regions, and the color histogram features and statistical features of each sub-region are extracted and fused to generate a multi-dimensional feature vector, including:

[0076] According to the preset rectangular coordinate parameters, the HSV image is cropped to obtain 6 sub-regions;

[0077] According to the pixel distribution of each sub-region, the histogram statistical processing of the hue channel, saturation channel and brightness channel is performed respectively to obtain the color histogram features of each channel;

[0078] Based on the color histogram features, the mean and standard deviation of each channel are calculated to obtain statistical features;

[0079] According to the preset feature fusion rules, the color histogram features and statistical features are spliced ​​together to obtain a multi-dimensional feature vector.

[0080] Specifically, the coordinates and sizes of six rectangular regions can be preset based on the shape and characteristic distribution of the colored gemstone, ensuring that each subregion captures the key characteristics of the gemstone's color. The HSV image can then be divided into six subregions according to the preset rectangular coordinate parameters. The HSV image includes a hue channel, a saturation channel, and a lightness channel. For each channel in each subregion, the distribution of pixel values ​​at each grayscale level can be calculated to obtain a color histogram feature. This color histogram feature can reflect the pixel distribution of each subregion across different color channels, providing rich color feature information. Based on this color histogram feature, the mean and standard deviation of each channel can then be calculated. The mean represents the central tendency of the color distribution, while the standard deviation represents the degree of dispersion of the color distribution. Using the mean and standard deviation as statistical features can describe the central tendency and degree of dispersion of the color distribution, providing a statistical description of the color features and enhancing the ability to distinguish color features.

[0081] The color histogram and statistical features of each channel are normalized to eliminate the effects of differences in pixel number and dimension. The normalized color histogram and statistical features are then concatenated according to pre-set feature fusion rules to form a multidimensional feature vector. This vector provides a richer description of color features, providing high-quality feature input for subsequent clustering analysis and color classification.

[0082] In one embodiment, the neighborhood radius of the DBScan algorithm is determined by adaptive optimization to obtain the optimal neighborhood radius, including:

[0083] Define the minimum candidate value and the maximum candidate value of the neighborhood radius, set the search space of the neighborhood radius based on the minimum candidate value and the maximum candidate value, and set the search step size;

[0084] Taking maximizing the number of effective clusters as the optimization goal, an optimization function is constructed based on the search space and optimization goal:

[0085] According to the optimization function, the gradient descent method is used to iteratively calculate in the search space, and the optimal neighborhood radius is solved by the following formula:

[0086]

[0087] Among them, ε * is the optimal neighborhood radius obtained by solving, ε is the neighborhood radius, ε' is the candidate parameter set of the neighborhood radius ε, and C(ε) is the number of valid clusters.

[0088] Specifically, by analyzing the distribution range of the color characteristics of colored gemstones, the minimum value of the neighborhood radius can be set to 0.05 and the maximum value to 1.0, and the search step size can be set to divide the search space of the neighborhood radius. The search step size can be adjusted according to actual needs, for example, set to 0.05. Based on the minimum value, maximum value and step size, the search space of the neighborhood radius can be constructed. Subsequently, the optimization function can be constructed with the goal of maximizing the number of effective clusters, that is, increasing the number of clusters in the clustering results and ensuring the rationality of the clustering. Based on this function, starting from the minimum value in the search space, for each neighborhood radius value, the DBScan algorithm can be applied to calculate the effective number of clusters, and the neighborhood radius can be updated according to the gradient direction, gradually moving to the peak of the optimization function. When the maximum number of iterations is reached or the change in the neighborhood radius is less than the set threshold, the iteration can be stopped to obtain the optimal neighborhood radius. Schematically, this process can use the gradient descent method to iteratively calculate the optimal value of the neighborhood radius in the search space, that is, by calculating the gradient of the optimization function, the neighborhood radius is gradually adjusted until the neighborhood radius value that maximizes the number of clusters is found. By maximizing the number of effective clusters, this adaptive optimization method can ensure that the DBScan algorithm can generate the most reasonable clustering results under different neighborhood radii, thereby improving the accuracy of colored gemstone color classification, reducing the uncertainty of manually set parameters, reducing clustering errors caused by improper parameter selection, and enhancing the robustness of color classification.

[0089] In one embodiment, the DBScan algorithm is used to perform density clustering based on the optimal neighborhood radius and the standardized feature matrix to generate color classification results, including:

[0090] Obtain the preset minimum number of samples, and for each sample point in the standardized feature matrix, count the number of samples in the neighborhood corresponding to the optimal neighborhood radius;

[0091] If the number of samples is greater than the preset minimum number of samples, the corresponding sample points are determined to be core points, and a core point set is generated;

[0092] Select an unmarked core point from the core point set, traverse the unmarked sample points in the neighborhood of the corresponding optimal neighborhood radius of the unmarked core point, mark the points in the unmarked sample points that meet the sample number greater than the preset minimum number as new core points, and recursively traverse the samples in the neighborhood of the optimal neighborhood radius corresponding to the new core point until no updated core points are added, and generate the maximum set of density-connected samples as the density cluster;

[0093] Store each density cluster in the corresponding folder and generate color classification results.

[0094] Specifically, before clustering, a minimum sample number threshold can be preset, such as MinPts=10, to determine whether a sample point is a core point, that is, whether the neighborhood of the point contains enough sample points to form the basis of a cluster. Then, for each sample point in the standardized feature matrix, the optimal neighborhood radius determined previously can be used to count the number of samples in its neighborhood. The neighborhood is defined as all sample points in the area with the sample point as the center and a radius of the optimal neighborhood radius, including core points, boundary points, and noise points, as shown in the following formula:

[0095] N ε (p)={q∈F′∣||pq||2≤ε}

[0096] Among them, N ε (p) represents the neighborhood with the target sample point p as the center and the neighborhood radius ε, ε is the optimal neighborhood radius, p is the target sample point, and p belongs to the standardized feature vector set, q is the sample point in the neighborhood, that is, the sample that satisfies the Euclidean distance ≤ ε from the target sample point p.

[0097] If the number of samples within a sample point's neighborhood exceeds a preset minimum number of samples (MinPts), the sample point is identified as a core point. This core point is key to cluster formation and is located at the center of a data-dense area. All sample points identified as core points are collected to form a core point set. This core point set forms the basis for subsequent cluster generation, with each cluster containing at least one core point. This set enables the DBScan algorithm to identify potential clustering structures in the data, laying the foundation for expanding the core point's neighborhood and forming clusters.

[0098] An unlabeled core point is selected from the core point set as the starting point. Schematically, all core points are initially unlabeled. New core points are obtained by traversing all unlabeled sample points within the optimal neighborhood radius of the unlabeled core point and adding them to the core point set. For each newly labeled core point, the sample points within its neighborhood are recursively traversed, continuing to search for new core points that meet the criteria until no new core points are added. This process forms a maximal set of density-connected samples, known as a density cluster. This process generates clusters based on density connectivity, allowing clusters to have arbitrary shapes. This overcomes the limitation of traditional clustering algorithms, which can only detect spherical clusters. It also automatically identifies the natural clustering structure of colored gemstones and adapts to the complexity of diverse color distributions. By storing each generated density cluster in a corresponding folder, the final color classification result is generated. This classification result clearly identifies the color category of each colored gemstone, providing a scientific basis for subsequent gemstone grading, pricing, and quality control.

[0099] like Figure 2 As shown, based on the same inventive concept, the embodiment of the present application also provides a system 200 for high-precision color sorting of colored gemstones based on machine vision for implementing the above-mentioned method for high-precision color sorting of colored gemstones based on machine vision. The implementation scheme for solving the problem provided by this system is similar to the implementation scheme described in the above-mentioned method. Therefore, the specific limitations of one or more embodiments of the system for high-precision color sorting of colored gemstones based on machine vision provided below can be referred to the limitations of the method for high-precision color sorting of colored gemstones based on machine vision above, and will not be repeated here. The system includes:

[0100] The image preprocessing module 201 is used to obtain multiple colored gemstone images, and perform cropping, splicing and noise reduction on each colored gemstone image to generate a preprocessed image;

[0101] The feature space conversion and extraction module 202 is used to convert the pre-processed image into the HSV color space to generate an HSV image, and divide the HSV image into multiple sub-regions, extract and fuse the color histogram features and statistical features of each sub-region, and generate a multi-dimensional feature vector;

[0102] The feature standardization and parameter optimization module 203 is used to standardize the multi-dimensional feature vector to obtain a standardized feature matrix, and to determine the neighborhood radius of the DBScan algorithm through adaptive optimization to obtain the optimal neighborhood radius;

[0103] The density clustering classification module 204 is used to perform density clustering processing using the DBScan algorithm according to the optimal neighborhood radius and the standardized feature matrix to generate a color classification result.

[0104] In the above system, the image preprocessing module 201 can effectively remove interference information from the image and integrate the image content by acquiring multiple colored gemstone images and performing cropping, splicing, and noise reduction processing on them, making the image more regular and clear, thereby providing a high-quality image foundation for subsequent color feature extraction. The feature space conversion and extraction module 202 converts the preprocessed image into the HSV color space, which can better separate color information and brightness information, making the color features more prominent. It also divides the image into multiple sub-regions, extracts and fuses the color histogram features and statistical features of each sub-region, and can comprehensively consider the local differences and overall characteristics of the colored gemstone color, avoiding the one-sidedness that may be caused by a single feature extraction method, thereby more comprehensively characterizing the color characteristics of the colored gemstone. The feature standardization and parameter optimization module 203 normalizes the multidimensional feature vectors, eliminating dimensional differences and data distribution differences between different feature dimensions. It also uses adaptive optimization to determine the neighborhood radius of the DBScan algorithm, dynamically adjusting parameters based on the actual distribution of the colored gemstone's color features. This avoids the inaccurate clustering that can result from fixed parameters, enabling the DBScan algorithm to better adapt to the complex distribution of colored gemstone color data and improving clustering accuracy and reliability. The density clustering classification module 204, based on the optimal neighborhood radius and the standardized feature matrix, employs the DBScan algorithm for density clustering, accurately classifying colored gemstones and achieving high-precision color sorting, generating color classification results.

[0105] In an exemplary embodiment, the present invention further provides a computer device comprising a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of the present invention's method for high-precision color sorting of colored gemstones based on machine vision. A multi-core processor is preferred to improve the system's parallel processing capabilities. The memory provides sufficient temporary storage space to support program execution and data processing. The memory capacity should be large enough to accommodate large amounts of supply information and computing tasks.

[0106] In an exemplary embodiment, the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a method for high-precision color sorting of colored gemstones based on machine vision of the present application.

[0107] The above-described embodiments merely represent several implementation methods of the embodiments of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that a person skilled in the art may make various modifications and improvements without departing from the concept of the embodiments of the present application, and these modifications and improvements fall within the scope of protection of the embodiments of the present application.

Claims

1. A high-precision color sorting method for colored gemstones based on machine vision, characterized in that: The method comprises: Acquire multiple colored gemstone images, and perform cropping, splicing, and noise reduction on each of the colored gemstone images to generate a preprocessed image; Converting the preprocessed image into an HSV color space to generate an HSV image, dividing the HSV image into a plurality of sub-regions, extracting and fusing the color histogram features and statistical features of each of the sub-regions to generate a multidimensional feature vector; Normalizing the multidimensional feature vector to obtain a normalized feature matrix, and determining the neighborhood radius of the DBScan algorithm through adaptive optimization to obtain an optimal neighborhood radius; According to the optimal neighborhood radius and the standardized feature matrix, the DBScan algorithm is used to perform density clustering processing to generate a color classification result.

2. The method according to claim 1, characterized in that The step of performing density clustering processing using the DBScan algorithm according to the optimal neighborhood radius and the standardized feature matrix to generate a color classification result includes: Obtaining a preset minimum number of samples, and for each sample point in the standardized feature matrix, counting the number of samples in the neighborhood corresponding to the optimal neighborhood radius; If the sample number is greater than the preset minimum sample number, the corresponding sample point is determined to be a core point, and a core point set is generated; An unmarked core point is selected from the core point set, and unmarked sample points in the neighborhood of the optimal neighborhood radius corresponding to the unmarked core point are traversed, and points in the unmarked sample points that satisfy the requirement that the number of samples is greater than the preset minimum number of samples are marked as new core points, and samples in the neighborhood of the optimal neighborhood radius corresponding to the new core point are recursively traversed until no updated core points are added, thereby generating a maximum set of density-connected samples as a density cluster; Each of the density clusters is stored in a corresponding folder to generate the color classification result.

3. The method according to claim 1, characterized in that Converting the pre-processed image to the HSV color space to generate an HSV image includes: Performing RGB channel value normalization processing on each pixel of the preprocessed image to obtain a normalized RGB value; Calculating the hue value of the normalized RGB value according to the maximum channel value type determination rule to obtain the hue component of each pixel; If the maximum channel value of the normalized RGB value is 0, the saturation is determined to be 0; otherwise, the saturation is calculated and processed on the normalized RGB value using a preset saturation calculation formula to obtain the saturation component of each pixel; Taking the maximum channel value in the normalized RGB value as the brightness value, to obtain the brightness component of each pixel; The HSV image is generated according to the hue component, the saturation component, and the lightness component.

4. The method according to claim 1, wherein The HSV image is divided into a plurality of sub-regions, and the color histogram features and statistical features of each sub-region are extracted and fused to generate a multi-dimensional feature vector, including: Performing region cropping processing on the HSV image according to preset rectangular coordinate parameters to obtain the six sub-regions; According to the pixel distribution of each sub-region, performing histogram statistical processing on the hue channel, the saturation channel and the brightness channel respectively to obtain the color histogram features of each channel; Based on the color histogram feature, the mean and standard deviation of each channel are respectively obtained to obtain the statistical feature; According to a preset feature fusion rule, the color histogram feature and the statistical feature are spliced ​​together to obtain the multidimensional feature vector.

5. The method according to claim 1, characterized in that The method of determining the neighborhood radius of the DBScan algorithm through adaptive optimization to obtain the optimal neighborhood radius includes: defining a minimum candidate value and a maximum candidate value of the neighborhood radius, setting a search space for the neighborhood radius based on the minimum candidate value and the maximum candidate value, and setting a search step size; Taking maximizing the number of effective clusters as the optimization goal, constructing an optimization function based on the search space and the optimization goal; According to the optimization function, the gradient descent method is used to iteratively calculate in the search space, and the optimal neighborhood radius is solved by the following formula: Among them, ε * is the optimal neighborhood radius obtained by solving, ε is the neighborhood radius, and ε ' is the candidate parameter set of neighborhood radius ε, and C(ε) is the number of valid clusters.

6. The method according to claim 1, characterized in that The step of cropping, splicing and noise reduction processing the colored gemstone images to generate pre-processed images includes: Cropping each of the colored gemstone images according to a preset rectangular frame to obtain each cropped gemstone image; According to the preset splicing rules, the cropped gemstone images are spliced ​​together to obtain a composite image; A Gaussian filter device is used to perform Gaussian filtering on the composite image to obtain the preprocessed image, wherein the radius of the filter is 3 and the standard deviation is 1.

5.

7. The method according to claim 2, characterized in that The neighborhood corresponding to the optimal neighborhood radius is: N ε (p)={q∈F′∣||p-q||2≤ε} Among them, N ε (p) represents a neighborhood with a neighborhood radius of ε centered on the target sample point p, where ε is the optimal neighborhood radius, p is the target sample point, and p belongs to the set of standardized feature vectors, and q is a sample point in the neighborhood, that is, a sample that satisfies the Euclidean distance ≤ ε from the target sample point p.

8. A high-precision color sorting system for colored gemstones based on machine vision, characterized in that: The system comprises: An image preprocessing module is used to obtain multiple colored gemstone images, and perform cropping, splicing and noise reduction on each of the colored gemstone images to generate a preprocessed image; A feature space conversion and extraction module is used to convert the preprocessed image into the HSV color space to generate an HSV image, and divide the HSV image into multiple sub-regions, extract and fuse the color histogram features and statistical features of each sub-region, and generate a multidimensional feature vector; A feature standardization and parameter optimization module is used to standardize the multidimensional feature vector to obtain a standardized feature matrix, and to determine the neighborhood radius of the DBScan algorithm through adaptive optimization to obtain the optimal neighborhood radius; The density clustering classification module is used to perform density clustering processing using the DBScan algorithm according to the optimal neighborhood radius and the standardized feature matrix to generate a color classification result.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.