Image color recognition method, computer device and storage medium
By selecting the region of interest in the image, filtering abnormal pixel points and performing weighted average processing, the problem of low image color recognition accuracy is solved, and higher color recognition accuracy and robustness is achieved.
Patent Information
- Application Number
- CN202310953932.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-31
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2043-07-31
AI Technical Summary
The image color recognition results are relatively accurate and are greatly affected by changes in light and environmental factors.
Select the area of interest in the color image, obtain the pixel value of each pixel in the specified color space, filter the abnormal pixel point, obtain the target processing area, and perform weighted average calculations. Finally, the similarity calculation is performed based on the weighted average value and the standard pixel value in the preset color library to determine the image color.
By filtering abnormal pixel points and weighted average processing, the accuracy and robustness of color recognition are improved, and the impact of light changes and environmental factors on color recognition is reduced.
Smart Images

Figure CN117011393B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image color recognition method, a computer device and a storage medium. Background Art
[0002] In computer vision and image processing, color recognition is a technique that converts the 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. Through color recognition, computers can distinguish and identify different objects based on different color information, thereby performing corresponding tasks.
[0003] However, image color recognition is often sensitive to lighting changes and environmental influences. Different lighting conditions and environmental factors may cause visual differences in color, thereby interfering with the accuracy of color recognition and resulting in low color recognition accuracy. Summary of the invention
[0004] In view of this, the present application provides an image color recognition method, a computer device and a storage medium to solve the technical problem of low accuracy of image color recognition results.
[0005] A first aspect of the present application provides an image color recognition method, the method comprising:
[0006] Select the region of interest in the color image;
[0007] Obtaining the pixel value of each pixel point in the region of interest in a specified color space;
[0008] Filtering abnormal pixels in the region of interest according to the pixel values to obtain a target processing region;
[0009] Performing weighted average calculation on the pixel values of the pixel points in the target processing area to obtain a weighted average value;
[0010] The color of the color image is determined according to the weighted average value and a plurality of standard pixel values in a preset color library.
[0011] In a possible implementation, filtering abnormal pixels in the region of interest according to the pixel values to obtain a target processing region includes:
[0012] Calculate the number of color component values of a specified channel in the pixel value, obtain the first target pixel point corresponding to the color component value whose number is less than a preset number threshold, filter the first target pixel point in the region of interest as an abnormal pixel point, and obtain the target processing area; and / or
[0013] Compare the color component value of the specified channel in the pixel value with the preset color component value range, obtain the second target pixel point corresponding to the color component value not within the preset color component value range, filter the second target pixel point in the region of interest as an abnormal pixel point, and obtain the target processing area.
[0014] In a possible implementation manner, performing weighted average calculation on the pixel values of the pixel points in the target processing area to obtain the weighted average value includes:
[0015] Traversing each pixel point in the target processing area, if the color component value of the specified channel in the pixel value of the pixel point is within a preset specified value range, adding the color component value of the specified channel in the pixel value of the pixel point to a first preset weighted value to obtain a weighted pixel value of the pixel point;
[0016] The weighted pixel value of each pixel point in the target processing area is averaged by calculating the color component value in the same channel to obtain the weighted average value.
[0017] In a possible implementation manner, performing weighted average calculation on the pixel values of the pixel points in the target processing area to obtain the weighted average value further includes:
[0018] The average color component value of all pixels in the target processing area on the specified channel is calculated, and the average color component value on the specified channel is added to the second preset weighted value to obtain the weighted average value.
[0019] In a possible implementation manner, 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:
[0020] Calculating the similarity between the weighted average value and each standard pixel value in the preset color library to obtain multiple similarities;
[0021] Determine a maximum similarity among the multiple similarities, and a target standard pixel value corresponding to the maximum similarity;
[0022] The color of the color image is determined according to the color label corresponding to the target standard pixel value.
[0023] In a possible implementation, the method further includes:
[0024] A color label corresponding to the determined color is displayed at a preset position away from the region of interest in the color image.
[0025] In a possible implementation manner, before setting the region of interest in the color image, the method further includes:
[0026] Performing denoising processing on the color image to obtain a denoised image;
[0027] Setting the region of interest in the color image includes setting the region of interest in the denoised image.
[0028] In a possible implementation manner, obtaining the pixel value of each pixel point in the region of interest in a specified color space includes:
[0029] Obtain a pixel value of each pixel in the region of interest in the RGB color space, wherein the pixel value of each pixel in the RGB color space includes a color component value of the R channel, a color component value of the G channel, and a color component value of the B channel; or convert the region of interest from the RGB color space to the HSI color space, obtain a pixel value of each pixel in the region of interest in the HSI color space, wherein the pixel value of each pixel in the HSI color space includes a color component value of the H channel, a color component value of the S channel, and a color component value of the I channel; or convert the region of interest from the RGB color space to the HSV color space, obtain a pixel value of each pixel in the region of interest in the HSV color space, wherein the pixel value of each pixel in the HSI color space includes a color component value of the H channel, a color component value of the S channel, and a color component value of the V channel.
[0030] The second aspect of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the image color recognition method when executing the computer program.
[0031] A third aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the image color recognition method when executed by a processor.
[0032] The image color recognition method, computer device and storage medium provided by the embodiments of the present application select an area of interest in an image, obtain the pixel value of each pixel point in the area of interest in a specified color space, and use these pixel values to filter abnormal pixels in the area of interest, so as to obtain a target processing area. A weighted average calculation is performed on the pixels in the target processing area to obtain a weighted average value. The weighted average value is compared and matched with multiple standard pixel values in a preset color library, and the standard pixel value closest to the weighted average value is found by calculating the similarity, so as to determine the color of the color image according to the closest standard pixel value. By filtering and weighting the pixel values of the pixels in the area of interest of the image in the specified color space, the accuracy and reliability of color recognition are improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 is a flow chart of an image color recognition method shown in an embodiment of the present application;
[0034] Figure 2 is a schematic diagram of a color recognition interface shown in an embodiment of the present application;
[0035] Figure 3 is a schematic diagram of a region of interest selected on a color image shown in an embodiment of the present application;
[0036] Figure 4 It is a structural diagram of a computer device shown in an embodiment of the present application. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0038] In computer vision and image processing, color recognition plays a relatively important role. Through color recognition, computers can distinguish and identify different objects based on different color information, thereby performing corresponding tasks.
[0039] In the prior art, there are mainly the following methods for identifying image color:
[0040] Method 1: In the RGB color space, by sampling the pixels of the image, the RGB value of each pixel can be obtained, and then the color of the image can be judged based on the RGB value.
[0041] The drawback of method one is that RGB color is sensitive to lighting changes and environmental influences. Different lighting conditions and environmental factors (such as shadows, reflections, etc.) may cause visual differences in color, thereby interfering with the accuracy of color recognition, and subtle differences in similar colors are difficult to distinguish.
[0042] Method 2: Convert the image from RGB color space to HSI color space or HSV color space. In HSI color space or HSV color space, by sampling the pixels of the image, the HSI value or HSV value of each pixel can be obtained, and then the color of the image can be judged by using methods such as threshold or region division.
[0043] The drawback of the second method is that the computational complexity is relatively high. In the HSI color space or the HSV color space, very similar colors, for example, lavender and light blue are very close, and it is difficult to accurately distinguish them.
[0044] Method 3: Calculate the color histogram of the image, obtain the distribution of different colors, and determine the color of the image based on the peak value or distribution shape.
[0045] The drawback of method three is that the resolution and accuracy of the histogram are limited by the number of pixels and color depth of the image, making it difficult to capture subtle color differences.
[0046] Method 4: Train the color recognition model based on machine learning and deep learning technology to learn the mapping relationship from the pixel value of the image to the color category to identify the color.
[0047] The drawback of method 4 is that a large number of labeled images are required to train the color recognition model. Labeling images requires a long processing time and high computing resources, resulting in low efficiency and time-consuming. If the labeling is inaccurate, the color recognition accuracy will be low.
[0048] Therefore, it is necessary to provide an image color recognition scheme to improve the accuracy of image color recognition.
[0049] See also Figure 1 FIG. 1 is a flowchart of an image color recognition method provided in Embodiment 1 of the present application. The image color recognition method can be executed by a computer device. The image color recognition method includes the following steps.
[0050] S11, selecting a region of interest in the color image.
[0051] The color image refers to an image that needs to be color-recognized. The color image can be acquired by an image acquisition device and transmitted to a computer device. The color image can also be uploaded to a computer device by a user via the Internet.
[0052] When the user needs to identify the color of a certain area in a color image, the user can use a calibration frame to select the area, and the area selected by the calibration frame is used as the region of interest. The shape of the calibration frame can be a square, a circle, an ellipse, an irregular polygon, etc.
[0053] In an optional embodiment, a color recognition interface may be displayed, such as Figure 2 As shown in FIG. 1 , the color recognition interface is used to synchronously display the color image and calibration frames of various shapes. After the user selects a calibration frame from among the various calibration frames, the user-selected calibration frame can be used to select an area of interest on the color image, such as Figure 3 As shown, the shape of the selected region of interest is consistent with the shape of the calibration box selected by the user.
[0054] The present application reduces the image processing amount by setting a ROI in the color image to be identified and performing color recognition on the image within the ROI, thereby improving the efficiency of image processing and color recognition.
[0055] In an optional implementation, the user's operation of moving, dragging, and scaling the calibration frame on the color image may also be received, so that the position and size of the calibration frame are more consistent with the position of the color that the user wants to identify.
[0056] In an optional implementation, before setting the region of interest in the color image, the method further includes:
[0057] The color image is subjected to denoising processing to obtain a denoised image.
[0058] There will be some noise in the color image to a greater or lesser extent. Noise refers to some random or irregular pixels in the color image. The appearance of these pixels will make the color image look blurry, distorted or grainy. In order to eliminate or reduce the noise in the color image and improve the accuracy of color recognition of the color image, the color image can be denoised.
[0059] Color images can be denoised using methods such as median filtering, mean filtering, and Gaussian filtering to smooth the color image and reduce the details and texture of the color image.
[0060] After the color image is denoised to obtain a denoised image, the denoised image is subsequently used as a recognition image for color recognition, for example, a region of interest is set in the denoised image.
[0061] S12, obtaining the pixel value of each pixel point in the region of interest in a specified color space.
[0062] The color space can be specified by the user, and all pixels in the region of interest are traversed to obtain the color component values of each color channel of each pixel in the specified color space, thereby obtaining the pixel value of each pixel in the specified color space. The color space specified by the user can be an RGB color space, an HSI color space, or an HSV color space.
[0063] RGB color space is a commonly used color representation method, which represents color as a combination of three components: red, green, and blue. In 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 specified color space is RGB color space, the pixel value of each pixel in the region of interest in RGB color space can be obtained.
[0064] HSI color space is another commonly used color representation method, which represents color as a combination of three components: hue, saturation, and brightness. In HSI 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 I channel. When the specified color space is the HSI color space, the region of interest can be first converted from the RGB color space to the HSI color space, and then the pixel value of each pixel in the region of interest in the HSI color space can be obtained.
[0065] HSV color space is another commonly used color representation method, which represents color as a combination of three components: hue, saturation, and value. In 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 specified color space is the HSV color space, the region of interest can be first converted from the RGB color space to the HSV color space, and then the pixel value of each pixel in the region of interest in the HSV color space can be obtained.
[0066] RGB, HSV and HSI are three color spaces that do not interfere with each other. The RGB color space is suitable for color images with a single color and low brightness, while the HSV color space and HSI color space are more suitable for images with diverse tones and high brightness. Compared with the HSV color space, the HSI color space is more intuitive and easy to operate in terms of understanding and controlling color images. Therefore, a color space can be specified according to the image characteristics of the color image and the demand for color representation, and subsequent color recognition of the color image can be performed in the specified color space.
[0067] For example, when the color image is an image of tropical fish in a coral reef or an image of gray stone, the RGB color space can be specified for color recognition processing; when the color image is an image that needs to distinguish color types and changes well, such as a flower image or a rainbow image, the HSI color space can be specified for color recognition processing; when the color image is a high-brightness color image, such as an image of a landscape under scorching sun, the HSV color space can be specified for color recognition processing.
[0068] S13, filtering abnormal pixels in the region of interest according to the pixel values to obtain a target processing region.
[0069] Since there are some noise points in the region of interest, which will affect the color recognition, it is necessary to filter out the abnormal pixels in the region of interest according to the pixel value, so as to obtain the target processing region. Performing color recognition based on the target processing region can improve the accuracy of color recognition.
[0070] In some embodiments, abnormal pixel detection can be performed on each pixel in the region of interest. If the pixel value of the pixel is significantly different from the average pixel value of the surrounding pixels, the pixel is considered to be an abnormal pixel. All abnormal pixels are removed from the region of interest to obtain the target processing area.
[0071] In some embodiments, the number of color component values of a specified channel in the pixel value can be calculated, and the first target pixel points corresponding to the color component values whose number is less than a preset number threshold can be obtained. The first target pixel points in the region of interest are filtered as abnormal pixels to obtain the target processing area.
[0072] The designated channel is a color channel in a designated color space, and a user may designate one or more color channels in the designated color space as the designated channel.
[0073] Projection mapping is used to count the number of different color component values in the specified color channel in the region of interest. When the number of color component values is less than the number threshold set by the user, the pixel point corresponding to the color component value is used as the first target pixel point, and the first target pixel point in the region of interest is filtered out as an abnormal pixel point to obtain the target processing area.
[0074] Exemplarily, assuming that the specified color space is the RGB color space, and the specified channel is the 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, the color component value 100 appears 50 times in the R channel, and the color component value 70 appears 10 times. 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 taken as the first target pixel, that is, the pixel whose color component value of the R channel is 70 among all the pixels in the region of interest is abnormal pixel.
[0075] Exemplarily, assuming that the specified color space is the RGB color space, and the specified channels are the R channel and the G channel, and the preset number thresholds corresponding to the R channel and the G channel are both 20, then 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, the color component value 100 appears 50 times in the R channel, the color component value 70 appears 10 times, the color component value 110 appears 60 times in the G channel, and the color component value 90 appears 15 times. 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 points corresponding to the color component value 70 in the R channel and the pixel points corresponding to the color component value 90 in the G channel are both used as first target pixels, that is, the pixel points whose color component value corresponding to the R channel in all the pixels in the region of interest is 70 are all abnormal pixels, and the pixel points whose color component value corresponding to the G channel in all the pixels in the region of interest is 90 are all abnormal pixels.
[0076] The above implementation method regards the pixel points whose color component values in the specified channel are less than a preset number threshold as abnormal points, which can filter out the outliers in the color component values and eliminate the influence of the noise generated by the outlier pixels on the color recognition of the area of interest, thereby improving the accuracy of color recognition.
[0077] In some embodiments, the color component value of a specified channel in the pixel value can be compared with a preset color component value range to obtain a second target pixel point corresponding to a color component value that is not within the preset color component value range, and the second target pixel point in the region of interest is filtered as an abnormal pixel point to obtain the target processing area.
[0078] Exemplarily, assuming that the specified color space is the RGB color space, and the specified channel is the 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). When the color component value of the R channel of a pixel is not within the preset color component value range, the pixel is used as the second target pixel, that is, all pixels in the region of interest whose R channel color component values are not within the preset color component value range are abnormal pixels.
[0079] In the above implementation, pixels whose color component values of a specified channel are not within a preset color component value range are filtered out as abnormal pixels, which can filter out inconsistent values in the color component values and eliminate the influence of noise generated by pixels with inconsistent values on the color recognition of the area of interest, thereby improving the robustness of color recognition.
[0080] It should be noted that the computer device may determine the abnormal pixel points according to a preset number threshold, or may determine the abnormal pixel points according to a preset color component value range, or may determine the abnormal pixel points according to both the preset number threshold and the preset color component value range. When determining the abnormal pixel points according to the preset number threshold and the preset color component value range, there is no restriction on the order of execution, and the abnormal pixel points may be determined according to the preset number threshold first, and then determined according to the preset color component value range, or the abnormal pixel points may be determined according to the preset color component value range first, and then determined according to the preset number threshold.
[0081] S14, performing weighted average calculation on the pixel values of the pixel points in the target processing area to obtain a weighted average value.
[0082] In an optional embodiment, the pixel values of the pixels 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 in the target processing area may be traversed, and if the color component value of a specified channel in the pixel value of the pixel is within a preset specified value range, the color component value of the specified channel in the pixel value of the pixel is added to a first preset weighted value to obtain a weighted pixel value of the pixel, and the color component value of the weighted pixel value of each pixel in the target processing area is averaged in the same channel to obtain the weighted average value.
[0083] One or more channels can be specified as designated channels.
[0084] Traverse each pixel point in the target processing area, that is, visit each pixel point one by one. For each pixel point, determine whether the color component value of the specified channel in the pixel value of the pixel point is within the preset specified numerical range. If the color component value of the specified channel in the pixel value of the pixel point is within the preset specified numerical range, add the color component value of the specified channel in the pixel value of the pixel point to the preset weighted value to obtain the weighted pixel value of the pixel point, and the weighted pixel value represents the result of adding the color component value of the pixel value on the specified channel to the first preset weighted value. In the same channel, the weighted pixel values of all pixels are averaged to obtain the average color component value on the channel as the weighted average value.
[0085] For example, assuming that the specified channel is the R channel, the specified numerical range is [25,50], and the first preset weighting value is 10, if the color component value of the R channel in the pixel value of a certain pixel point is 30, then since the color component value of the R channel in the pixel value of the pixel point is within the specified 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.
[0086] The weighting of the color component value of each pixel in the region of interest on the specified channel is called image grayscale weighting.
[0087] By weighting the image grayscale, it is possible to fade or enhance the image, change the image contrast and brightness, reduce the impact of the shooting environment on the image color, and improve the accuracy of image color recognition.
[0088] In an optional embodiment, the pixel values of the pixels in the target processing area may be averaged, and the averaged pixel values may be weighted to obtain a weighted average value. In a specific implementation, the average color component value of all the pixels in the target processing area on a specified channel may be calculated, and the average color component value on the specified channel may be added to a second preset weighted value to obtain the weighted average value.
[0089] A weighted range can also be pre-set. For each average color component value on a specified channel, a weighted value is randomly selected from the weighted range, and the average color component value on the specified channel is weighted with the corresponding selected weighted value to obtain a weighted average value.
[0090] For example, assuming that the standard pixel value of red in the preset color library is (255, 0, 0), the pixel value of a pixel in the area of interest is (250, 3, 2), the user specifies weighted processing of the average color component value of each channel, and the weighted range is [-5, 5]. Therefore, the average color component values of the R channel, G channel, and B channel are all weighted. After weighting, the pixel value of the current pixel is close to (255, 0, 0). It can be seen that after weighting the average color component value of the pixel in each channel, it is close to red, which is more conducive to the subsequent calculation of color similarity.
[0091] Since each pixel has color component values of three channels, it is necessary to calculate the average color component value of each channel separately. The weighting applied to the average color component value of the channel is called image channel weighting.
[0092] By weighting the image channels, the color of the color image on the specified channel can be made closer to the color value in the preset color library, thereby improving the accuracy of color recognition.
[0093] It should be noted that the computer device may calculate the weighted average value by image grayscale weighting, or by image channel weighting, or by both image grayscale weighting and image channel weighting. When the weighted average value is calculated by both image grayscale weighting and image channel weighting, there is no restriction on the order of execution. The weighted average value may be calculated by image grayscale weighting first, and then by image channel weighting. Alternatively, the weighted average value may be calculated by image channel weighting first, and then by image grayscale weighting.
[0094] 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.
[0095] The preset color library is a pre-set color library, which stores multiple standard pixel values. Each standard pixel value corresponds to a color label. The color label is used to distinguish different color categories and can be used to represent the color number or name or code. Different colors correspond to different color labels.
[0096] By calculating the similarity between the weighted average value and each standard pixel value, the color that is closest to or best matches the color image can be found.
[0097] In an optional implementation, 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:
[0098] Calculating the similarity between the weighted average value and each standard pixel value in the preset color library to obtain multiple similarities;
[0099] Determine a maximum similarity among the multiple similarities, and a target standard pixel value corresponding to the maximum similarity;
[0100] The color of the color image is determined according to the color label corresponding to the target standard pixel value.
[0101] The similarity can be calculated using different indicators, such as Euclidean distance, absolute value difference, cosine similarity or correlation coefficient. For each standard pixel value, the similarity is calculated with 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 close the color of the color image is to the color corresponding to the standard pixel value. The maximum similarity is determined from multiple 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 the target standard pixel value, which is used to represent the color most similar to the color image.
[0102] In an optional embodiment, the method may further include:
[0103] A color label corresponding to the determined color is displayed at a preset position away from the region of interest in the color image.
[0104] After the color of the region of interest is identified, a color label is used to display the identified color at a preset position away from the region of interest in the original color image, and the form of the color label is determined by the user or a preset label shape is selected.
[0105] For example, when the region of interest is determined to be a pattern on a beverage bottle and the identified color is lavender, a rectangle is used to display 5 cm away from the pattern in the color image, and the three words "lavender" are displayed in the rectangle, pointing to the region of interest.
[0106] The present application selects a region of interest in a color image. Since the number of pixels in the region of interest is relatively small compared to the entire color image, color recognition is performed based on the pixel value of each pixel in the region of interest in a specified color space, which helps to improve the efficiency of color recognition. By filtering abnormal pixels in the region of interest by pixel value, outliers or inconsistent values in color component values can be filtered out, thereby suppressing the noise or interference generated by abnormal pixels and improving the accuracy of color recognition. By performing weighted average calculation on the pixel values of the pixels in the target processing area, the perception of different colors can be adjusted, for example, brightness or saturation can be emphasized more, thereby improving the color distinction and the performance of color recognition. By performing weighted average calculation on the pixel values of the pixels in the target processing area, the color recognition problem under uneven illumination can be handled, color misjudgment caused by illumination changes can be reduced, and the robustness of color recognition can be improved. Finally, the color of the color image is determined according to the weighted average value and multiple standard pixel values in the preset color library, and the color recognition accuracy of the color image is high.
[0107] The present application can be applied to a variety of fields, such as computer vision, robot navigation, and autonomous driving. After color recognition of a color image, the present application can determine whether the color of the color image has a color cast. When a color cast occurs, the color deviation of the color image can be automatically corrected according to the recognized color, making the image more accurate and natural. The color image can also be classified according to the recognized color, thereby helping the automation system to automatically classify, retrieve, and recognize.
[0108] See also Figure 4FIG. 4 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. In a preferred embodiment of the present application, the computer device 4 includes a memory 41 , at least one processor 42 , and at least one communication bus 43 .
[0109] Those skilled in the art should understand that Figure 4 The structure of the computer device shown does not constitute a limitation of the embodiments of the present application, and may be either a bus structure or a star structure. The computer device 4 may also include more or less other hardware or software than shown in the figure, or a different arrangement of components.
[0110] In some embodiments, the computer device 4 is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application-specific integrated circuits, programmable gate arrays, digital processors, and embedded devices. The computer device 4 may also include other computer devices, which include but are not limited to any electronic product that can interact with a user through a keyboard, mouse, remote control, touchpad, or voice control device, such as a personal computer, tablet computer, smart phone, digital camera, etc.
[0111] It should be noted that the computer device 4 is only an example, and other existing or future electronic products that are suitable for the present application should also be included in the protection scope of the present application and included here by reference.
[0112] In some embodiments, the memory 41 stores a computer program, and when the computer program is executed by the at least one processor 42, all or part of the steps in the image color recognition method are implemented. 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 (OTPROM), an electronically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0113] In some embodiments, the at least one processor 42 is the control core (Control Unit) of the computer device 4, and uses various interfaces and lines to connect the various components of the entire computer device 4, and executes various functions and processes data of the computer device 4 by running or executing the program or module stored in the memory 41, and calling the data stored in the memory 41. For example, when the at least one processor 42 executes the computer program stored in the memory, it implements all or part of the steps of the image color recognition method described in the embodiment of the present application; or implements all or part of the functions of the image color recognition method. The at least one processor 42 can be composed of an integrated circuit, for example, it can be composed of a single packaged integrated circuit, or it can be composed of multiple integrated circuits with the same function or different functions, including one or more central processing units (CPU), microprocessors, digital processing chips, graphics processors, and various control chips.
[0114] In some embodiments, the at least one communication bus 43 is configured to realize connection and communication between the memory 41 and the at least one processor 42, etc. Although not shown, the computer device 4 may also include a power supply (such as a battery) for powering each component. Preferably, the power supply may be logically connected to the at least one processor 42 through power management, so as to realize functions such as management of charging, discharging, and power consumption management through power management. The power supply may also include any components such as one or more DC or AC power supplies, recharging power supply fault detection circuits, power converters or inverters, power status indicators, etc. The computer device 4 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0115] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to execute part of the method described in each embodiment of the present application.
[0116] In the several embodiments provided in this application, it should be understood that the disclosed methods can be implemented in other ways. For example, the embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0117] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, and may be located in one place or distributed on 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.
[0118] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and the appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear contrary indication in its context. It should also be understood that the term "and / or" used in the present application refers to any or all possible combinations containing one or more of the listed items. The terms "first" and "second" are only used for descriptive purposes and cannot be understood as implying or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" can expressly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise stated, the meaning of "multiple" is two or more.
[0119] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for image color recognition, characterized in that: The method comprises: Select the region of interest in the color image; Obtaining the pixel value of each pixel point in the region of interest in a specified color space; Filtering abnormal pixels in the region of interest according to the pixel values to obtain a target processing region; Performing weighted average calculation on the pixel values of the pixel points in the target processing area to obtain a weighted average value; 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, filtering abnormal pixels of the region of interest according to the pixel value to obtain a target processing region includes: Calculate the number of color component values of a specified channel in the pixel value, obtain the first target pixel point corresponding to the color component value whose number is less than a preset number threshold, filter the first target pixel point in the region of interest as an abnormal pixel point, and obtain the target processing area; and / or Compare the color component value of the specified channel in the pixel value with a preset color component value range, obtain a second target pixel point corresponding to a color component value that is not within the preset color component value range, and filter the second target pixel point in the region of interest as an abnormal pixel point to obtain the target processing region; The weighted average calculation of the pixel values of the pixel points in the target processing area to obtain the weighted average value includes: Traversing each pixel point in the target processing area, if the color component value of the specified channel in the pixel value of the pixel point is within a preset specified value range, adding the color component value of the specified channel in the pixel value of the pixel point to a first preset weighted value to obtain a weighted pixel value of the pixel point; The weighted pixel value of each pixel point in the target processing area is averaged by calculating the color component value in the same channel to obtain the weighted average value.
2. The image color recognition method according to claim 1, characterized in that: The weighted average calculation of the pixel values of the pixel points in the target processing area to obtain the weighted average value includes: The average color component value of all pixels in the target processing area on the specified channel is calculated, and the average color component value on the specified channel is added to the second preset weighted value to obtain the weighted average value.
3. The image color recognition method according to claim 1 or 2, characterized in that: 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: Calculating the similarity between the weighted average value and each standard pixel value in the preset color library to obtain multiple similarities; Determine a maximum similarity among the multiple similarities, and a target standard pixel value corresponding to the maximum similarity; The color of the color image is determined according to the color label corresponding to the target standard pixel value.
4. The image color recognition method according to claim 2, characterized in that: The method further comprises: A color label corresponding to the determined color is displayed at a preset position away from the region of interest in the color image.
5. The image color recognition method according to claim 2, characterized in that: Before setting the region of interest in the color image, the method further includes: Performing denoising processing on the color image to obtain a denoised image; Setting the region of interest in the color image includes setting the region of interest in the denoised image.
6. The image color recognition method according to claim 2, characterized in that: The step of obtaining the pixel value of each pixel point in the region of interest in the specified color space comprises: Obtaining a pixel value of each pixel point in the region of interest in an RGB color space, wherein the pixel value of each pixel point in the RGB color space includes 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 Convert the region of interest from RGB color space to HSI color space, and obtain a pixel value of each pixel point in the region of interest in the HSI color space, wherein the pixel value of each pixel point in the HSI color space includes a color component value of an H channel, a color component value of an S channel, and a color component value of an I channel; or The region of interest is converted from RGB color space to HSV color space, and the pixel value of each pixel point in the region of interest in the HSV color space is obtained, and the pixel value of each pixel point in the HSI color space includes 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.
7. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the image color recognition method according to any one of claims 1 to 6 when executing the computer program.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the image color recognition method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Vehicle body color recognition method
CN106650752A
Image data processing method and device, electronic equipment and storage medium
CN114266838A