CN117011393A - Image color recognition method, computer device, and storage medium - Google Patents

Image color recognition method, computer device, and storage medium Download PDF

Info

Publication number
CN117011393A
CN117011393A CN202310953932.7A CN202310953932A CN117011393A CN 117011393 A CN117011393 A CN 117011393A CN 202310953932 A CN202310953932 A CN 202310953932A CN 117011393 A CN117011393 A CN 117011393A
Authority
CN
China
Prior art keywords
color
pixel
value
region
image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310953932.7A
Other languages
Chinese (zh)
Inventor
单立波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Weipu Technology Co ltd
Original Assignee
Shenzhen Weipu Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Weipu Technology Co ltd filed Critical Shenzhen Weipu Technology Co ltd
Priority to CN202310953932.7A priority Critical patent/CN117011393A/en
Publication of CN117011393A publication Critical patent/CN117011393A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/25Determination of region of interest [ROI] or a volume of interest [VOI]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/74Image or video pattern matching; Proximity measures in feature spaces
    • G06V10/761Proximity, similarity or dissimilarity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Databases & Information Systems (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Software Systems (AREA)
  • Image Analysis (AREA)

Abstract

The application relates to the technical field of image processing, and provides an image color recognition method, computer equipment and a storage medium. According to the application, through selecting the region of interest in the image, the pixel value of each pixel point in the region of interest in the designated color space is obtained, and the abnormal pixel point filtering is carried out on the region of interest by utilizing the pixel values, so that the target processing region is obtained. And carrying out weighted average calculation on the pixel points in the target processing area to obtain a weighted average value. Comparing and matching the weighted average value with a plurality of standard pixel values in a preset color library, and finding the standard pixel value closest to the weighted average value by calculating the similarity, thereby determining the color of the color image according to the closest standard pixel value. The accuracy and reliability of color recognition are improved by filtering and weighting the pixel values of the pixel points in the image region of interest in the designated color space.

Description

Image color recognition method, computer device, and storage medium
Technical Field
The present application relates to the field of image processing technologies, and in particular, to an image color recognition method, a computer device, and a storage medium.
Background
In computer vision and image processing, color recognition is a technique that converts color information in an object or image into understandable data. Color recognition can be used in image analysis and processing to help computer systems understand the color properties of objects in an image. By means of color recognition, the computer can distinguish and recognize different objects according to different color information, so that corresponding tasks are performed.
However, color recognition of an image is often sensitive to illumination changes and environmental influences, and different illumination conditions and environmental factors may cause visual differences of colors, thereby disturbing the accuracy of color recognition and causing lower accuracy of color recognition.
Disclosure of Invention
In view of the above, the present application provides an image color recognition method, a computer device and a storage medium, so as to solve the technical problem of low accuracy of image color recognition results.
A first aspect of the present application provides an image color recognition method, the method comprising:
selecting a region of interest from the color image;
acquiring a pixel value of each pixel point in the region of interest in a designated color space;
filtering abnormal pixel points of the region of interest according to the pixel values to obtain a target processing region;
carrying out weighted average calculation on pixel values of pixel points in the target processing area to obtain a weighted average value;
and determining the color of the color image according to the weighted average value and a plurality of standard pixel values in a preset color library.
In a possible implementation manner, the filtering the abnormal pixel point of the region of interest according to the pixel value to obtain a target processing region includes:
calculating the number of color component values of a designated channel in the pixel values, acquiring first target pixel points corresponding to the color component values, the number of which is smaller than a preset number threshold, and filtering the first target pixel points in the region of interest as abnormal pixel points to obtain the target processing region; and/or
And comparing the color component value of the designated channel in the pixel value with a preset color component value range, obtaining a second target pixel point corresponding to the color component value which is not in the preset color component value range, and filtering the second target pixel point in the region of interest as an abnormal pixel point to obtain the target processing region.
In one possible implementation manner, the calculating a weighted average of the pixel values of the pixel points in the target processing area to obtain a weighted average value includes:
traversing each pixel point in the target processing area, and adding the color component value of the designated channel in the pixel values of the pixel points with a first preset weighting value to obtain a weighted pixel value of the pixel points if the color component value of the designated channel in the pixel values of the pixel points is in a preset designated numerical range;
and carrying out color component value average calculation on the weighted pixel value of each pixel point in the target processing area in the same channel to obtain the weighted average value.
In one possible implementation manner, the calculating the weighted average of the pixel values of the pixel points in the target processing area to obtain a weighted average value further includes:
calculating the average color component value of all the pixel points in the target processing area on the appointed channel, and adding the average color component value on the appointed channel with a second preset weighting value to obtain the weighted average value.
In one possible implementation manner, the determining the color of the color image according to the weighted average value and a plurality of standard pixel values in a preset color library includes:
performing similarity calculation on the weighted average value and each standard pixel value in the preset color library to obtain a plurality of similarities;
determining the maximum similarity in the plurality of similarities and a target standard pixel value corresponding to the maximum similarity;
and determining the color of the color image according to the color label corresponding to the target standard pixel value.
In one possible embodiment, the method further comprises:
and displaying the color label corresponding to the determined color at a preset position away from the region of interest in the color image.
In a possible embodiment, before setting the region of interest in the color image, the method further comprises:
denoising the color image to obtain a denoised image;
setting a region of interest in the color image includes setting a region of interest in the denoised image.
In one possible implementation manner, the acquiring the pixel value of each pixel point in the region of interest in the designated color space includes:
acquiring pixel values of each pixel point in the RGB color space in the region of interest, wherein the pixel values of each pixel point in the RGB color space comprise a color component value of an R channel, a color component value of a G channel and a color component value of a B channel; or converting the interested region from RGB color space to HSI color space, and obtaining pixel values of each pixel point in the interested region in the HSI color space, wherein the pixel values of each pixel point in the HSI color space comprise color component values of H channels, color component values of S channels and color component values of I channels; or converting the interested region from RGB color space to HSV color space, and obtaining pixel values of each pixel point in the interested region in the HSV color space, wherein the pixel values of each pixel point in the HSI color space comprise color component values of H channels, color component values of S channels and color component values of V channels.
A second aspect of the application provides a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the image colour recognition method when executing the computer program.
A third aspect of the present application provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of the image color recognition method.
According to the image color recognition method, the computer equipment and the storage medium provided by the embodiment of the application, through selecting the region of interest in the image, the pixel value of each pixel point in the region of interest in the designated color space is obtained, and the abnormal pixel point filtering is carried out on the region of interest by utilizing the pixel values, so that the target processing region is obtained. And carrying out weighted average calculation on the pixel points in the target processing area to obtain a weighted average value. Comparing and matching the weighted average value with a plurality of standard pixel values in a preset color library, and finding the standard pixel value closest to the weighted average value by calculating the similarity, thereby determining the color of the color image according to the closest standard pixel value. The accuracy and reliability of color recognition are improved by filtering and weighting pixel values of pixel points in an image region of interest in a designated color space.
Drawings
FIG. 1 is a flow chart of an image color recognition method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a color recognition interface shown in an embodiment of the present application;
FIG. 3 is a schematic diagram of a region of interest selected on a color image, according to an embodiment of the present application;
fig. 4 is a block diagram of a computer device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application.
In computer vision and image processing, color recognition plays a more important role, and through the color recognition, a computer can distinguish and recognize different objects according to different color information, so that corresponding tasks are executed.
In the prior art, the following methods are mainly used for identifying the colors of the images:
the method comprises the following steps: in the RGB color space, by sampling pixels of an image, RGB values of each pixel can be obtained, and then the color of the image is judged from the RGB values.
A drawback of the first method is that RGB colors are sensitive to illumination changes and environmental effects, and different illumination conditions and environmental factors (e.g., shadows, reflections, etc.) may cause visual differences in colors, thereby interfering with the accuracy of color recognition, and subtle differences in similar colors are difficult to distinguish.
The second method is as follows: the method comprises the steps of converting an image from an RGB color space to an HSI color space or an HSV color space, sampling pixels of the image in the HSI color space or the HSV color space to obtain an HSI value or an HSV value of each pixel, and judging the color of the image by using a threshold value or region division method and the like.
The second method has the disadvantage of high computational complexity, and in the HSI color space or HSV color space, for very similar colors, e.g., pale purple and pale blue, are very close, which makes it difficult to distinguish accurately.
And a third method: calculating a color histogram of the image, acquiring distribution conditions of different colors, and judging the color of the image according to the peak value or the distribution shape.
The third method has the defect that the resolution and the precision of the histogram are limited by the pixel number and the color depth of the image, and a fine color difference is difficult to capture.
The method four: the color recognition model is trained based on machine learning and deep learning techniques, and the mapping relation from the pixel values of the image to the color categories is learned to perform color recognition.
The fourth disadvantage of the method is that a large number of marked images need to be used for training the color recognition model, the marked images need a long processing time and a high computational resource, resulting in a lower efficiency, a more time consuming and, if the marking is inaccurate, a lower accuracy of the color recognition.
Therefore, it is necessary to provide an image color recognition scheme to improve the accuracy of image color recognition.
Referring to fig. 1, a flowchart of an image color recognition method according to an embodiment of the application is shown. The image color recognition method may be performed by a computer device. The image color recognition method includes the following steps.
S11, selecting a region of interest from the color image.
The color image refers to an image that needs to be color-identified. The color image may be acquired by an image acquisition device and transmitted to a computer device. The color image may also be uploaded to the computer device by the user via the internet.
When a user needs to identify the color of a certain area in the color image, the area can be selected by using a calibration frame, and the area selected by the calibration frame is used as the region of interest. The calibration frame may be square, circular, elliptical, irregular polygonal, etc.
In an alternative embodiment, a color recognition interface may be displayed, as shown in fig. 2, for synchronously displaying the color image and calibration frames of various shapes. After the user selects one of the plurality of calibration frames, the user-selected calibration frame may be used to select a region of interest on the color image, as shown in fig. 3, the shape of the selected region of interest being consistent with the shape of the user-selected calibration frame.
The application sets the ROI in the color image to be identified, and carries out color identification on the image in the ROI, thereby reducing the image processing amount and improving the efficiency of image processing and color identification.
In an alternative embodiment, the user's movement, dragging and scaling operations of the calibration frame on the color image may also be received, so that the position and size of the calibration frame more conform to the position of the color that the user desires to identify.
In an alternative embodiment, before setting the region of interest in the color image, the method further comprises:
and denoising the color image to obtain a denoised image.
More or less noise may be present in the color image, and noise refers to some random or irregular pixels present in the color image, where the presence of the pixels may obscure, distort or create a grainy feel to the color image. To eliminate or reduce noise in a color image, to improve accuracy of color recognition of the color image, the color image may be subjected to denoising processing.
The color image can be denoised by using methods such as median filtering, mean filtering, gaussian filtering and the like, so that the purpose of smoothing the color image is achieved, and details and textures of the color image are reduced.
After denoising the color image to obtain a denoised image, performing color recognition by taking the denoised image as a recognition image, for example, setting a region of interest in the denoised image.
S12, acquiring pixel values of each pixel point in the region of interest in a designated color space.
And traversing all the pixel points in the interested region by using a user to designate a color space, and acquiring the color component values of each color channel of each pixel point in the designated color space, so as to obtain the pixel value of each pixel point in the designated color space. The user-specified color space may be an RGB color space, or an HSI color space, or an HSV color space.
The RGB color space is a common color representation that represents colors as a combination of three components, red (Red), green (Green), and Blue (Blue). In the RGB color space, the color value of each pixel is composed of the color component value of the R channel, the color component value of the G channel, and the color component value of the B channel. When the designated color space is an RGB color space, then the pixel value of each pixel point within the region of interest in the RGB color space may be acquired.
The HSI color space is another common color representation that represents colors as a combination of three components, hue (Hue), saturation (Saturation) and brightness (Lightness). In the HSI color space, the color value of each pixel consists of the color component value of the H-channel, the color component value of the S-channel, and the color component value of the I-channel. When the designated color space is the HSI color space, the region of interest may be converted from the RGB color space to the HSI color space, and then the pixel value of each pixel point in the region of interest in the HSI color space may be obtained.
HSV color space is another common color representation that represents colors as a combination of three components, hue (Hue) Saturation (Saturation) and Value (Value). In the HSV color space, the color value of each pixel is composed of the color component value of the H-channel, the color component value of the S-channel, and the color component value of the V-channel. When the designated color space is an HSV color space, the region of interest can be converted from an RGB color space to an HSV color space, and then the pixel value of each pixel point in the region of interest in the HSV color space can be obtained.
RGB, HSV and HSI are three mutually noninterfere color spaces, the RGB color space is suitable for color images with single color and weak brightness, the HSV color space and the HSI color space are more suitable for images with various hues and high brightness, and compared with the HSV color space, the HSI color space is more visual and easy to operate in the aspects of understanding and controlling the color images. Thus, one color space may be specified based on the image characteristics of the color image and the requirements for the color representation, and subsequent color recognition of the color image may be performed within the specified color space.
For example, when the color image is a tropical fish image or a gray stone image in coral reefs, an RGB color space may be designated for color recognition processing; when the color image is an image that needs to be well distinguished between color types and variations, such as a flower image or a rainbow image, the HSI color space may be designated for color recognition processing; when the color image is a high-brightness color image, for example, a scenic image under intense sun illumination, the HSV color space may be designated for color recognition processing.
S13, filtering abnormal pixel points of the region of interest according to the pixel values to obtain a target processing region.
Since some noise points exist in the region of interest and can affect the identification of colors, abnormal pixel points in the region of interest need to be filtered according to pixel values, so that a target processing region is obtained. The accuracy of color recognition can be improved by performing color recognition based on the target processing region.
In some embodiments, abnormal pixel detection may be performed on each pixel in the region of interest, and if there is a large difference between the pixel value of the pixel and the average pixel value of surrounding pixels, the pixel is considered to be an abnormal pixel, and all the abnormal pixels are removed from the region of interest, so as to obtain the target processing region.
In some embodiments, the number of color component values of the designated channel in the pixel values may be calculated, a first target pixel point corresponding to the color component value with the number smaller than a preset number threshold may be obtained, and the first target pixel point in the region of interest is filtered as an abnormal pixel point, so as to obtain the target processing region.
The specified channel is a color channel in a specified color space, and one or more color channels may be specified as specified channels in the specified color space by a user.
And counting the number of different color component values in a designated color channel in the region of interest by using a projection mapping mode, and when the number of the color component values is smaller than a number threshold value preset by a user, taking the pixel point corresponding to the color component value as a first target pixel point, and filtering and removing the first target pixel point in the region of interest as an abnormal pixel point to obtain a target processing region.
For example, assuming that the designated color space is an RGB color space, the designated channel is an R channel, and the preset number threshold is 20, the number of occurrences of each color component value of the R channel in the region of interest is calculated, for example, 50 occurrences of the color component value 100 in the R channel, 10 occurrences of the color component value 70, and since the number of occurrences of the color component value 70 is less than 20, the pixel corresponding to the color component value 70 is regarded as the first target pixel, that is, the pixel having the color component value of 70 in the R channel among all the pixels in the region of interest is the abnormal pixel.
For example, assuming that the designated color space is an RGB color space and the designated channels are an R channel and a G channel, the preset number thresholds corresponding to the R channel and the G channel are 20, the number of occurrences of each color component value of the R channel in the region of interest is calculated, and the number of occurrences of each color component value of the G channel in the region of interest is calculated, for example, 50 occurrences of the color component value 100 in the R channel, 10 occurrences of the color component value 70, 60 occurrences of the color component value 110 in the G channel, and 15 occurrences of the color component value 90, and since the number of occurrences of the color component value 70 in the R channel is less than 20 and the number of occurrences of the color component value 90 in the G channel is less than 20, the pixel corresponding to the color component value 70 in the R channel and the pixel corresponding to the color component value 90 in the G channel are both the first target pixel, i.e., the pixel corresponding to the color component value 70 in all the pixel points in the region of interest is the abnormal pixel, and the pixel corresponding to the color component value 90 in the G channel is the abnormal pixel in all pixel points in the region of interest.
According to the embodiment, the pixel points with the number smaller than the preset number threshold value in the designated channel are used as the abnormal points, so that outliers in the color component values can be filtered, the influence of noise generated by the pixel points of the outliers on the identification of the color of the region of interest is eliminated, and the accuracy of color identification is improved.
In some embodiments, the color component value of the designated channel in the pixel value may be compared with a preset color component value range, so as to obtain a second target pixel point corresponding to a color component value not in the preset color component value range, and the second target pixel point in the region of interest is filtered as an abnormal pixel point, so as to obtain the target processing region.
For example, assuming that the designated color space is an RGB color space, the designated channel is an R channel, and the preset color component value range is (200, 255), the color component value of the R channel of each pixel in the region of interest is compared with the preset color component value range (200, 255), and when the color component value of the R channel of a certain pixel is not in the preset color component value range, the pixel is taken as a second target pixel, that is, all pixels in the region of interest, whose color component value of the R channel is not in the preset color component value range, are all abnormal pixels.
According to the embodiment, the pixel points of the designated channel, which are not in the preset color component value range, are used as the abnormal pixel points to be filtered and removed, the inconsistent values in the color component values can be filtered, the influence of noise generated by the pixel points of the inconsistent values on the identification of the color of the region of interest is eliminated, and therefore the robustness of color identification is improved.
It should be noted that, the computer device may determine the abnormal pixel point according to the preset number threshold, may determine the abnormal pixel point according to the preset color component value range, and may determine the abnormal pixel point according to the preset number threshold and the preset color component value range at the same time. When the abnormal pixel points are determined together according to the preset quantity threshold value and the preset color component value range, the abnormal pixel points are determined according to the preset quantity threshold value, the abnormal pixel points are determined according to the preset color component value range, and the abnormal pixel points are determined according to the preset quantity threshold value.
And S14, carrying out weighted average calculation on the pixel values of the pixel points in the target processing area to obtain a weighted average value.
In an alternative embodiment, the pixel values of the pixel points in the target processing area may be weighted, and the pixel values after the weighted calculation may be averaged to obtain a weighted average value. In a specific implementation, each pixel point in the target processing area may be traversed, if the color component value of the designated channel in the pixel values of the pixel points is within a preset designated numerical range, the color component value of the designated channel in the pixel values of the pixel points is added with a first preset weighting value to obtain a weighted pixel value of the pixel point, and the weighted pixel value of each pixel point in the target processing area is subjected to average calculation of the color component values in the same channel to obtain the weighted average value.
One or more channels may be designated as designated channels.
And traversing each pixel point in the target processing area, namely accessing each pixel point one by one. For each pixel point, judging whether the color component value of the designated channel in the pixel values of the pixel point is in a preset designated numerical range or not. If the color component value of the designated channel in the pixel values of the pixel points is in the preset designated numerical range, adding a preset weighting value to the color component value of the designated channel in the pixel values of the pixel points to obtain a weighted pixel value of the pixel points, wherein the weighted pixel value represents the result of adding the color component value of the pixel value on the designated channel and the first preset weighting value. In the same channel, the weighted pixel values of all the pixel points are averaged to obtain an average color component value on the channel, which is used as a weighted average value.
For example, assuming that the designated channel is an R channel, the designated numerical range is [25,50], the first preset weighting value is 10, if the color component value of the R channel in the pixel value traversed to a certain pixel point is 30, since the color component value of the R channel in the pixel value of the pixel point is within the designated numerical range, the weighted pixel value is 30+10=40, that is, the color component value of the R channel of the pixel point after weighting is 40.
The weighting of the color component values on a given channel for each pixel point within the region of interest is referred to as image gray scale weighting.
Through image gray weighting, image fading or enhancement processing can be realized, the contrast and brightness of the image are changed, the influence of shooting environment on the image color is reduced, and the accuracy of image color identification is improved.
In an alternative embodiment, an average calculation may be performed on the pixel values of the pixel points in the target processing area, and a weighted calculation may be performed on the pixel values after the average calculation to obtain a weighted average value. In the implementation, the average color component value of all the pixel points in the target processing area on the designated channel can be calculated, and the average color component value on the designated channel is added with a second preset weighting value to obtain the weighted average value.
The weighting range can be preset, for the average color component value of each appointed channel, one weighting value is randomly selected from the weighting range, and the weighted calculation is carried out on the average color component value of the appointed channel and the weighting value which is correspondingly selected, so as to obtain the weighted average value.
For example, assuming that the standard pixel value of red in the preset color library is (255, 0), the pixel value of a certain pixel point in the region of interest is (250,3,2), the user designates that the average color component value of each channel is weighted, and the weighted range is [ -5,5], so that the average color component values of the R channel, the G channel and the B channel are weighted, and the pixel value of the current pixel point is close to (255, 0) after being weighted, and therefore, the pixel point is close to red after being weighted, which is more beneficial to the subsequent calculation of the similarity of the colors.
Since each pixel has three color component values for each channel, an average color component value needs to be calculated for each channel separately, and the weighting applied to the average color component value for the channel is referred to as image channel weighting.
Through image channel weighting, the color of the color image on the designated channel can be closer to the color value in the preset color library, so that the accuracy of color identification is improved.
It should be noted that, the computer device may calculate the weighted average value by using an image gray weighting method, may calculate the weighted average value by using an image channel weighting method, and may calculate the weighted average value by using both the image gray weighting method and the image channel weighting method. When the weighted average value is calculated by adopting the image gray weighting and the image channel weighting, the weighted average value can be calculated by adopting the image gray weighting mode first, then the weighted average value can be calculated by adopting the image channel weighting mode, or the weighted average value can be calculated by adopting the image channel weighting mode first, and then the weighted average value can be calculated by adopting the image gray weighting mode.
And S15, determining the color of the color image according to the weighted average value and a plurality of standard pixel values in a preset color library.
The preset color library is a preset color library, a plurality of standard pixel values are stored in the preset color library, each standard pixel value corresponds to one color label, the color labels are used for distinguishing types of different colors and can be used for representing color numbers or names or codes of the colors, and the different colors correspond to different color labels.
By performing a similarity calculation of the weighted average value with each standard pixel value, the color that is closest or most matched to the color image can be found.
In an optional embodiment, the determining the color of the color image according to the weighted average value and a plurality of standard pixel values in a preset color library includes:
performing similarity calculation on the weighted average value and each standard pixel value in the preset color library to obtain a plurality of similarities;
determining the maximum similarity in the plurality of similarities and a target standard pixel value corresponding to the maximum similarity;
and determining the color of the color image according to the color label corresponding to the target standard pixel value.
The similarity may be calculated using different indices such as euclidean distance, absolute value difference, cosine similarity, or correlation coefficient. And carrying out similarity calculation on each standard pixel value and the weighted average value to obtain a similarity value. The greater the similarity, the closer the color of the color image is to the color corresponding to the standard pixel value. The smaller the similarity, the less the color of the color image is indicated to be close to the color corresponding to the standard pixel value. The maximum similarity is determined from the plurality of similarity values, that is, the value with the highest similarity is found, and the standard pixel value corresponding to the maximum similarity is determined as a target standard pixel value for representing the color most similar to the color image.
In an alternative embodiment, the method may further comprise:
and displaying the color label corresponding to the determined color at a preset position away from the region of interest in the color image.
And after the color of the region of interest is identified, displaying the identified color at a preset position away from the region of interest in the original color image by using a color label, wherein the color label form is determined or selected by a user to preset label shapes.
Illustratively, when the region of interest is determined to be a pattern on a beverage bottle and the identification color is light purple, a rectangular display is used in the color image 5cm from the pattern, and a "light purple" three-character is displayed in the rectangular box and directed to the region of interest.
According to the application, the region of interest is selected from the color image, and the number of the pixel points of the region of interest is smaller than that of the whole color image, so that the color recognition is performed based on the pixel value of each pixel point in the region of interest in the designated color space, and the efficiency of the color recognition is improved. Abnormal pixel point filtering is carried out on the region of interest through the pixel values, outliers or inconsistent values in the color component values can be filtered, noise or interference generated by the abnormal pixel points is restrained, and accuracy of color identification can be improved. The pixel values of the pixel points in the target processing area are subjected to weighted average calculation, so that the perceptibility of different colors, such as more emphasis on brightness or saturation, can be adjusted, the color distinguishing degree can be improved, the color recognition performance is improved, the pixel values of the pixel points in the target processing area are subjected to weighted average calculation, the color recognition problem under uneven illumination can be processed, color misjudgment caused by illumination change is reduced, and the color recognition robustness is improved. And finally, determining the color of the color image according to the weighted average value and a plurality of standard pixel values in a preset color library, wherein the color identification accuracy of the color image is high.
The application can be applied to various fields, such as computer vision, robot navigation, autopilot, etc. After the color image is identified, the application can judge whether the color of the color image is color cast, and when the color cast phenomenon occurs, the color deviation of the color image can be automatically corrected according to the identified color, so that the image is more accurate and natural. Color images may also be classified according to identified colors, thereby helping automated systems to automatically classify, retrieve, and identify.
Fig. 4 is a schematic structural diagram of a computer device according to an embodiment of the present application. In the preferred embodiment of the application, the computer device 4 includes a memory 41, at least one processor 42, at least one communication bus 43.
It will be appreciated by those skilled in the art that the configuration of the computer device shown in fig. 4 is not limiting of the embodiments of the present application, and that either a bus-type configuration or a star-type configuration is possible, and that the computer device 4 may include more or less other hardware or software than that shown, or a different arrangement of components.
In some embodiments, the computer device 4 is a device capable of automatically performing numerical calculation and/or information processing according to preset or stored instructions, and its hardware includes, but is not limited to, a microprocessor, an application specific integrated circuit, a programmable gate array, a digital processor, an embedded device, and the like. The computer device 4 may also include other computer devices, including but not limited to any electronic product that can interact with a user by way of a keyboard, mouse, remote control, touch pad, or voice control device, such as a personal computer, tablet, smart phone, digital camera, etc.
It should be noted that the computer device 4 is only used as an example, and other electronic products that may be present in the present application or may be present in the future are also included in the scope of the present application by way of reference.
In some embodiments, the memory 41 has stored therein a computer program which, when executed by the at least one processor 42, performs all or part of the steps in the image color recognition method as described. The Memory 41 includes a Read-Only Memory (ROM), a programmable Read-Only Memory (PROM), an erasable programmable Read-Only Memory (EPROM), a One-time programmable Read-Only Memory (One-time Programmable Read-Only Memory, OTPROM), an Electrically erasable rewritable Read-Only Memory (EEPROM), a compact disc Read-Only Memory (Compact Disc Read-Only Memory, CD-ROM) or other optical disc Memory, a magnetic disc Memory, a tape Memory, or any other medium that can be used for computer-readable carrying or storing data.
In some embodiments, the at least one processor 42 is a Control Unit (Control Unit) of the computer device 4, connects the various components of the entire computer device 4 using various interfaces and lines, and performs various functions and processes of the computer device 4 by running or executing programs or modules stored in the memory 41, and invoking data stored in the memory 41. For example, the at least one processor 42, when executing the computer program stored in the memory, implements all or part of the steps of the image color recognition method described in embodiments of the present application; or to implement all or part of the functionality of the image color recognition method. The at least one processor 42 may be comprised of integrated circuits, such as a single packaged integrated circuit, or may be comprised of multiple integrated circuits packaged with the same or different functionality, including one or more central processing units (Central Processing unit, CPU), microprocessors, digital processing chips, graphics processors, combinations of various control chips, and the like.
In some embodiments, the at least one communication bus 43 is arranged to enable connected communication between the memory 41 and the at least one processor 42 or the like. Although not shown, the computer device 4 may also include a power source (e.g., a battery) for powering the various components, preferably the power source is logically connected to the at least one processor 42 via a power management system so as to perform functions such as managing charging, discharging, and power consumption via the power management system. The power supply may also include one or more of any components, such as a direct current or alternating current power supply, a recharging power failure detection circuit, a power converter or inverter, a power status indicator, and the like. The computer device 4 may further include various sensors, bluetooth modules, wi-Fi modules, etc., which will not be described in detail herein.
The integrated units implemented in the form of software functional modules described above may be stored in a computer readable storage medium. The software functional modules described above are stored in a storage medium and include instructions for causing a computer device (which may be a personal computer, a computer device, or a network device, etc.) or processor (processor) to perform portions of the methods described in the various embodiments of the application.
In the several embodiments provided by the present application, it should be understood that the disclosed and methods may be implemented in other ways. For example, the embodiments described above are merely illustrative, and for example, the division of the modules is merely a logical function division, and other manners of division may be implemented in practice.
The modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical units, may be located in one place, or may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
The terminology used in the embodiments of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include the plural forms as well, unless the context clearly indicates to the contrary. It should also be understood that the term "and/or" as used in this disclosure is intended to encompass any or all possible combinations of one or more of the listed items. The terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as implying or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature, and in the description of embodiments of the application, unless otherwise indicated, the meaning of "a plurality" is two or more.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within the scope of the present application. Therefore, the protection scope of the application is subject to the protection scope of the claims.

Claims (10)

1. An image color recognition method, the method comprising:
selecting a region of interest from the color image;
acquiring a pixel value of each pixel point in the region of interest in a designated color space;
filtering abnormal pixel points of the region of interest according to the pixel values to obtain a target processing region;
carrying out weighted average calculation on pixel values of pixel points in the target processing area to obtain a weighted average value;
and determining the color of the color image according to the weighted average value and a plurality of standard pixel values in a preset color library.
2. The method of claim 1, wherein the performing outlier filtering on the region of interest according to the pixel value to obtain a target processing region includes:
calculating the number of color component values of a designated channel in the pixel values, acquiring first target pixel points corresponding to the color component values, the number of which is smaller than a preset number threshold, and filtering the first target pixel points in the region of interest as abnormal pixel points to obtain the target processing region; and/or
And comparing the color component value of the designated channel in the pixel value with a preset color component value range, obtaining a second target pixel point corresponding to the color component value which is not in the preset color component value range, and filtering the second target pixel point in the region of interest as an abnormal pixel point to obtain the target processing region.
3. The method of claim 2, wherein performing a weighted average calculation on pixel values of pixel points in the target processing region to obtain a weighted average value includes:
traversing each pixel point in the target processing area, and adding the color component value of the designated channel in the pixel values of the pixel points with a first preset weighting value to obtain a weighted pixel value of the pixel points if the color component value of the designated channel in the pixel values of the pixel points is in a preset designated numerical range;
and carrying out color component value average calculation on the weighted pixel value of each pixel point in the target processing area in the same channel to obtain the weighted average value.
4. The method of claim 2, wherein performing a weighted average calculation on pixel values of pixel points in the target processing region to obtain a weighted average value includes:
calculating the average color component value of all the pixel points in the target processing area on the appointed channel, and adding the average color component value on the appointed channel with a second preset weighting value to obtain the weighted average value.
5. The method according to claim 3 or 4, wherein determining the color of the color image according to the weighted average value and a plurality of standard pixel values in a preset color library comprises:
performing similarity calculation on the weighted average value and each standard pixel value in the preset color library to obtain a plurality of similarities;
determining the maximum similarity in the plurality of similarities and a target standard pixel value corresponding to the maximum similarity;
and determining the color of the color image according to the color label corresponding to the target standard pixel value.
6. The image color recognition method according to claim 5, further comprising:
and displaying the color label corresponding to the determined color at a preset position away from the region of interest in the color image.
7. The image color recognition method of claim 5, wherein prior to setting the region of interest in the color image, the method further comprises:
denoising the color image to obtain a denoised image;
setting a region of interest in the color image includes setting a region of interest in the denoised image.
8. The image color recognition method of claim 5, wherein the acquiring pixel values in a specified color space for each pixel point within the region of interest comprises:
acquiring pixel values of each pixel point in the RGB color space in the region of interest, wherein the pixel values of each pixel point in the RGB color space comprise a color component value of an R channel, a color component value of a G channel and a color component value of a B channel; or (b)
Converting the region of interest from an RGB color space to an HSI color space, and acquiring pixel values of each pixel point in the region of interest in the HSI color space, wherein the pixel values of each pixel point in the HSI color space comprise color component values of an H channel, color component values of an S channel and color component values of an I channel; or (b)
Converting the region of interest from an RGB color space to an HSV color space, and acquiring a pixel value of each pixel point in the region of interest in the HSV color space, wherein the pixel value of each pixel point in the HSI color space comprises a color component value of an H channel, a color component value of an S channel and a color component value of a V channel.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the image colour identification method according to any of claims 1 to 8 when the computer program is executed.
10. A computer-readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the image color recognition method according to any one of claims 1 to 8.
CN202310953932.7A 2023-07-31 2023-07-31 Image color recognition method, computer device, and storage medium Pending CN117011393A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310953932.7A CN117011393A (en) 2023-07-31 2023-07-31 Image color recognition method, computer device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310953932.7A CN117011393A (en) 2023-07-31 2023-07-31 Image color recognition method, computer device, and storage medium

Publications (1)

Publication Number Publication Date
CN117011393A true CN117011393A (en) 2023-11-07

Family

ID=88563101

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310953932.7A Pending CN117011393A (en) 2023-07-31 2023-07-31 Image color recognition method, computer device, and storage medium

Country Status (1)

Country Link
CN (1) CN117011393A (en)

Similar Documents

Publication Publication Date Title
CN110544258B (en) Image segmentation method and device, electronic equipment and storage medium
CN111028213A (en) Image defect detection method and device, electronic equipment and storage medium
CN110168562A (en) Control method based on depth, control device and electronic device based on depth
US10032088B2 (en) Method and system for classifying painted road markings in an automotive driver-vehicle-assistance device
EP3220353B1 (en) Image processing apparatus, image processing method, and recording medium
CN109671046B (en) Method and device for analyzing skin moisture by using skin image
US20100172578A1 (en) Detecting skin tone in images
US9064178B2 (en) Edge detection apparatus, program and method for edge detection
CN106937049A (en) The processing method of the portrait color based on the depth of field, processing unit and electronic installation
EP2959454A1 (en) Method, system and software module for foreground extraction
CN112750162B (en) Target identification positioning method and device
CN108830184B (en) Black eye recognition method and device
CN106815587B (en) Image processing method and device
CN111126393A (en) Vehicle appearance refitting judgment method and device, computer equipment and storage medium
US20150036924A1 (en) Method, arrangement and computer program product for recognizing videoed objects
CN115619787B (en) UV glue defect detection method, system, equipment and medium
CN106570855A (en) Method and system for quickly judging pork freshness
CN113298753A (en) Sensitive muscle detection method, image processing method, device and equipment
KR20110021500A (en) Method for real-time moving object tracking and distance measurement and apparatus thereof
JP5338762B2 (en) White balance coefficient calculation device and program
CN113614774A (en) Method and system for defect detection in image data of target coating
US9361527B1 (en) Method and system for classifying painted road markings in an automotive driver vehicle-assistance device
CN110390698B (en) Gray scale sensor module, data processing method thereof and robot
CN117011393A (en) Image color recognition method, computer device, and storage medium
CN117501326A (en) Image processing method and device, electronic equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination