Image color difference detection method and system for industrial production
By converting the solid color image to be detected from the RGB color space to the HSV and CIELAB color space, and combining local statistical characteristics and adaptive threshold calculation technology, the problem of low image color mixing detection accuracy and poor robustness in the prior art is solved. It achieves efficient and accurate color mixing detection effect.
Patent Information
- Application Number
- CN202411605638.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-11-12
AI Technical Summary
The existing image color mixing detection methods are not very accurate, have poor robustness, and have high computing resources and time costs when dealing with complex backgrounds and multiple color interferences.
By converting the solid color image to be detected from the RGB color space to the HSV and CIELAB color space, combining local statistical characteristics and adaptive threshold calculation technology, efficient and accurate color mixing detection is achieved.
This method can more comprehensively analyze image color characteristics, improve detection robustness and accuracy, and reduce computing resources and time costs.
Smart Images

Figure CN119131027B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of image color mixing detection, and in particular relates to an image color difference detection method and system for industrial production. Background Art
[0002] With the development of image processing technology, pure color images have been widely used in various fields, such as printing, textile, coating and other industries. However, in the actual production and application process, color mixing often occurs in pure color images, which not only affects the quality of the product, but also may cause serious economic losses;
[0003] Traditional color mixing detection methods mainly rely on manual detection, which is not only inefficient, but also easily affected by subjective factors, making it difficult to ensure the accuracy of the detection results. With the development of computer vision technology, automated color mixing detection methods based on image processing have gradually become a research hotspot. These methods are usually implemented based on color space conversion, feature extraction and classification algorithms. However, when dealing with complex backgrounds and multiple color interferences, existing methods often have problems such as low detection accuracy and poor robustness. Public patent CN 117853756 A provides a color mixing detection method in a pure color image, first preprocessing the image of color mixing detection, and then further optimizing the processed image; then adding a smoothing effect to the color feature; then generating a mask in the HSV color space; finally, calculating the color difference of the acquired image features; starting from the human eye's perception of color, simulating the process of the human eye's recognition and judgment of the color mixing image, converting the color mixing detection screens of different colors into the color difference threshold of the human eye's color perception, and fine-tuning the threshold to achieve color mixing defect detection of different color screens, but this method requires high computing resources and time costs.
[0004] Therefore, how to effectively detect the color mixing phenomenon in pure color images has become an urgent problem to be solved in the field of image color mixing detection technology. Summary of the invention
[0005] The purpose of the present invention is to provide an image color difference detection method and system for industrial production, which provides an efficient, accurate and robust pure color image color mixing detection method through multi-color space conversion and adaptive threshold calculation technology.
[0006] In a first aspect, the present invention provides an industrial production image color difference detection method for detecting a mixed color area in a pure color image, the method comprising the following steps:
[0007] Step S1, converting the pure color image to be detected from the RGB color space to the HSV color space and the CIELAB color space respectively, to obtain a first pure color image to be detected and a second pure color image to be detected.
[0008] Furthermore, the pure color image to be detected is converted from the RGB color space to the HSV color space and the CIELAB color space respectively, wherein the conversion from the RGB color space to the HSV color space to obtain the first pure color image to be detected adopts the following formula:
[0009] ;
[0010] ;
[0011] ;
[0012] H is hue, which indicates the type of color, expressed as an angle, ranging from 0° to 360°; S is saturation, which indicates the purity or intensity of the color, ranging from 0 to 1; V is lightness, which indicates the brightness of the color, ranging from 0 to 1; R, G, B represent the three color components of red, green, and blue, ranging from 0 to 1. Represents the maximum value of the three color components, Indicates the minimum value of the three color components.
[0013] Furthermore, the RGB color space is converted to the CIELAB color space to obtain the second pure color image to be detected using the following formula:
[0014] ;
[0015] in, , ; L represents the lightness in the CIELAB color space, a represents the position of the color on the red-green axis, and b represents the position of the color on the yellow-blue axis. Represents the average value of RGB color components, which is the weighted average of RGB quantities; Indicates that the corrected Values used to convert to CIELAB color space.
[0016] Step S2, extracting the hue, saturation and brightness information in the first pure color image to be detected, calculating the color difference of each pixel in the first pure color image to be detected, and marking the area where the color difference is greater than the first adaptive threshold as the first area.
[0017] Furthermore, in step S2, the specific process of calculating the color difference of each pixel in the first pure color image to be detected based on the local statistical characteristics is:
[0018] For each pixel , its hue , Saturation and brightness ; Define pixel points The local neighborhood , calculate the average hue in the local neighborhood , Saturation and brightness :
[0019] ;
[0020] Then the pixel Hue difference , Saturation difference and brightness difference It is expressed as:
[0021] ;
[0022] Then the pixel Comprehensive color difference The calculation formula is:
[0023] ;
[0024] The area where the color difference is greater than the first adaptive threshold is marked as the first area. The calculation formula is: ;in, is the weight coefficient, which controls the influence of the color difference standard deviation on the adaptive threshold. between; is the standard deviation of the color difference:
[0025] ;
[0026] is the average value of the color difference in the local neighborhood: ; is the bias term, .
[0027] Step S3, filter and optimize the first area in the second pure color image to be detected, extract the L, a, and b components in the first area after filtering, calculate the color difference of each pixel in the first area of the second pure color image to be detected, obtain an optimized mixed color detection result, compare the optimized mixed color detection result with the second adaptive threshold, and mark the mixed color area.
[0028] Furthermore, in step S3, the first region in the second pure color image to be detected is subjected to filtering optimization by using Gaussian filtering:
[0029] ;
[0030] in, is the weight of the Gaussian filter, and the weight center is set at Location, along with and As increases, the weight gradually decreases; is the standard deviation, controlling the width of the filter, Indicates the horizontal offset of the filter. Indicates the vertical offset of the filter.
[0031] Furthermore, in step S3, the L, a, and b components in the filtered first area are extracted, and the color difference of each pixel in the first area of the second pure color image to be detected is calculated, specifically:
[0032] For each pixel , using the same local neighborhood as the HSV color space , the pixel point in the first area after filtering The L, a, and b components are , then the average component in the local neighborhood The calculation formula is:
[0033] ;
[0034] ;
[0035] ;
[0036] Calculate the covariance matrix :
[0037] ;
[0038] The calculation formula of the covariance term is:
[0039] ;
[0040] ;
[0041] ;
[0042] ;
[0043] ;
[0044] ;
[0045] Define the difference vector: ;
[0046] Then, the pixel points in the first area Color difference in CIELAB color space :
[0047] ; The pixel points in the first area Color difference in CIELAB color space As the optimized color mixing detection result.
[0048] Furthermore, in step S3, the optimized color mixing detection result is compared with the second adaptive threshold value to mark the color mixing area; wherein the second adaptive threshold value The calculation formula is: ;in, is the influence of the standard deviation of color difference in CIELAB color space on the adaptive threshold, and its value range is [0, 1]; is the standard deviation of the color difference in CIELAB color space: ; is the average value of the color difference in the local neighborhood of the CIELAB color space: , is the second bias term, .
[0049] Further, The area is marked as the mixed color area, which is the final detection result.
[0050] In a second aspect, the present invention provides an industrial production image color difference detection system, which is used to perform an industrial production image color difference detection method according to the first aspect, wherein the system comprises: a color space conversion module, a color difference region marking module, and a mixed color region marking module connected in sequence;
[0051] Furthermore, the color space conversion module is used to convert the pure color image to be detected from the RGB color space to the HSV color space and the CIELAB color space respectively, to obtain a first pure color image to be detected and a second pure color image to be detected;
[0052] The color difference region marking module is used to extract the hue, saturation and brightness information in the first pure color image to be detected, calculate the color difference of each pixel in the first pure color image to be detected, and mark the region where the color difference is greater than the first adaptive threshold as the first region;
[0053] The mixed color area marking module is used to filter and optimize the first area in the second pure color image to be detected, extract the L, a, and b components in the filtered first area, calculate the color difference of each pixel in the first area of the second pure color image to be detected, obtain an optimized mixed color detection result, compare the optimized mixed color detection result with the second adaptive threshold, and mark the mixed color area.
[0054] Furthermore, the color space conversion module includes: an HSV conversion unit, a CIELAB conversion unit, and a data cache unit; the HSV conversion unit is used to convert the pure color image to be detected from the RGB color space to the HSV color space to obtain a first pure color image to be detected; the CIELAB conversion unit is used to convert the pure color image to be detected from the RGB color space to the CIELAB color space to obtain a second pure color image to be detected; the data cache unit is used to temporarily store intermediate data and conversion results during the conversion process.
[0055] Among them, the HSV conversion unit and the CIELAB conversion unit process the space conversion of the pure color image in parallel when working.
[0056] Furthermore, the system also includes: an image preprocessing module, a detection result output module;
[0057] The image preprocessing module is arranged before the color space conversion module, and is used for performing noise reduction and enhancement processing on the pure color image to be detected;
[0058] The detection result output module is connected to the mixed color area marking module, and is used to visualize the marked mixed color area and output a detection report, which at least includes: the position, area, and color difference information of the mixed color area.
[0059] Furthermore, the system also includes: a parameter adaptive adjustment module, which is used to dynamically adjust the weight coefficients α, γ and bias terms β, δ in the first adaptive threshold and the second adaptive threshold according to the detection result.
[0060] Compared with the prior art, the present invention has the following beneficial effects:
[0061] By combining the advantages of HSV and CIELAB color spaces, the present invention can more comprehensively analyze the color characteristics of images and effectively distinguish between mixed color areas and normal color changes; by adopting local statistical characteristics and adaptive threshold processing, it can automatically adapt to different images and lighting conditions and improve the robustness of detection; the detection method of the present invention is efficient and accurate, and has broad application prospects and practical value. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1This is a flow chart of a method for detecting color difference of an image for industrial production according to the present invention;
[0063] Figure 2 The figure is a schematic diagram of the composition of an image color difference detection system for industrial production of the present invention. DETAILED DESCRIPTION
[0064] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention is described clearly and completely below. Obviously, the described implementation mode is a part of the present invention, not all implementation modes. Based on the implementation modes of the present invention, all other implementation modes obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. Example 1
[0065] like Figure 1 As shown, an industrial production image color difference detection method of the present invention is used to detect mixed color areas in pure color images. The method mainly includes image color space conversion, preliminary mixed color detection in HSV color space, filtering optimization and final mixed color detection in CIELAB color space; through the comprehensive utilization of multiple color spaces, the color changes in the image can be better captured and the sensitivity of mixed color detection can be improved.
[0066] In a specific embodiment, the method comprises the following steps:
[0067] Step S1, converting the pure color image to be detected from the RGB color space to the HSV color space and the CIELAB color space respectively, to obtain a first pure color image to be detected and a second pure color image to be detected.
[0068] It should be noted that the RGB color space is one of the most commonly used color spaces, but it has certain limitations when processing color differences; the HSV color space has better performance in color representation and processing, especially in color difference calculation and color consistency; therefore, the pure color image to be detected is first converted from the RGB color space to the HSV color space.
[0069] The pure color image to be detected is converted from the RGB color space to the HSV color space and the CIELAB color space respectively, wherein the conversion from the RGB color space to the HSV color space to obtain the first pure color image to be detected adopts the following formula:
[0070] ;
[0071] ;
[0072] ;
[0073] H is hue, which indicates the type of color, expressed as an angle, ranging from 0° to 360°; S is saturation, which indicates the purity or intensity of the color, ranging from 0 to 1; V is value, which indicates the brightness of the color, ranging from 0 to 1; R, G, B represent the three color components of red, green, and blue, ranging from 0 to 1. Represents the maximum value of the three color components, Indicates the minimum value of the three color components.
[0074] It should be noted that the CIELAB color space has good performance in color difference calculation, so the pure color image to be detected is converted from the RGB color space to the CIELAB color space; from the RGB color space to the CIELAB color space, the second pure color image to be detected is obtained using the following formula:
[0075] ;in, , ; L represents the lightness in the CIELAB color space, a represents the position of the color on the red-green axis, and b represents the position of the color on the yellow-blue axis. Represents the average value of RGB color components, which is the weighted average of RGB quantities; Indicates that the corrected Values used to convert to CIELAB color space.
[0076] Step S2, extracting the hue, saturation and brightness information in the first pure color image to be detected, calculating the color difference of each pixel in the first pure color image to be detected, and marking the area where the color difference is greater than the first adaptive threshold as the first area.
[0077] In step S2, the specific process of calculating the color difference of each pixel in the first pure color image to be detected based on the local statistical characteristics is:
[0078] For each pixel ,tone , Saturation and brightness ; Define pixel points The local neighborhood , calculate the average hue in the local neighborhood , Saturation and brightness :
[0079] ; then the pixel Hue difference , Saturation difference and brightness difference It is expressed as:
[0080] ;
[0081] Then the pixel Comprehensive color difference The calculation formula is: ; Mark the area where the color difference is greater than the first adaptive threshold as the first area, and the first adaptive threshold The calculation formula is:
[0082] ;in, is the weight coefficient, which controls the influence of the color difference standard deviation on the adaptive threshold. between; is the standard deviation of the color difference: ; is the average value of the color difference in the local neighborhood: ; is the bias term, .
[0083] Step S3, filter and optimize the first area in the second pure color image to be detected, extract the L, a, and b components in the first area after filtering, calculate the color difference of each pixel in the first area of the second pure color image to be detected, obtain an optimized mixed color detection result, compare the optimized mixed color detection result with the second adaptive threshold, and mark the mixed color area.
[0084] In step S3, the first area in the second pure color image to be detected is filtered and optimized using Gaussian filtering:
[0085] ;in, is the weight of the Gaussian filter, and the weight center is set at Location, along with and As increases, the weight gradually decreases; is the standard deviation, controlling the width of the filter, Indicates the horizontal offset of the filter. Indicates the vertical offset of the filter.
[0086] In step S3, the L, a, and b components in the filtered first area are extracted, and the color difference of each pixel in the first area of the second pure color image to be detected is calculated. Specifically, for each pixel , using the same local neighborhood as the HSV color space , the pixel point in the first area after filtering The L, a, and b components are , then the average L, a, and b components in the local neighborhood The calculation formula is:
[0087] ;
[0088] Calculate the covariance matrix : ; The calculation formula of the covariance term is:
[0089] ;
[0090] ;
[0091] ;
[0092] ;
[0093] ;
[0094] ;
[0095] Define the difference vector: Then, the pixel points in the first area Color difference in CIELAB color space : ; The pixel points in the first area Color difference in CIELAB color space As the optimized color mixing detection result.
[0096] In step S3, the optimized color mixing detection result is compared with the second adaptive threshold value to mark the color mixing area; wherein the second adaptive threshold value The calculation formula is: ;in, is the influence of the standard deviation of color difference in CIELAB color space on the adaptive threshold, and its value range is [0, 1]; is the standard deviation of the color difference in CIELAB color space: ; is the average value of the color difference in the local neighborhood of the CIELAB color space: , is the second bias term, .
[0097] Will The area is marked as the mixed color area, which is the final detection result.
[0098] By combining the characteristics of HSV and CIELAB color spaces, this method can comprehensively utilize their advantages in color representation and detection. The HSV color space is used to quickly screen areas where color mixing may exist, while the CIELAB color space is used to perform fine detection and verification of the screened areas. This combination not only improves the detection efficiency, but also ensures the accuracy and reliability of the detection results. Example 2
[0099] like Figure 2 As shown, the present invention provides an industrial production image color difference detection system, which is used to execute an industrial production image color difference detection method described in Example 1. The system includes: a color space conversion module, a color difference area marking module, and a mixed color area marking module connected in sequence.
[0100] The color space conversion module is used to convert the pure color image to be detected from the RGB color space to the HSV color space and the CIELAB color space respectively, to obtain a first pure color image to be detected and a second pure color image to be detected; the color difference area marking module is used to extract the hue, saturation and brightness information in the first pure color image to be detected, calculate the color difference of each pixel in the first pure color image to be detected, and mark the area where the color difference is greater than the first adaptive threshold as the first area; the mixed color area marking module is used to filter and optimize the first area in the second pure color image to be detected, extract the L, a, and b components in the filtered first area, calculate the color difference of each pixel in the first area of the second pure color image to be detected, obtain the optimized mixed color detection result, compare the optimized mixed color detection result with the second adaptive threshold, and mark the mixed color area.
[0101] The color space conversion module includes: an HSV conversion unit, a CIELAB conversion unit, and a data cache unit; the HSV conversion unit is used to convert the pure color image to be detected from the RGB color space to the HSV color space to obtain a first pure color image to be detected; the CIELAB conversion unit is used to convert the pure color image to be detected from the RGB color space to the CIELAB color space to obtain a second pure color image to be detected; the data cache unit is used to temporarily store intermediate data and conversion results in the conversion process.
[0102] Among them, the HSV conversion unit and the CIELAB conversion unit process the space conversion of the pure color image in parallel when working.
[0103] The system also includes: an image preprocessing module and a detection result output module; the image preprocessing module is arranged before the color space conversion module, and is used to perform noise reduction and enhancement processing on the pure color image to be detected; the detection result output module is connected to the mixed color area marking module, and is used to visualize the marked mixed color area and output a detection report, and the detection report at least includes: the position, area, and color difference information of the mixed color area.
[0104] The system also includes: a parameter adaptive adjustment module, which is used to dynamically adjust the weight coefficients α, γ and bias items β, δ in the first adaptive threshold and the second adaptive threshold according to the detection result.
[0105] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. An industrial production image color difference detection method for detecting mixed color areas in pure color images, characterized in that: The method comprises the following steps: Step S1, converting the pure color image to be detected from the RGB color space to the HSV color space and the CIELAB color space respectively, to obtain a first pure color image to be detected and a second pure color image to be detected; Step S2, extracting hue, saturation and brightness information from the first pure color image to be detected, calculating the color difference of each pixel in the first pure color image to be detected, and marking an area where the color difference is greater than a first adaptive threshold as a first area; The specific process of calculating the color difference of each pixel in the first pure color image to be detected based on the local statistical characteristics is as follows: For each pixel , its hue, saturation and lightness are expressed as: , and ,definition The local neighborhood of , then the average hue of the local neighborhood , average saturation and average brightness The calculation formula is: ; Then the pixel Hue difference , Saturation difference and brightness difference It is expressed as: ; Pixels Color difference The calculation formula is: ; The area where the color difference is greater than the first adaptive threshold is marked as the first area. The calculation formula is: ;in, is the weight coefficient, which controls the influence of the color difference standard deviation on the adaptive threshold, and its value range is between [0, 1]. is the standard deviation of the color difference: ; is the average value of the color difference in the local neighborhood: , is the bias term, ; Step S3, performing filtering optimization on the first area in the second pure color image to be detected, extracting L, a, and b components in the first area after filtering, calculating the color difference of each pixel in the first area of the second pure color image to be detected, obtaining an optimized mixed color detection result, comparing the optimized mixed color detection result with the second adaptive threshold, and marking the mixed color area; Extract the L, a, and b components in the filtered first area, and calculate the color difference of each pixel in the first area of the second pure color image to be detected, specifically: For each pixel , using the same local neighborhood as the HSV color space , the pixel point in the first area after filtering The L, a, and b components are expressed as , then the average component in the local neighborhood The calculation formula is: ; Let the covariance matrix , difference vector: ; Then, the pixel points in the first area Color difference in CIELAB color space : ; The pixel points in the first area Color difference in CIELAB color space As the optimized color mixing detection result; The covariance matrix It is expressed as: ; The calculation formula for each covariance term is: ; ; ; ; ; 。 2. The method for detecting color difference of an image for industrial production according to claim 1, characterized in that: The pure color image to be detected is converted from the RGB color space to the HSV color space and the CIELAB color space respectively, wherein the conversion from the RGB color space to the HSV color space to obtain the first pure color image to be detected adopts the following formula: ; ; ; Among them, H is hue, which indicates the type of color, expressed in angles, ranging from 0° to 360°, S is saturation, which indicates the purity or intensity of the color, ranging from 0 to 1, V is lightness, which indicates the brightness of the color, ranging from 0 to 1, R, G, B represent the three color components of red, green, and blue, ranging from 0 to 1, Represents the maximum value of the three color components, Indicates the minimum value of the three color components.
3. The method for detecting color difference of an image for industrial production according to claim 2, characterized in that: In step S3, the first area in the second pure color image to be detected is filtered and optimized using Gaussian filtering: ;in, is the weight of the Gaussian filter, and the weight center is set at Location, along with and As increases, the weight gradually decreases; is the standard deviation, controlling the width of the filter, Indicates the horizontal offset of the filter. Indicates the vertical offset of the filter.
4. The method for detecting color difference of an image for industrial production according to claim 3, characterized in that: In step S3, the optimized color mixing detection result is compared with the second adaptive threshold value to mark the color mixing area; wherein the second adaptive threshold value The calculation formula is: ;in, is the influence of the standard deviation of color difference in CIELAB color space on the adaptive threshold, and its value range is [0, 1]; is the standard deviation of the color difference in CIELAB color space: ; is the average value of the color difference in the local neighborhood of the CIELAB color space: , is the second bias term, ;Will The area is marked as the mixed color area, which is the final detection result.
5. An industrial production image color difference detection system, used to execute the industrial production image color difference detection method according to any one of claims 1 to 4, characterized in that: The system comprises: a color space conversion module, a color difference area marking module, and a mixed color area marking module connected in sequence; The color space conversion module is used to convert the pure color image to be detected from the RGB color space to the HSV color space and the CIELAB color space respectively, to obtain a first pure color image to be detected and a second pure color image to be detected; The color difference region marking module is used to extract the hue, saturation and brightness information in the first pure color image to be detected, calculate the color difference of each pixel in the first pure color image to be detected, and mark the region where the color difference is greater than the first adaptive threshold as the first region; The mixed color area marking module is used to filter and optimize the first area in the second pure color image to be detected, extract the L, a, and b components in the filtered first area, calculate the color difference of each pixel in the first area of the second pure color image to be detected, obtain an optimized mixed color detection result, compare the optimized mixed color detection result with the second adaptive threshold, and mark the mixed color area.
6. The industrial production image color difference detection system according to claim 5, characterized in that: The color space conversion module includes: an HSV conversion unit, a CIELAB conversion unit, and a data cache unit; The HSV conversion unit is used to convert the pure color image to be detected from the RGB color space to the HSV color space to obtain a first pure color image to be detected; The CIELAB conversion unit is used to convert the pure color image to be detected from the RGB color space to the CIELAB color space to obtain a second pure color image to be detected; The data cache unit is used to temporarily store intermediate data and conversion results during the conversion process.
7. The industrial production image color difference detection system according to claim 6, characterized in that: The system also includes: an image preprocessing module and a detection result output module; The image preprocessing module is arranged before the color space conversion module, and is used for performing noise reduction and enhancement processing on the pure color image to be detected; The detection result output module is connected to the mixed color area marking module, and is used to visualize the marked mixed color area and output a detection report, which at least includes: the position, area, and color difference information of the mixed color area.
Citation Information
Patent Citations
Method for detecting mixed colors in pure-color image
CN117853756A
Defect detection method applied to presswork detection system
CN103808731A
Color mixing inspection method and device thereof
CN109448619A