Self-adaptive color filtering method under high-contrast background
By segmenting and equalizing the images under high contrast background, combined with adaptive color filtering technology, the problem of unstable processing effects in the existing technology under high contrast background is solved, and more reliable image processing results are achieved.
Patent Information
- Application Number
- CN202510425354.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-07
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2045-04-07
AI Technical Summary
The existing color filtering technology is susceptible to factors such as light source state and local shadows under high contrast backgrounds, resulting in unstable processing effects and affecting subsequent image processing flow and business efficiency.
By segmenting the images under high contrast backgrounds, dividing them into multiple sub-graphs of equal sizes, and equalizing the sub-graphs and adaptive color filtering, the image is processed using the color difference algorithm of adaptive thresholds, and finally the processing results are spliced into a binary graph of the original image.
It effectively reduces the interference of overexposure and shadow on image processing results, improves the flexibility of threshold adjustment, and improves the reliability of image processing results.
Smart Images

Figure CN119941595A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image processing, and in particular to an adaptive color filtering method under a high-contrast background. Background Art
[0002] Color filtering is one of the commonly used techniques in the field of image processing. Existing methods usually process the entire image by setting a fixed threshold, or divide the image into several intervals, set a processing threshold for each interval, and finally merge the processing results. However, the fixed threshold algorithm is easily affected by factors such as the light source state and local shadows, which greatly reduces the processing effect, thereby affecting the subsequent image processing process, reducing the overall business efficiency, and may even cause certain safety hazards. Therefore, in view of the defects of the prior art, it is necessary to propose a technical solution to solve the technical problems existing in the prior art. Summary of the invention
[0003] The purpose of the present invention is to provide an adaptive color filtering method under high-contrast background, which divides the image and performs equalization processing on the small images according to the sample space, and then performs color filtering on the image according to the color difference algorithm of the adaptive threshold, obtains a usable binary image and passes it to the subsequent processing flow, so as to solve the problems raised in the above-mentioned background technology.
[0004] In order to solve the above technical problems, the present invention provides the following technical solutions: an adaptive color filtering method under a high-contrast background, comprising the following steps:
[0005] S100: Segment the complete image with a high-contrast background into multiple sub-images of equal size;
[0006] Preferably, image segmentation needs to divide the complete image with a high-contrast background into multiple sub-images of equal size. When the product box grid image contains 72 small boxes, the image can be approximately divided into 72 sub-images based on the size of the small boxes, and the size of each sub-image can be slightly enlarged to ensure that each small box can fall completely in the sub-image.
[0007] S200: adjusting the HSV value of the pixel point in the sub-image to a standard HSV adjacent interval defined according to the equalization sample, and performing image equalization processing;
[0008] Preferably, performing image equalization processing specifically includes the following steps:
[0009] S201: Calculate the standard HSV: From the width , the height is The size of the balanced sample is The sampling space is used to calculate the HSV value of each pixel in the sampling space;
[0010] S202: Pixel equalization: Based on the sampling space, calculate the HSV mean of all sub-images in the sampling space, and subtract the sampled HSV value of each sub-image from the standard HSV to obtain the sampling offset vector of the sub-image. , adjust the HSV value of the sub-image pixel according to the sampling offset vector;
[0011] Preferably, calculating the HSV value of each pixel in the sampling space further includes: calculating the standard HSV according to the HSV of all pixels in the sampling space:
[0012]
[0013] in, Indicates the standard hue value, Indicates the standard saturation value, Indicates the standard brightness value, Indicates the position coordinates of the corresponding pixel. Indicates the number of pixels in the sample space.
[0014] Preferably, adjusting the HSV value of the sub-image pixel point according to the sampling offset vector includes: for a given tolerance threshold , when the condition is not met When , the color feature offset that does not meet the requirements is added to all pixels, that is, when , then for all pixels in the sub-image, their saturation will be updated to: .
[0015] S203: HSV to RGB conversion: The HSV values of the pixels after equalization are reconverted into RGB values and filled in the image.
[0016] Preferably, the HSV conversion to RGB specifically includes: when the saturation When it is 0, the RGB values are the same as the brightness V, otherwise The fractional part , calculated by the following formula:
[0017]
[0018] is the calculated intermediate value, based on The integer part of Calculate the RGB value of the pixel:
[0019]
[0020] And draw the new RGB channel values onto the image for the next step of processing.
[0021] S300: performing adaptive color filtering based on the average color difference of the image, that is, selecting a color filtering ratio coefficient and generalizing it to all sub-images, and processing to obtain color filtering results of all sub-images;
[0022] Preferably, performing adaptive color filtering specifically includes the following steps:
[0023] S301: Calculate the average color difference: calculate the average color difference vector of all pixels that meet the preset conditions, and use the value as the average color difference of the image;
[0024] Preferably, calculating the average color difference specifically includes: for any pixel in the image, when all its RGB values fall within the preset RGB processing interval , then the pixel participates in the calculation of the average color difference, and its color difference vector can be expressed as: , the average value of the color difference vectors of all pixels that meet the conditions is the average color difference of the image.
[0025] S302: Obtaining an adaptive scale coefficient: changing the pixel point retention interval by adjusting the adaptive scale coefficient, and selecting the optimal coefficient to allow as many target points as possible to fall within the retention interval;
[0026] Preferably, obtaining the adaptive scale factor specifically includes: for the pixel points to be retained, calculating the color difference vector , adjust the adaptive scale factor interval So that for the average color difference vector , the following three constraints are all met:
[0027]
[0028] And for the pixels that need to be filtered out, their color difference vector Satisfy one of the following constraints:
[0029]
[0030] S303: Color filtering: All pixels that meet the constraint conditions are retained, and other pixels are filled with default colors to obtain color filtering results for all sub-images.
[0031] S400: All sub-images are sequentially spliced to obtain a binary image after color filtering of the original image.
[0032] Compared with the prior art, the beneficial effects achieved by the present invention are as follows: the present invention divides the complete image into several sub-images of equal size, selects one from the sub-image as a balanced sample, delimits the sampling space, calculates the average HSV value, and calculates the sampling offset vectors of other sub-images based on the value, uses the vector to equalize the sub-image, calculates the color difference mean of the image after equalization, adjusts the color filtering proportional coefficient, makes the target pixel points fall within the filter retention interval, and fills the other positions with the default color to obtain the color filtering result of the sub-image; finally, all the filtered sub-images are spliced to obtain the color filtering result of the original image. Compared with the prior art, the present invention effectively reduces the interference of factors such as overexposure and shadow on the image processing results through the equalization operation, and at the same time improves the flexibility of threshold adjustment through the migration of proportional coefficients, which can improve the reliability of image processing results. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0034] Figure 1 A flowchart of an adaptive color filtering method under a high-contrast background provided by an embodiment of the present invention;
[0035] Figure 2 A flowchart of an image equalization method provided by an embodiment of the present invention;
[0036] Figure 3 A flowchart of an adaptive color filtering method provided by an embodiment of the present invention;
[0037] Figure 4 This is the product box grid image targeted by the embodiment of the present invention. DETAILED DESCRIPTION
[0038] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0039] Embodiments of the present invention are combined Figures 1 to 4 , providing the following technical solution: an adaptive color filtering method under a high-contrast background, comprising the following steps:
[0040] S100: Segment the complete image with a high-contrast background into multiple sub-images of equal size;
[0041] Exemplarily, image segmentation requires dividing a complete image with a high-contrast background into multiple sub-images of equal size. For example, the product box grid image in this embodiment contains 72 small boxes. The image can be approximately divided into 72 sub-images based on the size of the small boxes, and the size of each sub-image can be slightly enlarged to ensure that each small box can fall completely within the sub-image.
[0042] S200: adjusting the HSV value of the pixel point in the sub-image to a standard HSV adjacent interval defined according to the equalization sample, and performing image equalization processing;
[0043] In this embodiment, one of the multiple equally sized sub-images is selected as a balanced sample, and an area is defined as a sampling space. The hue-saturation-brightness (HSV) value of the pixel in the space is used as the standard HSV, and the HSV values of the pixel points in other sub-images are adjusted to a range close to the standard HSV.
[0044] Exemplary, combined Figure 2 As shown, the image equalization process specifically includes the following steps:
[0045] S201: Calculate the standard HSV: From the width , the height is The size of the balanced sample is The HSV value of each pixel in the sampling space is calculated using the following formula:
[0046]
[0047]
[0048]
[0049] in, is the brightness of the color, is saturation, for hue;
[0050] The standard HSV is further calculated based on the HSV of all pixels in the sampling space:
[0051]
[0052] in, Indicates the standard hue value, Indicates the standard saturation value, Indicates the standard brightness value, Indicates the position coordinates of the corresponding pixel. Indicates the number of pixels in the sample space.
[0053] Preferably, the defined balanced sample sampling space needs to select the most representative color area as much as possible to reduce the proportion of abnormal pixels such as overexposed points and shadow points. Figure 4 In the product box grid image shown, the sampling space selects the middle area inside the small box grid to avoid the shadow area caused by the oblique illumination of the light source.
[0054] S202: Pixel equalization: Based on the sampling space defined in S201, calculate the HSV mean of all sub-images in the sampling space, and subtract the sampled HSV value of each sub-image from the standard HSV to obtain the sampling offset vector of the sub-image. , for a given tolerance threshold , when the condition is not met When , the color feature offset that does not meet the requirements is added to all pixels, that is, when , then for all pixels in the sub-image, their saturation will be updated to: ;
[0055] Preferably, not all color feature shifts need to be used. For sub-images with large feature differences, equalizing their hue (H) and saturation (S) may destroy the color coordination of the sub-images themselves. For the product box grid images described in this embodiment, because the contents of the divided sub-images have strong similarities, the three color features of hue, saturation and brightness can all be equalized.
[0056] S203: HSV to RGB conversion: The HSV value after pixel equalization needs to be reconverted to RGB value and filled in the image. If it is 0, the RGB values are the same as the brightness V, otherwise The fractional part , calculated by the following formula:
[0057]
[0058] is the calculated intermediate value, and then based on The integer part of , get the RGB value of the pixel:
[0059]
[0060] And draw the new RGB channel values onto the image for the next step of processing.
[0061] S300: Based on the average color difference of the image, adaptive color filtering is performed, that is, a color filtering ratio coefficient is selected and extended to all sub-images, and the color filtering results of all sub-images are obtained.
[0062] Exemplarily, a sub-image after equalization is selected, the color difference values between the three RGB color channels of all pixels are calculated and the average color difference is obtained, a suitable proportional coefficient threshold is selected so that the color difference values of the pixels to be retained fall between the product of the threshold and the average color difference, and the pixels whose color difference values do not belong to this interval are filled with a default color to obtain a color filtering result image, and the proportional coefficient used by the threshold sample is extended to all sub-images, and the filtering results of all sub-images are obtained through processing.
[0063] Further, combined with Figure 3 As shown, adaptive color filtering specifically includes the following steps:
[0064] S301: Calculate the average color difference: calculate the average color difference vector of all pixels that meet the preset conditions, and use the value as the average color difference of the image;
[0065] For example, for any pixel in the image, if all its RGB values fall within the preset RGB processing range , then the pixel participates in the calculation of the average color difference, and its color difference vector can be expressed as: , the average value of the color difference vectors of all pixels that meet the conditions is the average color difference of the image.
[0066] S302: Obtaining an adaptive scale coefficient: changing the pixel point retention interval by adjusting the adaptive scale coefficient, and selecting the optimal coefficient to allow as many target points as possible to fall within the retention interval;
[0067] For example, for the pixel points that need to be retained, the color difference vector is calculated , adjust the adaptive scale factor interval So that for the average color difference vector , the following three constraints are all met:
[0068]
[0069] And for the pixels that need to be filtered out, their color difference vector Satisfy one of the following constraints:
[0070]
[0071] S303: Color filtering: The scale factor interval set in S302 Apply it to all sub-images, retain all pixels that meet the constraints, and fill other pixels with default colors to obtain the color filtering results of all sub-images.
[0072] S400: All sub-images are stitched together in order to obtain a binary image after color filtering of the original image;
[0073] Exemplarily, the parts of all sub-images expanded in S100 are deleted, and all sub-images are spliced in sequence to obtain a binary image after color filtering of the original image.
[0074] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0075] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. An adaptive color filtering method under high contrast background, characterized by: The following steps are involved: S100: Segment the complete image with a high-contrast background into multiple sub-images of equal size; S200: adjusting the HSV value of the pixel point in the sub-image to a standard HSV adjacent interval defined according to the equalization sample, and performing image equalization processing; S300: performing adaptive color filtering based on the average color difference of the image, that is, selecting a color filtering ratio coefficient and generalizing it to all sub-images, and processing to obtain color filtering results of all sub-images; S400: All sub-images are sequentially spliced to obtain a binary image after color filtering of the original image.
2. The method for adaptive color filtering under high contrast background according to claim 1, characterized in that: The image equalization process specifically comprises the following steps: S201: Calculate the standard HSV: From the width , the height is The size of the balanced sample is The sampling space is used to calculate the HSV value of each pixel in the sampling space; S202: Pixel equalization: Based on the sampling space, calculate the HSV mean of all sub-images in the sampling space, and subtract the sampled HSV value of each sub-image from the standard HSV to obtain the sampling offset vector of the sub-image. , adjust the HSV value of the sub-image pixel according to the sampling offset vector; S203: HSV to RGB conversion: The HSV values of the pixels after equalization are reconverted into RGB values and filled in the image.
3. The method for adaptive color filtering under high contrast background according to claim 2, characterized in that: The calculation formula for calculating the HSV value of each pixel in the sampling space is as follows: ; ; ; in, is the brightness of the color, is saturation, For color tone.
4. The method for adaptive color filtering under high contrast background according to claim 3, characterized in that: Calculating the HSV value of each pixel in the sampling space also includes: calculating the standard HSV according to the HSV of all pixels in the sampling space: ; in, Represents the standard hue value, Indicates the standard saturation value, Indicates the standard brightness value, Indicates the position coordinates of the corresponding pixel. Indicates the number of pixels in the sample space.
5. The method for adaptive color filtering under high contrast background according to claim 2, characterized in that: The method of adjusting the HSV value of the sub-image pixel point according to the sampling offset vector includes: for a given tolerance threshold , when the condition is not met When , the color feature offset that does not meet the requirements is added to all pixels, that is, when , then for all pixels in the sub-image, their saturation will be updated to: .
6. The method for adaptive color filtering under high contrast background according to claim 5, characterized in that: The HSV conversion to RGB specifically includes: When it is 0, the RGB values are the same as the brightness V, otherwise The fractional part , calculated by the following formula: ; is the calculated intermediate value, based on The integer part of Calculate the RGB value of the pixel: ; And draw the new RGB channel values onto the image for the next step of processing.
7. The method for adaptive color filtering under high contrast background according to claim 6, characterized in that: The adaptive color filtering specifically comprises the following steps: S301: Calculate the average color difference: calculate the average color difference vector of all pixels that meet the preset conditions, and use the value as the average color difference of the image; S302: Obtaining an adaptive scale coefficient: changing the pixel point retention interval by adjusting the adaptive scale coefficient, and selecting the optimal coefficient to allow as many target points as possible to fall within the retention interval; S303: Color filtering: All pixels that meet the constraint conditions are retained, and other pixels are filled with default colors to obtain color filtering results for all sub-images.
8. The method for adaptive color filtering under high contrast background according to claim 7, characterized in that: The calculation of the average color difference specifically includes: for any pixel in the image, when all its RGB values fall within the preset RGB processing interval , then the pixel participates in the calculation of the average color difference, and its color difference vector can be expressed as: , the average value of the color difference vectors of all pixels that meet the conditions is the average color difference of the image.
9. The method for adaptive color filtering under high contrast background according to claim 8, characterized in that: The method of obtaining the adaptive scale factor specifically includes: for the pixel points to be retained, calculating the color difference vector , adjust the adaptive scale factor interval So that for the average color difference vector , the following three constraints are all met: ; And for the pixels that need to be filtered out, their color difference vector Satisfy one of the following constraints: 。
Citation Information
Patent Citations
Method for adaptively adjusting image contrast based on image brightness information
CN118469886A
Redundancy elimination in a content-adaptive video preview system
EP1557837A1
Bandwidth adaption rule for adaptive noise filter for inverse filtering with improved speed
GB0212778D0
Image processing device, image processing method, and image processing program
WO2006106750A1