Image color recognition method, computer equipment and storage medium
By extracting and analyzing the sky area features in the image, determining whether the image meets the color tuning conditions, and tuning the sky area when the conditions are met, the problems of poor color tuning effects and equipment resource occupation in the prior art are solved, and the problems of poor color tuning effects and equipment resource occupation in the prior art are improved. The efficiency and user experience of image processing.
Patent Information
- Application Number
- CN202310982195.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-04
- Publication Date
- 2025-02-14
AI Technical Summary
When shooting images under different lighting conditions, it is difficult to effectively identify and color the sky area, resulting in poor color tuning effects and occupying the computing power and power of the terminal equipment.
By obtaining the image to be identified, the sky area is extracted, and the target color area is determined in the area. Based on the characteristics of the target color area and the sky area, it is determined whether the image meets the color tuning conditions. If it is satisfied, the sky area will be colored.
It improves the reliability of image feature extraction, ensures effective color matching of the sky area when the color tuning conditions are met, avoids color tuning operations when the conditions are not met, and reduces the computing power and power consumption of the equipment.
Smart Images

Figure CN119444876A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure 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] When a user uses a terminal device to take an image, the beauty of color is more easily perceived than elements such as composition, light and shadow. Therefore, it is necessary to add an automatic post-color adjustment function based on the original image obtained by the camera, which can highlight the beauty of the picture. In an exemplary embodiment, the color adjustment function can adjust the color of a part of the image, for example, separately adjust the color of the sky part in the image, so as to effectively improve the color performance of the sky while keeping the ground color unchanged, so as to improve the visual effect of the image.
[0003] However, the color of the sky varies greatly, and is affected by many factors such as shooting angle, position of the sun, atmospheric haze concentration, weather, etc., so color adjustment is not necessary in all situations. For example, the effect of color adjustment on the sky is poor for scenes such as cloudy days, strong backlight, and dark clouds at night. Summary of the invention
[0004] The embodiments of the present disclosure at least provide an image color recognition method, a computer device, and a storage medium.
[0005] In a first aspect, an embodiment of the present disclosure provides an image color recognition method, comprising: acquiring an image to be recognized, and extracting a sky area in the image to be recognized; determining a target color area in the sky area, and determining image features of the image to be recognized based on the target color area and the sky area, wherein the color of the target color area is in a preset color range; and when it is determined that the image to be recognized meets a color adjustment condition based on the image features, adjusting the color of the sky area.
[0006] In a second aspect, an embodiment of the present disclosure further provides a computer device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the computer device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect are performed.
[0007] In a third aspect, the present application further provides a computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute the image color recognition method described in any one of the above items of the present application.
[0008] The above-mentioned technical scheme provided by the embodiment of the present application has at least the following advantages compared with the prior art: the method provided by the embodiment of the present application, after acquiring the image to be identified, can extract the sky area in the image to be identified, and determine the target color area in the sky area, so as to determine the image features of the image to be identified based on the sky area and the target color area, thereby eliminating the influence of pixels in other areas of the image to be identified, for example, pixels in the ground area on the image feature extraction, thereby improving the reliability of determining whether the image to be identified meets the color adjustment conditions based on the image features, and when it is determined that the image to be identified meets the color adjustment conditions, the sky area in the image to be identified is toned to ensure the visual effect of the image after color adjustment, or the color adjustment operation is not performed when the image to be identified does not meet the color adjustment conditions. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0010] Figure 1 A schematic diagram showing a flow chart of an image color recognition method provided by an embodiment of the present disclosure;
[0011] Figure 2a A schematic diagram of an image to be recognized provided by an embodiment of the present disclosure is shown;
[0012] Figure 2b A schematic diagram showing the processing result of the mask image after the mask is processed by the fast guided filtering provided by the embodiment of the present disclosure;
[0013] Figure 2c A schematic diagram showing a sky area provided by an embodiment of the present disclosure;
[0014] Figure 3a A schematic diagram of a method for determining the above-mentioned image features provided by an embodiment of the present disclosure is shown;
[0015] Figure 3b A schematic diagram of a process for determining the above-mentioned image features provided by an embodiment of the present disclosure is shown;
[0016] Figure 4 A schematic diagram of an image color recognition device provided by an embodiment of the present disclosure is shown;
[0017] Figure 5 A schematic diagram of a computer device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0019] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0020] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0021] According to research, when users use terminal devices to take images, the beauty of color is more easily perceived than elements such as composition, light and shadow. Therefore, it is necessary to add an automatic post-production color adjustment function based on the original image obtained by the camera, which can highlight the beauty of the picture. In an exemplary embodiment, the color adjustment function can adjust the color of a part of the image, for example, separately adjust the color of the sky part in the image, so as to effectively improve the color performance of the sky while keeping the ground color unchanged, so as to improve the visual effect of the image.
[0022] However, the color of the sky varies greatly, and is affected by many factors such as shooting angle, position of the sun, atmospheric haze concentration, weather, etc., so color adjustment is not necessary in all situations. For example, in scenes such as cloudy days, strong backlight, and dark clouds at night, the effect of color adjustment on the sky is poor. At the same time, this color adjustment operation will occupy the computing power of the terminal device, increase the image processing time, consume the device power, and affect the user experience.
[0023] Therefore, the situations in which color adjustment is required in the image can be distinguished. In an exemplary embodiment, the degree of backlighting can be estimated based on the grayscale histogram standard deviation combined with the sky ratio. Specifically, the image can be gray-converted, and the histogram standard deviation of the converted grayscale image can be determined. However, in the process of determining the histogram corresponding to the grayscale image, the ground area pixels are not excluded. Therefore, the histogram standard deviation may be affected by the ground area factor, and it is difficult to effectively characterize the sky situation.
[0024] Based on this, the present disclosure provides an image color recognition method, a computer device and a storage medium. In an embodiment of the present disclosure, after acquiring an image to be recognized, the sky area in the image to be recognized can be extracted, and a target color area can be determined in the sky area, so as to determine the image features of the image to be recognized based on the sky area and the target color area, thereby excluding the influence of pixels in other areas of the image to be recognized, for example, the influence of pixels in the ground area on the image feature extraction, thereby improving the reliability of determining whether the image to be recognized meets the color adjustment conditions based on the image features, and when it is determined based on the image features that the image to be recognized meets the color adjustment conditions, the sky area in the image to be recognized is toned to ensure the visual effect of the image after color adjustment, or the color adjustment operation is not performed when the image to be recognized does not meet the color adjustment conditions.
[0025] To facilitate understanding of this embodiment, a method for image color recognition provided by an embodiment of the present disclosure is first introduced in detail. The execution subject of the method for image color recognition provided by an embodiment of the present disclosure is generally a computer device with certain computing capabilities, and the computer device includes, for example, a terminal device or a server or other processing device. In some possible implementations, the method for image color recognition can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0026] See also Figure 1 FIG. 1 is a flow chart of an image color recognition method provided by an embodiment of the present disclosure. The method may include steps S101 to S105, wherein:
[0027] S101: Acquire an image to be recognized, and extract a sky area in the image to be recognized.
[0028] In the disclosed embodiment, an image can be captured by a camera function of a terminal device to obtain an image to be identified, wherein the terminal device can be a mobile phone, a tablet, etc. After the image to be identified is acquired, the image to be identified can be toned based on the image processing function of the terminal device.
[0029] In an exemplary embodiment, when adjusting the color of the image to be identified, the color adjustment can be performed separately according to the region type. In the present disclosure, the color adjustment for the sky region is considered. Based on this, the pixels in the image to be identified can be analyzed first to determine whether there are pixels belonging to the sky region in the image to be identified. If it is determined that there are pixels belonging to the sky region in the image to be identified, the pixels can be extracted, and the sky region in the image to be identified can be determined based on the extraction result, so as to perform subsequent color adjustment operations on the sky region.
[0030] S103: determining a target color region in the sky region, and determining image features of the image to be identified based on the target color region and the sky region, wherein the color of the target color region is within a preset color range.
[0031] In the disclosed embodiment, the target color can be used to indicate the color in the sky that is worth adjusting. Therefore, the sky area can be identified, and it can be determined whether the target color area is identified. If so, the step of determining the image features of the image to be identified is performed. If not, the image to be identified is abandoned. For example, the target color area can be a pure blue sky area.
[0032] When it is determined that there is a target color area in the sky area, features related to the target color area and the sky area can be extracted in the image to be identified to obtain image features. The image features can be used to analyze whether it is necessary to adjust the color of the sky area, thereby screening out images to be identified in scenes where there is no need for color adjustment, such as cloudy sky areas, strong backlighting, dark clouds, etc.
[0033] S105: When it is determined based on the image features that the image to be identified meets a color adjustment condition, color adjustment is performed on the sky area.
[0034] In the disclosed embodiment, the above-mentioned image features may include the backlight corresponding to the sky area, the color attribute statistics of the sky area, the proportion of the sky area and the target color area in the image to be identified, etc. Here, splicing can be performed based on the image features to obtain a feature vector, and the feature vector can be input into a pre-set classification model.
[0035] Here, a classification model may be pre-set, and based on the classification model, it is determined whether the image to be identified meets the color adjustment condition. For example, the classification model may be a binary classification model. If the result output by the binary classification model is 1, it is determined that the image to be identified meets the color adjustment condition. If the result output by the binary classification model is 0, it is determined that the image to be identified does not meet the color adjustment condition. In an exemplary embodiment, a feature vector corresponding to the above-mentioned image feature may be input into the above-mentioned classification model to obtain an output result.
[0036] It should be understood that when the image to be identified meets the color adjustment conditions, it means that there is a need to adjust the sky area of the image to be identified. For example, the color of the sky area is worth adjusting, and the proportion of the area occupied by the sky area in the image to be identified is large enough, so there is a need for color adjustment.
[0037] When adjusting the color of the sky area, the color attribute of the sky area in the image to be identified can be analyzed based on the image features, so as to adjust the color of the sky area based on the color attribute, wherein the color attribute can be used to indicate the color interval to which the sky area belongs. In an exemplary embodiment, a feature related to the color of the sky area can be determined from the image features, and an analysis is performed based on the feature to obtain the color attribute of the sky area.
[0038] It can be seen from the above description that in the embodiment of the present disclosure, after acquiring the image to be identified, the sky area in the image to be identified can be extracted, and the target color area can be determined in the sky area, so as to determine the image features of the image to be identified based on the sky area and the target color area, thereby excluding the influence of pixels in other areas of the image to be identified, for example, the influence of ground area pixels on the image feature extraction, thereby improving the reliability of determining whether the image to be identified meets the color adjustment conditions based on the image features, and when it is determined that the image to be identified meets the color adjustment conditions, the sky area in the image to be identified is toned to ensure the visual effect of the image after color adjustment.
[0039] In addition, if the image to be identified does not meet the color adjustment conditions, the color adjustment operation will not be performed, which can shorten the image processing time, reduce the computing power occupied by the terminal device, save device power, and improve the user experience.
[0040] In an optional implementation, the above step S101, extracting the sky area in the image to be identified, may include the following process:
[0041] S1011: Determine non-sky pixel points and sky pixel points in the image to be identified based on a preset classification model.
[0042] S1012: Obtain a mask image corresponding to the sky pixel point, and determine the sky area based on the mask image.
[0043] In an embodiment of the present disclosure, the above-mentioned preset classification model can be a binary classification model, which can segment the image to be identified based on the pixel points of the image to be identified. In an exemplary embodiment, the pixel points in the image to be identified can be divided into sky pixels and non-sky pixels.
[0044] Next, the alpha mask of the image area corresponding to the sky pixel in the image to be identified can be obtained, and the image to be identified and the alpha mask can be sampled separately to obtain samples of smaller size, thereby reducing the amount of calculation in the processing process. Then, the sample can be processed using a fast guided filter to refine the edge of the alpha mask to obtain a mask image. In an exemplary embodiment, Figure 2a Schematic diagram of the image to be recognized. Figure 2b The figure shows a schematic diagram of the processing result after fast guided filtering of the mask image.
[0045] It should be understood that in the above mask image, the pixels in the non-sky area can be set to 0. Based on this, the pixel values of the image to be identified can be multiplied with the mask image. Since the result of multiplying 0 and any value is 0, the multiplication result finally obtained only includes the sky area in the image to be identified. In an exemplary embodiment, the image of the sky area is as follows: Figure 2c shown.
[0046] In the disclosed embodiment, the sky area in the image to be identified can be extracted, thereby preventing the non-sky area from affecting the extraction result when the image features are subsequently extracted.
[0047] In an optional embodiment, the above Figure 1 The corresponding embodiment may also include the following process:
[0048] S11: preprocessing the sky area to obtain a normalized standard deviation of a normalized histogram of the sky area.
[0049] S12: Determine a first proportion of the sky area in the image to be identified.
[0050] S13: Acquire device parameters of a camera device that captures the image to be recognized, and read the focal length coefficient of the image to be recognized from the device parameters.
[0051] S14: Determine the backlight degree of the sky area based on the product of the normalized standard deviation, the first ratio and the focal length coefficient.
[0052] S15: Determine the backlight type of the sky area according to a comparison result between the backlight and a backlight threshold.
[0053] In the disclosed embodiment, first, a normalized histogram of the sky area can be determined, and the normalized standard deviation of the normalized histogram can be determined. The specific method for determining the normalized standard deviation is described as follows and will not be described in detail here. Next, a judgment threshold Th1 can be obtained, and based on the Th1, the sky area pixels and the non-sky area pixels in the image to be identified can be determined, thereby determining the first proportion of the sky area in the image to be identified. In an exemplary embodiment, the sky area pixel range and the non-sky area pixel range can be determined based on the Th1.
[0054] For example, the alpha mask corresponding to the image to be identified can be obtained. If the pixel range of the alpha mask is [0, 1], and the judgment threshold Th1 = 0.4, the pixel range of the sky area can be [0.4, 1.0] and the pixel range of the non-sky area can be [0, 0.4).
[0055] In an exemplary embodiment, the pixels in the alpha mask that fall within the sky area pixel range may be determined as sky area pixels, and the pixels that fall within the non-sky area pixel range may be determined as non-sky area pixels. Then, the number of sky area pixels num_sky and the number of non-sky area pixels num_nonsky may be counted. Next, the first ratio sky_ratio of the sky area pixels to the entire image may be counted, where:
[0056]
[0057] After determining the first proportion sky_ratio, the device parameters of the camera device that shoots the image to be identified can be obtained, and the focal length coefficient f of the image to be identified is read from the device parameters, and the backlight backlight_prob of the sky area is determined based on the product of the normalized standard deviation sky_std_normal, the first proportion sky_ratio and the focal length coefficient f, where:
[0058] backlight_prob=f×sky_ratio×sky_std_normal
[0059] After determining the backlight_prob of the sky area, the backlight threshold Th2 can be obtained. When the backlight_prob is greater than Th2, the backlight type of the sky area can be determined to be the sky backlight type; when the backlight_prob is not greater than Th2, the backlight type of the sky area can be determined to be the sky non-backlight type.
[0060] In the embodiment of the present disclosure, considering that when there is strong backlighting in the sky area in the image to be identified, the color adjustment effect on the sky area is not obvious, therefore, the backlighting type of the sky area can be determined, thereby screening out the images to be identified whose backlighting type of the sky area is the sky non-backlighting type, so as to perform subsequent identification processing on the images to be identified of the non-backlighting type.
[0061] In an optional implementation, the above step S11, preprocessing the sky area to obtain a normalized standard deviation of a normalized histogram of the sky area, may include the following process:
[0062] (1) Obtaining a brightness channel image corresponding to the sky area;
[0063] (2) Based on the grayscale, the grayscale range of the brightness channel image is compressed, and a normalized histogram is statistically calculated based on the compression result to determine a normalized standard deviation based on the normalized histogram, wherein the grayscale is smaller than the grayscale range.
[0064] In the disclosed embodiment, considering that the image to be identified captured by the above-mentioned terminal device is often an RGB (three color channels of red, green, and blue) image, the RGB image can be converted into an HSV (hue, saturation, and value) image. Then, the lightness V channel image can be extracted, and the lightness V channel image can be grayscale compressed to reduce the grayscale range of the lightness V channel image, so as to facilitate the determination of the normalized histogram h_sky of the lightness V channel image after compression.
[0065] In an exemplary embodiment, the grayscale range of the original brightness V channel image may be [0, 255], and the grayscale level after compression is set to n1. The grayscale range may be divided by the grayscale level n1 to perform grayscale compression on the brightness V channel image, and the grayscale range of the compressed image may be [0, n1-1]. The normalized histogram h_sky of the grayscale compressed image is obtained by statistics, h_sky = (h_sky0, h_sky1, ..., h_skyn1), the histogram standard deviation sky_std is calculated based on the normalized histogram, and sky_std is normalized to obtain the normalized standard deviation sky_std_normal, where:
[0066]
[0067]
[0068] In the embodiment of the present disclosure, the grayscale range of the luminance channel image can be compressed based on the grayscale, and a normalized histogram can be statistically analyzed based on the compression result to determine the normalized standard deviation based on the normalized histogram, thereby providing a technical basis for the subsequent determination of the backlight type of the sky area.
[0069] In an optional implementation, when it is determined that the backlight type of the sky area is the first type, and the first type is used to indicate that the sky area is a non-backlight image area, the above step S103, determining the target color area in the sky area, may include the following process:
[0070] S21: Obtain a compression ratio corresponding to the sky area, and input the compression ratio into a preset image segmentation model to obtain a segmentation threshold.
[0071] S22: Segment the sky area based on the segmentation threshold, and determine a target color area in the sky area according to the segmentation result.
[0072] In the embodiment of the present disclosure, the target color area may be a pure blue sky area in the sky area, and the minimum cross entropy algorithm is integrated into the preset image segmentation model to calculate the segmentation threshold t through the minimum cross entropy algorithm.
[0073] In an exemplary embodiment, the normalized red-to-blue ratio R_rb of each pixel in the sky area of the image to be identified in the RGB color space can be calculated to obtain a corresponding single-channel feature map. Here, the red-to-blue ratio R_rb can be used to indicate the ratio of the red channel value to the blue channel value of the corresponding pixel, where:
[0074]
[0075] Here, b(x,y) and r(x,y) are respectively the blue channel value and the red channel value of the pixel at (x,y) of the image to be identified. It should be understood that in the normalized red-to-blue ratio feature map, the value range of R_rb is [-1,1].
[0076] In the disclosed embodiment, the feature map of R_rb can be transformed into a histogram. In an exemplary implementation, the number of preset square map intervals n2 can be determined first, and n2 can be used as the above compression ratio to compress the feature map of R_rb according to the compression ratio to obtain a histogram h_rb of R_rb, h_rb = (h_rb0, h_rb1, ..., h_rb n2). Then, the segmentation threshold can be calculated by the minimum cross entropy formula as shown below:
[0077] t=arg min{-m(1,t)log[u(1,t)]-m(t+1,n2)log[u(t+1,n2)]}, where,
[0078] After the segmentation threshold t is determined, the sky area may be segmented based on the segmentation threshold t, and pixels smaller than the segmentation threshold t may be determined as pixels of the target color area.
[0079] In an exemplary embodiment, the search range corresponding to the segmentation threshold t is [0, 1]. For this, the search range can be mapped to the pixel range in the RGB color space, so as to facilitate the screening of pixels in the target color area based on the pixel values of the pixels. For example, if the segmentation threshold t is 0.3 and the pixel range in the RGB color space is [0, 255], then the pixels in the pixel range of [0, 77] can be determined as pixels in the target color area, thereby determining the target color area.
[0080] In the embodiments of the present disclosure, considering that when adjusting the color of the sky area, the main color adjustment target is the target color area, therefore, the present disclosure can segment the sky area and determine the target color area in the sky area based on the segmentation result, so as to facilitate the subsequent analysis of the color adjustment of the image to be identified based on the target color area.
[0081] In an optional implementation, when it is determined that the backlight type of the sky area is the second type, and the second type is used to indicate that the sky area is a backlight image area, the above step S103 of determining the target color area in the sky area may further include the following process:
[0082] S31: Acquire a saturation channel image corresponding to the sky area, and determine a first pixel point in the saturation channel image whose pixel value is less than a pixel value threshold.
[0083] S32: Determine a second pixel point that matches the target color interval among the first pixel points, and determine a target color area according to the second pixel point.
[0084] In the embodiment of the present disclosure, firstly, the third pixel point whose red-to-blue ratio is negative in the above-mentioned R_rb feature map, that is, the pixel point whose red-to-blue ratio is less than 0, can be excluded from the sky area image. It should be understood that the third pixel point belongs to the non-sky area, for example, the earth area.
[0085] Next, the saturation channel image corresponding to the image to be identified in the above HSV image can be obtained, and the fourth pixel belonging to the target color area can be determined in the sky area of the saturation channel image. In an exemplary embodiment, a pixel with a saturation S greater than 20% can be determined as the fourth pixel.
[0086] After excluding the third pixel and the fourth pixel in the above-mentioned sky area, the remaining pixel points in the sky area can be determined as the above-mentioned first pixel points, and the probability value of each pixel in the first pixel points belonging to the target color area is calculated to determine the second pixel point matching the target color interval based on the probability value. The specific method for calculating the probability value is described as follows and will not be described in detail here.
[0087] In the embodiment of the present disclosure, considering that when the sky area is a backlit image area, the color changes of the area near the sun in the sky are complex and there is no definite rule, the effect of using the above minimum cross entropy method to segment the sky area is not good. Therefore, the target color area can be determined based on the saturation channel image corresponding to the sky area, thereby increasing the scope of application of the present disclosure.
[0088] In an optional implementation, the above step S32, determining the second pixel point matching the target color interval in the first pixel point, may include the following process:
[0089] (1) determining a probability value of each pixel in the first pixel points based on preset calculation parameters and a Euclidean distance between pixel values of each pixel in the first pixel points;
[0090] (2) Determine a pixel point whose probability value exceeds a target color threshold among the first pixel points, and determine the pixel point as a second pixel point.
[0091] In the embodiment of the present disclosure, the above-mentioned preset calculation parameters include the RGB channel c of the image to be identified, the standard deviation σ of the kernel function, the sampling pixel point bluesky in the fourth pixel point, and the pixel value range [0, n3] corresponding to bluesky, wherein, when determining the sampling pixel point bluesky, the pixel value range [0, n3] can be intercepted in the pixel value range of the fourth pixel point, and the pixel point with a pixel value located at [0, n3] is determined as the sampling pixel point bluesky.
[0092] Next, the Euclidean distance between the RGB pixel values of each pixel in the first pixel can be calculated, and the multivariate Gaussian kernel function K can be determined based on the Euclidean distance, and the probability value p of each pixel in a pixel can be calculated by the following formula: i :
[0093]
[0094]
[0095] Among them, p i is the probability that the i-th pixel in the first pixel belongs to the target color area. j is the serial number of the first pixel, and its value range is [0, n3].
[0096] Next, the target color threshold Th3 can be obtained, and the probability value p in the first pixel can be i Pixels with a color value less than Th3 are determined as pixels of non-target color thresholds, such as white cloud areas, and the probability value p i The pixel point not less than Th3 is determined as the second pixel point of the target color threshold.
[0097] In the embodiment of the present disclosure, considering that when the sky area is a backlit image area, the color changes of the area near the sun in the sky are complex and there is no definite rule, the effect of using the above minimum cross entropy method to segment the sky area is not good. Therefore, the target color area can be determined based on the saturation channel image corresponding to the sky area, thereby increasing the scope of application of the present disclosure.
[0098] In an optional implementation, the above step S103, determining the image features of the image to be identified based on the target color area and the sky area, may include the following process:
[0099] S41: Determine a first proportion of the sky area in the image to be identified, and determine a second proportion of the target color area in the sky area.
[0100] S42: extracting the channel means corresponding to each color parameter of the target color area in the preset color space respectively to obtain a collection of channel means.
[0101] S43: Obtain the backlight intensity corresponding to the sky area, and determine the image feature according to the first proportion, the second proportion, the channel mean value collection and the backlight intensity.
[0102] In the disclosed embodiment, the number of pixels num_sky in the sky area and the total number of pixels in the image to be identified can be determined first, and the first ratio sky_ratio can be determined based on the ratio of num_sky to the total data. Then, the number of pixels num_bluesky in the target color area in the sky area can be determined, and the second ratio bluesky_ratio can be determined based on the ratio of num_sky to num_bluesky.
[0103] Next, the HSV image corresponding to the image to be identified can be obtained. In the HSV image, the hue H value range is [0,360], the saturation S value range is [0,100%], and the lightness V value range is [0,100%]. Then, the channel mean set corresponding to each channel of the HSV image can be calculated, and the channel mean includes: the mean h_mean of the hue channel H, the mean s_mean of the saturation channel S, and the mean v_mean of the lightness channel V:
[0104]
[0105]
[0106]
[0107] Among them, pix_h is the value of the hue channel of the target color area, pix_s is the value of the saturation channel of the target color area, and pix_v is the value of the saturation channel of the target color area. Then, the backlight prob can be obtained.
[0108] It should be understood that the above h_mean, s_mean and v_mean are color statistical attributes of the target color area in the image to be identified, backlight_prob reflects the degree of backlight in the sky area, and sky_ratio and bluesky_ratio reflect the actual shooting range and shooting angle of the terminal device when shooting the image to be identified to a certain extent. Based on this, h_mean, s_mean, v_mean, backlight_prob, sky_ratio and bluesky_ratio can be determined as the above image features.
[0109] In this public embodiment, the image features of the image to be identified can be determined based on the target color area and the sky area, thereby eliminating the influence of the non-sky area in the image to be identified, so that the determined image features can be used to characterize the sky.
[0110] See also Figure 3a As shown, it is a schematic diagram of a method for determining the above-mentioned image features provided by an embodiment of the present disclosure, see Figure 3b FIG. 1 is a flow chart of the method for determining the above-mentioned image features. Specifically, the method includes steps S301 to S313, wherein:
[0111] S301: Determine the mask image in the image to be recognized.
[0112] S302: performing downsampling processing and fast guided filtering on the mask image to refine the alpha mask edge.
[0113] S303: performing alpha fusion on the image to be recognized and the mask image after refining the alpha mask edge to obtain a sky area.
[0114] In the embodiment of the present disclosure, the process of determining the mask image and the edge of the refined alpha mask, and determining the sky area is as described in the embodiment corresponding to the above step S101, and will not be repeated here.
[0115] S304: Calculate the first ratio sky_ratio based on the sky area.
[0116] S305: Convert the RGB image to the HSV image for the sky area, and determine the brightness channel map corresponding to the HSV image.
[0117] S306: Based on the grayscale, the grayscale range of the brightness channel image is compressed, and a normalized histogram (i.e., grayscale compression map) is statistically normalized based on the compression result, wherein the compression process includes grayscale quantization and histogram equalization.
[0118] S307: Determine the backlight degree of the sky area.
[0119] In the disclosed embodiment, the method for determining the backlight intensity of the sky area is as described in the embodiment corresponding to the above steps S11-S15, and will not be repeated here.
[0120] S308: Determine the backlight type of the sky area according to the comparison result between the backlight and the backlight threshold, if yes, execute S309, if no, execute S310.
[0121] S309: Determine a second pixel point among the first pixel points, and determine a target color area according to the second pixel point.
[0122] In the embodiment of the present disclosure, the sky area includes the first pixel, the third pixel and the fourth pixel. The specific method of determining the target color area according to the second pixel is as described in the embodiment corresponding to the above step S103, which will not be repeated here.
[0123] S310: Determine the feature map of R_rb corresponding to the above image to be identified, and determine the target color area through the above minimum cross entropy algorithm.
[0124] In the disclosed embodiment, the feature map of R_rb corresponding to the above-mentioned image to be identified is determined, and the method of determining the target color area through the above-mentioned minimum cross entropy algorithm is as described in the embodiment corresponding to the above-mentioned step S103, which will not be repeated here.
[0125] S311: Determine a second proportion of the target color area in the sky area.
[0126] S312: Determine the HSV image of the target color area.
[0127] S313: Based on the HSV image of the target color area, determine a collection of channel means.
[0128] In the embodiment of the present disclosure, the channel mean collection includes the hue channel mean, the saturation channel mean and the lightness channel mean. The method for determining the above channel mean collection is as described in the embodiment corresponding to the above steps S41-S43, and will not be repeated here.
[0129] In summary, in the embodiments of the present disclosure, after acquiring the image to be identified, the sky area in the image to be identified can be extracted, and the target color area can be determined in the sky area, so as to determine the image features of the image to be identified based on the sky area and the target color area, thereby excluding the influence of pixels in other areas of the image to be identified, for example, the influence of pixels in the ground area on the image feature extraction, thereby improving the reliability of determining whether the image to be identified meets the color adjustment conditions based on the image features, and when it is determined that the image to be identified meets the color adjustment conditions, the sky area in the image to be identified is toned to ensure the visual effect of the image after color adjustment, or the color adjustment operation is not performed when the image to be identified does not meet the color adjustment conditions.
[0130] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0131] Based on the same inventive concept, an image color recognition device corresponding to the image color recognition method is also provided in the embodiment of the present disclosure. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned image color recognition method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0132] Reference Figure 4 FIG. 4 is a schematic diagram of an image color recognition device provided by an embodiment of the present disclosure, wherein the device comprises: an extraction unit 41, a determination unit 42, and a color adjustment unit 43; wherein:
[0133] Extraction unit 41: obtains an image to be identified, and extracts a sky area in the image to be identified;
[0134] A determination unit 42 is configured to determine a target color region in the sky region, and determine image features of the image to be identified based on the target color region and the sky region, wherein the color of the target color region is within a preset color range;
[0135] The color adjustment unit 43 performs color adjustment on the sky area when it is determined based on the image feature that the image to be identified meets the color adjustment condition.
[0136] In an embodiment of the present disclosure, after acquiring an image to be identified, a sky area in the image to be identified can be extracted, and a target color area can be determined in the sky area, so as to determine image features of the image to be identified based on the sky area and the target color area, thereby eliminating the influence of pixels in other areas of the image to be identified, for example, pixels in the ground area on the image feature extraction, thereby improving the reliability of determining whether the image to be identified meets the color adjustment conditions based on the image features, and when it is determined that the image to be identified meets the color adjustment conditions, the sky area in the image to be identified is toned to ensure the visual effect of the image after color adjustment, or the color adjustment operation is not performed when the image to be identified does not meet the color adjustment conditions.
[0137] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0138] For descriptions of the processing flow of each unit in the device and the interaction flow between each unit, reference may be made to the relevant descriptions in the above method embodiments, which will not be described in detail here.
[0139] Corresponds to Figure 1 The image color recognition method in the present disclosure also provides a computer device 500, such as Figure 5 FIG. 5 is a schematic diagram of the structure of a computer device 500 provided in an embodiment of the present disclosure, including:
[0140] Processor 51, memory 52, and bus 53; memory 52 is used to store execution instructions, including memory 521 and external memory 522; memory 521 here is also called internal memory, which is used to temporarily store operation data in processor 51 and data exchanged with external memory 522 such as hard disk. Processor 51 exchanges data with external memory 522 through memory 521. When the computer device 500 is running, the processor 51 communicates with the memory 52 through bus 53, so that the processor 51 executes the following instructions:
[0141] Acquire an image to be identified, and extract a sky area in the image to be identified;
[0142] Determining a target color region in the sky region, and determining image features of the image to be identified based on the target color region and the sky region, wherein the color of the target color region is within a preset color range;
[0143] When it is determined based on the image feature that the image to be identified meets the color adjustment condition, the sky area is adjusted in color.
[0144] The present disclosure also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the steps of the image color recognition method described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0145] The embodiments of the present disclosure also provide a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of the image color recognition method described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0146] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0147] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0148] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0149] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0150] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0151] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the aforementioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the aforementioned embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be based on the protection scope of the claims.
Claims
1. A method for image color recognition, characterized in that: include: Acquire an image to be identified, and extract a sky area in the image to be identified; Determining a target color region in the sky region, and determining image features of the image to be identified based on the target color region and the sky region, wherein the color of the target color region is within a preset color range; When it is determined based on the image feature that the image to be identified meets the color adjustment condition, the sky area is adjusted in color.
2. The method according to claim 1, characterized in that The method further comprises: Preprocessing the sky area to obtain a normalized standard deviation of a normalized histogram of the sky area; Determining a first proportion of the sky area in the image to be identified; Acquire device parameters of a camera device that captures the image to be recognized, and read the focal length coefficient of the image to be recognized from the device parameters; Determining the backlighting degree of the sky area based on the product of the normalized standard deviation, the first ratio, and the focal length coefficient; The backlight type of the sky area is determined according to a comparison result between the backlight level and a backlight level threshold.
3. The method according to claim 2, characterized in that The preprocessing based on the sky area to obtain a normalized standard deviation of a histogram of the sky area includes: Obtaining a brightness channel image corresponding to the sky area; Based on the grayscale, the grayscale range of the brightness channel image is compressed, and a normalized histogram is statistically calculated based on the compression result to determine a normalized standard deviation based on the normalized histogram, wherein the grayscale is smaller than the grayscale range.
4. The method according to claim 2, characterized in that: In a case where it is determined that the backlight type of the sky area is a first type, and the first type is used to indicate that the sky area is a non-backlight image area; Determining a target color area in the sky area comprises: Obtaining a compression ratio corresponding to the sky area, and inputting the compression ratio into a preset image segmentation model to obtain a segmentation threshold; The sky region is segmented based on the segmentation threshold, and a target color region is determined in the sky region according to the segmentation result.
5. The method according to claim 2, characterized in that: In a case where it is determined that the backlight type of the sky area is the second type, and the second type is used to indicate that the sky area is a backlight image area; Determining a target color area in the sky area comprises: Acquire a saturation channel image corresponding to the sky area, and determine a first pixel point in the saturation channel image whose pixel value is less than a pixel value threshold; A second pixel point matching the target color range is determined among the first pixel points, and a target color area is determined according to the second pixel point.
6. The method according to claim 5, characterized in that the step of determining a second pixel point matching a target color interval in the first pixel point comprises: Determine a probability value of each pixel in the first pixel points based on a preset calculation parameter and a Euclidean distance between pixel values of each pixel in the first pixel points; A pixel point whose probability value exceeds a target color threshold is determined among the first pixel points, and the pixel point is determined as a second pixel point.
7. The method according to claim 1, characterized in that The step of determining the image features of the image to be identified based on the target color area and the sky area includes: Determine a first proportion of the sky area in the image to be identified, and determine a second proportion of the target color area in the sky area; Respectively extracting the channel means corresponding to each color parameter of the target color area in the preset color space to obtain a collection of channel means; The backlight intensity corresponding to the sky area is obtained, and the image feature is determined according to the first proportion, the second proportion, the channel mean value collection, and the backlight intensity.
8. The method according to claim 1, characterized in that The step of extracting the sky area in the image to be identified comprises: Based on a preset classification model, determining non-sky pixels and sky pixels in the image to be identified; A mask image corresponding to the sky pixel point is obtained, and the sky area is determined based on the mask image.
9. A computer device, characterized in that: include: One or more processors, one or more memories and a bus, wherein the one or more memories store machine-readable instructions executable by the one or more processors. When the computer device is running, the one or more processors communicate with the one or more memories via the bus, and when the machine-readable instructions are executed by the processor, the steps of the image color analysis method according to any one of claims 1 to 8 are performed.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the image color analysis method according to any one of claims 1 to 8 are executed.
Citation Information
Cited By
Image color adjustment method and device, equipment, medium and product
CN121258857A