An image processing method, apparatus and electronic device

By automatically detecting the intensity and direction of the color cast of the image and adopting a matching color cast correction strategy to correct the image, the color cast problem caused by the color temperature difference in the image acquisition device is solved and the image processing efficiency is improved.

CN115984129BActive Publication Date: 2025-10-10HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211633992.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-19
Publication Date
2025-10-10
Estimated Expiration
2042-12-19

AI Technical Summary

Technical Problem

In the prior art, images captured by image acquisition devices suffer from color cast due to color temperature differences, and manual processing is inefficient and cannot effectively improve the image restoration degree.

Method used

By automatically detecting the intensity and direction of the color cast of an image, the image is corrected using a matching color cast correction strategy, including global and local color cast correction, and pixel value distribution and white balance processing, and image processing is automated to improve efficiency.

Benefits of technology

It realizes automatic image color cast correction, shortens the processing cycle, improves image processing efficiency and reduces manual intervention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115984129B_ABST
    Figure CN115984129B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide an image processing method and device and electronic equipment, and relate to the technical field of image processing. An image to be processed is obtained. The color cast intensity of the image to be processed is determined according to the distribution of specified pixel values of each pixel point in the image to be processed. If the color cast intensity meets a preset color cast requirement, the color cast type of the image to be processed is determined, and the color cast direction of the image to be processed is determined based on the distribution. The color cast type includes global color cast or local color cast. A color cast correction strategy matched with the color cast type and the color cast direction is used to perform color cast correction on the image to be processed to obtain a target image. Compared with related technologies, the scheme provided in the embodiments of the present application can improve the image processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing, and in particular to an image processing method and device and electronic equipment. BACKGROUND

[0002] With the continuous development of electronic technology, various image acquisition devices are widely used in various scenes. For example, photographers use cameras to take landscape photos; cameras are used in traffic networks to collect vehicle violation information, etc.

[0003] For any image acquisition scene, there is a color temperature difference between objects to be acquired under different lightings. For example, there is a color temperature difference between the sunlit area and the shadow area of the same road; there is a color temperature difference between the same object under the light of a night mobile vehicle, the light of a road lighting, and the compensation light of an image acquisition device, etc. Thus, the color temperature difference will affect the images acquired by the image acquisition device, causing the images to have different degrees of color cast phenomenon, thereby reducing the restoration degree of the acquired images to the real scene.

[0004] In related technologies, after the image acquisition device acquires an image, the acquired image is manually detected for color cast one by one, and the image with color cast problem is processed. Thus, due to the long cycle of manual processing, the efficiency of color cast processing is low. SUMMARY

[0005] The purpose of the embodiments of the present application is to provide an image processing method, device and electronic equipment to improve the image processing efficiency. The specific technical solutions are as follows:

[0006] In a first aspect, the embodiments of the present application provide an image processing method, which comprises:

[0007] acquiring a to-be-processed image;

[0008] determining a color cast intensity of the to-be-processed image according to the distribution of the specified pixel value of each pixel point in the to-be-processed image;

[0009] if the color cast intensity meets a preset color cast requirement, determining a color cast type of the to-be-processed image, and determining a color cast direction of the to-be-processed image based on the distribution; wherein the color cast type includes global color cast or local color cast;

[0010] using a color cast correction strategy matched with the color cast type and the color cast direction to perform color cast correction on the to-be-processed image to obtain a target image.

[0011] Optionally, in a specific implementation, the designated pixel values ​​include first-category pixel values ​​and second-category pixel values, and determining the color cast intensity of the image to be processed based on the distribution of the designated pixel values ​​of each pixel point in the image to be processed includes:

[0012] Calculating a first mean of first-category pixel values ​​of each pixel point in the image to be processed and a second mean of second-category pixel values ​​of each pixel point in the image to be processed, and calculating a color cast intensity of the image to be processed using the first mean and the second mean;

[0013] Determining the color cast direction of the image to be processed based on the distribution includes:

[0014] The color cast direction of the image to be processed is determined according to the relationship between the first mean value and the second mean value and the specified numerical range respectively.

[0015] Optionally, in a specific implementation, if the color cast intensity satisfies a preset color cast requirement, determining the color cast type of the image to be processed includes:

[0016] If the color cast intensity is greater than a first intensity threshold, determining that the color cast type of the image to be processed is global color cast;

[0017] If the color cast intensity is less than the first intensity threshold and greater than a second intensity threshold, it is determined that the color cast type of the image to be processed is local color cast; wherein the second intensity threshold is less than the first intensity threshold.

[0018] Optionally, in a specific implementation, the image to be processed is a CIELAB image; the first category pixel value is an a color channel value; the second category pixel value is a color channel value;

[0019] The calculating the color cast intensity of the image to be processed by using the first mean and the second mean includes:

[0020] Calculating the average chromaticity of the image to be processed by using the sum of the squares of the first mean and the second mean;

[0021] Calculating a third mean of each first difference and a fourth mean of each second difference, and calculating the chromaticity center distance of the image to be processed using the sum of the squares of the third mean and the fourth mean; wherein each first difference is a difference between a first-category designated pixel value of a pixel point in the image to be processed and the first mean, and each second difference is a difference between a second-category designated pixel value of a pixel point in the image to be processed and the second mean;

[0022] The ratio of the average chromaticity to the chromaticity center distance is calculated as the color cast intensity of the image to be processed.

[0023] Optionally, in a specific implementation, the image to be processed is a YUV image; the first type of pixel value is a U component value, and the second type of pixel value is a V component value;

[0024] The calculating the color cast intensity of the image to be processed by using the first mean and the second mean includes:

[0025] Calculating a third difference and a fourth difference between the first mean and the second mean and a preset center value, respectively; wherein the preset center value is determined based on the number of bits of the image to be processed;

[0026] A sum of squares of the third difference and the fourth difference is calculated, and a positive root of the sum of squares is calculated as the color cast intensity of the image to be processed.

[0027] Optionally, in a specific implementation, the color cast type includes: global color cast;

[0028] The method of adopting a color cast correction strategy that matches the color cast type and the color cast direction to perform color cast correction on the image to be processed to obtain a target image includes:

[0029] White balance processing is performed on the image to be processed, and during the processing, the proportion of the white balance gain of the colors included in the color cast direction in the white balance gain sum value of all colors is reduced to obtain a target image.

[0030] Optionally, in a specific implementation, the color cast type is: local color cast;

[0031] The method of adopting a color cast correction strategy that matches the color cast type and the color cast direction to perform color cast correction on the image to be processed to obtain a target image includes:

[0032] performing white balance processing on the image to be processed, and during the processing, reducing the proportion of the white balance gain of the colors included in the color cast direction in the sum of the white balance gains of all colors to obtain a corrected image;

[0033] Calculating the saturation of the corrected image and the image to be processed respectively, and determining the credibility of the corrected image and the image to be processed respectively according to a preset correspondence between saturation and credibility;

[0034] Calculating the fusion weights of the corrected image and the image to be processed respectively based on the credibility of the corrected image and the image to be processed;

[0035] The corrected image and the image to be processed are fused according to their fusion weights to obtain a target image.

[0036] Optionally, in a specific implementation, the method further includes:

[0037] The target image is determined as a new image to be processed, and the step of determining the color cast intensity of the image to be processed according to the distribution of specified pixel values ​​of each pixel point in the image to be processed is returned to, until the color cast intensity does not meet the preset color cast requirement.

[0038] Optionally, in a specific implementation, obtaining the image to be processed includes:

[0039] Get the initial image;

[0040] If each pixel point in the initial image has the specified pixel value, the initial image is determined as the image to be processed;

[0041] Otherwise, the image type is converted to the initial image to obtain an image to be processed in which each pixel has the specified pixel value.

[0042] In a second aspect, an embodiment of the present invention provides an image processing device, the device comprising:

[0043] An acquisition module, used for acquiring an image to be processed;

[0044] an intensity determination module, configured to determine the color cast intensity of the image to be processed based on the distribution of designated pixel values ​​of each pixel point in the image to be processed;

[0045] a type determination module, configured to determine the color cast type of the image to be processed if the color cast intensity meets a preset color cast requirement, and determine the color cast direction of the image to be processed based on the distribution; wherein the color cast type includes global color cast or local color cast;

[0046] The correction module is used to adopt a color cast correction strategy that matches the color cast type and the color cast direction to perform color cast correction on the image to be processed to obtain a target image.

[0047] Optionally, in a specific implementation, the designated pixel values ​​include first-category pixel values ​​and second-category pixel values, and the intensity determination module includes:

[0048] an intensity determination submodule, configured to calculate a first mean of the first type of pixel values ​​of each pixel point in the image to be processed, and a second mean of the second type of pixel values ​​of each pixel point in the image to be processed, and calculate the color cast intensity of the image to be processed using the first mean and the second mean;

[0049] The type determination module includes:

[0050] The direction determination submodule is used to determine the color cast direction of the image to be processed according to the relationship between the first mean value and the second mean value and the specified numerical range respectively.

[0051] Optionally, in a specific implementation, the type determination module includes:

[0052] If the color cast intensity is greater than a first intensity threshold, determining that the color cast type of the image to be processed is global color cast;

[0053] If the color cast intensity is less than the first intensity threshold and greater than a second intensity threshold, it is determined that the color cast type of the image to be processed is local color cast; wherein the second intensity threshold is less than the first intensity threshold.

[0054] Optionally, in a specific implementation, the image to be processed is a CIELAB image; the first category pixel value is an a color channel value; the second category pixel value is a color channel value;

[0055] The intensity determination submodule is specifically configured to:

[0056] Calculating the average chromaticity of the image to be processed by using the sum of the squares of the first mean and the second mean;

[0057] Calculating a third mean of each first difference and a fourth mean of each second difference, and calculating the chromaticity center distance of the image to be processed using the sum of the squares of the third mean and the fourth mean; wherein each first difference is a difference between a first-category designated pixel value of a pixel point in the image to be processed and the first mean, and each second difference is a difference between a second-category designated pixel value of a pixel point in the image to be processed and the second mean;

[0058] The ratio of the average chromaticity to the chromaticity center distance is calculated as the color cast intensity of the image to be processed.

[0059] Optionally, in a specific implementation, the image to be processed is a YUV image; the first type of pixel value is a U component value, and the second type of pixel value is a V component value;

[0060] The intensity determination submodule is specifically configured to:

[0061] Calculating a third difference and a fourth difference between the first mean and the second mean and a preset center value, respectively; wherein the preset center value is determined based on the number of bits of the image to be processed;

[0062] A sum of squares of the third difference and the fourth difference is calculated, and a positive root of the sum of squares is calculated as the color cast intensity of the image to be processed.

[0063] Optionally, in a specific implementation, the color cast type includes: global color cast;

[0064] The correction module is specifically used to:

[0065] White balance processing is performed on the image to be processed, and during the processing, the proportion of the white balance gain of the colors included in the color cast direction in the white balance gain sum value of all colors is reduced to obtain a target image.

[0066] Optionally, in a specific implementation, the color cast type is: local color cast;

[0067] The correction module is specifically used to:

[0068] performing white balance processing on the image to be processed, and during the processing, reducing the proportion of the white balance gain of the colors included in the color cast direction in the sum of the white balance gains of all colors to obtain a corrected image;

[0069] Calculating the saturation of the corrected image and the image to be processed respectively, and determining the credibility of the corrected image and the image to be processed respectively according to a preset correspondence between saturation and credibility;

[0070] Calculating the fusion weights of the corrected image and the image to be processed respectively based on the credibility of the corrected image and the image to be processed;

[0071] The corrected image and the image to be processed are fused according to their fusion weights to obtain a target image.

[0072] Optionally, in a specific implementation, the device further includes:

[0073] A return module is used to determine a new image to be processed from the target image, and return to the step of determining the color cast intensity of the image to be processed based on the distribution of specified pixel values ​​of each pixel point in the image to be processed, until the color cast intensity does not meet the preset color cast requirement.

[0074] Optionally, in a specific implementation, the acquisition module is specifically configured to:

[0075] Get the initial image;

[0076] If each pixel point in the initial image has the specified pixel value, the initial image is determined as the image to be processed;

[0077] Otherwise, the image type is converted to the initial image to obtain an image to be processed in which each pixel has the specified pixel value.

[0078] In a third aspect, an embodiment of the present invention provides an electronic device, including:

[0079] Memory for storing computer programs;

[0080] The processor is configured to implement the steps of any of the above method embodiments when executing the program stored in the memory.

[0081] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above method embodiments are implemented.

[0082] In a fifth aspect, an embodiment of the present application further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the steps of any of the above method embodiments.

[0083] Beneficial effects of the embodiments of the present application:

[0084] As can be seen from the above, by applying the solution provided in the embodiment of the present application, the image to be processed can be first obtained, and then the color cast intensity of the image to be processed can be determined based on the distribution of the specified pixel values ​​of each pixel point in the image to be processed; if the color cast intensity of the image to be processed meets the preset color cast requirement, it is determined whether the color cast type of the image to be processed is global color cast or local color cast, and based on the distribution of the specified pixel values ​​of each pixel point in the image to be processed, the color cast direction of the image to be processed is determined; in this way, a color cast correction strategy that matches the color cast type and color cast direction can be used to perform color cast correction on the image to be processed to obtain the target image.

[0085] Based on this, by applying the solution provided in the embodiment of the present application, after obtaining the image to be processed, the electronic device can automatically determine the color cast category and color cast direction of the image to be processed, and perform color cast correction on the image to be processed according to the determined color cast category and color cast direction, without the need for manual analysis and color cast correction of the image to be processed. Therefore, compared with the manual processing method, the image processing cycle is shortened, and the image processing efficiency is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0086] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other embodiments can also be obtained based on these drawings.

[0087] Figure 1 A schematic diagram of a flow chart of an image processing method provided in an embodiment of the present application;

[0088] Figure 2(a)-Figure 2(b) Schematic diagrams of image color cast types provided in embodiments of the present application;

[0089] Figure 3 Another flowchart of the image processing method provided in an embodiment of the present application;

[0090] Figure 4 A schematic diagram of another flow chart of the image processing method provided in an embodiment of the present application;

[0091] Figure 5 A schematic diagram of a relationship curve between credibility and saturation provided in an embodiment of the present application;

[0092] Figure 6(a)-Figure 6(b) They are respectively a schematic diagram of a local color cast correction method provided in an embodiment of the present application;

[0093] Figure 7 A schematic diagram of another flow chart of the image processing method provided in an embodiment of the present application;

[0094] Figure 8(a)-Figure 8(b) Schematic diagrams of the color cast directions of YUV images provided in the embodiments of the present application;

[0095] Figure 9 A flowchart of a specific example of the image processing method provided in an embodiment of the present application;

[0096] Figure 10 A flowchart of a specific example of the color cast detection method provided in an embodiment of the present application;

[0097] Figure 11 A schematic diagram of the structure of an image processing device provided in an embodiment of the present application;

[0098] Figure 12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0099] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field based on this application are within the scope of protection of this application.

[0100] In the related art, after an image acquisition device captures an image, a manual process is usually performed on each captured image to detect color cast, and images with color cast problems are processed. This results in a low efficiency in color cast processing due to the long manual processing cycle.

[0101] In order to solve the above technical problems, an embodiment of the present application provides an image processing method.

[0102] The method can be applied to various application scenarios requiring image processing, such as processing photographs of people and road videos. Furthermore, the method can be applied to various image acquisition devices, such as video cameras and still cameras, which can be equipped with image processing modules and then execute the method to process the acquired images. It can also be applied to other electronic devices that can communicate with image acquisition devices, such as servers, mobile phones, and computers, which can acquire images and then execute the method to process the acquired images.

[0103] Based on this, the embodiments of the present application do not specifically limit the application scenarios and execution entities of the method.

[0104] For the sake of clarity, the entity that executes the technical solution provided by this application will be referred to as an electronic device below.

[0105] An image processing method provided in an embodiment of the present application may include the following steps:

[0106] Get the image to be processed;

[0107] determining the color cast intensity of the image to be processed according to the distribution of the specified pixel values ​​of each pixel point in the image to be processed;

[0108] If the color cast intensity meets the preset color cast requirement, determining the color cast type of the image to be processed, and determining the color cast direction of the image to be processed based on the distribution; wherein the color cast type includes global color cast or local color cast;

[0109] A color cast correction strategy that matches the color cast type and the color cast direction is adopted to perform color cast correction on the image to be processed to obtain a target image.

[0110] As can be seen, by applying the scheme provided in the embodiments of the present application, the color cast intensity of the to-be-processed image can be determined first according to the distribution of the specified pixel values of the pixel points in the to-be-processed image, and then if the color cast intensity of the to-be-processed image meets the preset color cast requirement, it is determined whether the color cast type of the to-be-processed image is global color cast or local color cast, and the color cast direction of the to-be-processed image is determined based on the distribution of the specified pixel values of the pixel points in the to-be-processed image. In this way, the color cast correction strategy matched with the color cast type and the color cast direction can be used to correct the color cast of the to-be-processed image to obtain a target image.

[0111] Based on this, by applying the scheme provided in the embodiments of the present application, after obtaining the to-be-processed image, the electronic device can automatically determine the color cast category and the color cast direction of the to-be-processed image, and correct the color cast of the to-be-processed image according to the determined color cast category and color cast direction, without the need for manual analysis and color cast correction of the to-be-processed image. Therefore, compared with the manual processing mode, the image processing period is shortened, and thus the image processing efficiency is improved.

[0112] Next, an image processing method provided by an embodiment of the present application will be described in detail in combination with the accompanying drawings.

[0113] Figure 1 A flowchart of an image processing method provided by an embodiment of the present application is shown in FIG. 1, which can include the following steps S101-S104. Figure 1

[0114] S101: Obtain a to-be-processed image;

[0115] Before image processing, the to-be-processed image can be obtained first. If the obtained image is a single frame image, the single frame image can be directly taken as the to-be-processed image. If the obtained image is a video stream, the video stream can be processed to obtain multiple frames of images, and each frame of image can be taken as a to-be-processed image.

[0116] Due to the influence of the surrounding environment, the initial image collected by the image collection device can have noise, so that when the initial image is subjected to color cast detection and color cast correction, the noise can affect the accuracy of color cast detection, and thus affect the effect of color cast correction. Based on this, optionally, the initial image collected by the image collection device can be subjected to denoising processing, and the image after denoising processing can be taken as the to-be-processed image.

[0117] ​Since the image processing method provided by the present application is based on the specified pixel values ​​of each pixel in the image to be processed of a specified type, the image to be processed is subjected to color cast detection and color cast correction. Therefore, after obtaining the initial image, if the initial image is not an image of the specified type, the initial image can be converted, and the converted image of the specified type is used as the image to be processed. For example, if the a (Redness) color channel value and the b (Yellowness) color channel value of the CIELAB color space are used to perform color cast detection and color cast correction, then when the initial image obtained is an RGB image, each pixel in the image does not have an a color channel value and a b color channel value, then the initial image can be converted into a CIELAB image, and the converted CIELAB image is used as the image to be processed.

[0118] S102: determining the color cast intensity of the image to be processed based on the distribution of the designated pixel values ​​of each pixel point in the image to be processed;

[0119] After the image to be processed is acquired, the color cast intensity of the image to be processed may be determined based on the distribution of designated pixel values ​​of each pixel point in the image to be processed.

[0120] Since the electronic device can determine the color cast intensity of the image to be processed based on the specified pixel values ​​of each pixel point of the image to be processed, and the above-mentioned specified pixel values ​​are the pixel values ​​of each pixel point of the image located in the specified color space, based on this, when any initial image is obtained, it can be first determined whether the initial image is an image located in the specified color space, that is, whether each pixel point in the initial image has the specified pixel value.

[0121] Optionally, in a specific implementation, the above step S101 may include the following steps 11-13:

[0122] Step 11: Get the initial image;

[0123] Step 12: If each pixel in the initial image has a specified pixel value, the initial image is determined as the image to be processed;

[0124] Step 13: Otherwise, perform image type conversion on the initial image to obtain an image to be processed in which each pixel has a specified pixel value.

[0125] In the specific implementation, when performing image processing, an initial image can be acquired first, and then it is determined whether each pixel point in the initial image has a specified pixel value. If each pixel point in the initial image has the specified pixel value, the initial image can be determined as a to-be-processed image. If each pixel point in the initial image does not have the specified pixel value, the initial image can be subjected to image type conversion, that is, the initial image is converted into an image in which each pixel point has the specified pixel value, so as to obtain the to-be-processed image.

[0126] The specified pixel value can be an a color channel value and a b color channel value, and the to-be-processed image should be a CIELAB image. Based on this, when each pixel point in the acquired initial image does not have the a color channel value and the b color channel value, the initial image can be converted into a CIELAB image.

[0127] The specified pixel value can also be a U component value and a V component value, and the to-be-processed image should be a YUV image. Based on this, when each pixel value in the acquired initial image does not have the U component value and the V component value, the initial image can be converted into a YUV image. The Y component in the YUV image is used to represent the luminance of the image, and the U component and the V component are both used to represent the chrominance of the YUV image.

[0128] S103: If the color cast intensity meets the preset color cast requirement, the color cast type of the to-be-processed image is determined, and the color cast direction of the to-be-processed image is determined based on the distribution.

[0129] The color cast type includes global color cast or local color cast.

[0130] The color cast type of the image can include global color cast and local color cast, and the color cast intensity of the image belonging to different color cast types is different.

[0131] Generally, if the color cast intensity of an image is extremely low, it can be considered that the image is not color cast. If the color cast intensity of the image is weak and there are multiple colors in the image, it can be considered that the color cast type of the image is local color cast. If the color cast intensity of the image is strong and the colors existing in the image are relatively single, it can be considered that the color cast type of the image is global color cast.

[0132] For example, the a color channel value and the b color channel value of each pixel point in a CIELAB image are analyzed, and a distribution histogram of the a color channel value and the b color channel value of each pixel point in the CIELAB image in a preset a-b chroma coordinate can be obtained. For example, Figure 2(a)-2(b)As shown in the histogram, each peak represents a color, and the height of the peak is the average chromaticity value of each pixel under that color. As shown in Figure 2(a), if the peak distribution in the ab chromaticity coordinate histogram is relatively concentrated or there is only one peak, and the peak height is high, it can be considered that the image has global color cast, and the larger the above average chromaticity value, the more serious the image color cast. As shown in Figure 2(b), if there are multiple peaks in the ab chromaticity coordinate histogram, and the distribution of each peak is relatively dispersed, it can be considered that the image has local color cast, and if the height of each peak is very low, it can be considered that the image does not have color cast.

[0133] From the above, it can be seen that if the color cast intensity of the image is strong, the color cast type of the image is global color cast; if the color cast intensity of the image is weak, the color cast type of the image is local color cast; if the color cast intensity of the image is extremely low, the image has no color cast.

[0134] Based on this, the type of color cast in an image can be determined based on the intensity of the color cast. To determine the intensity of the color cast, a preset color cast requirement can be set. Thus, if the color cast intensity of the image to be processed satisfies the preset color cast requirement, the image to be processed can be determined to have color cast. Furthermore, the type of color cast in the image to be processed can be determined based on the quantitative relationship between the color cast intensity and the various intensity thresholds in the preset color cast requirement. Furthermore, the direction of the color cast in the image to be processed can be determined based on the distribution of specified pixel values ​​for each pixel in the image to be processed.

[0135] The preset color cast requirement may include multiple intensity thresholds, and the color cast type of each image may be determined based on the quantitative relationship between the color cast intensity and the multiple intensity thresholds. For example, if the color cast intensity of an image is greater than a first intensity threshold, the image's color cast type may be determined to be global; if the color cast intensity of an image is greater than a second intensity threshold but less than the first intensity threshold, the image's color cast type may be determined to be local; and if the color cast intensity of an image is less than the second intensity threshold, the image may be determined to have no color cast.

[0136] Optionally, in a specific implementation, the above step S103 may include the following steps 21-22:

[0137] Step 21: If the color cast intensity is greater than the first intensity threshold, determining that the color cast type of the image to be processed is global color cast;

[0138] Step 22: If the color cast intensity is less than the first intensity threshold and greater than the second intensity threshold, determining that the color cast type of the image to be processed is local color cast; wherein the second intensity threshold is less than the first intensity threshold.

[0139] In this specific implementation, if the color cast intensity is greater than the first intensity threshold, the color cast type of the image to be processed is determined to be global color cast; if the color cast intensity is less than the first intensity threshold and greater than the second intensity threshold, the color cast type of the image to be processed is determined to be local color cast.

[0140] Among them, the above-mentioned first intensity threshold is greater than the above-mentioned second intensity threshold, and the above-mentioned first intensity threshold and the above-mentioned second intensity threshold can be set according to actual needs. For example, the above-mentioned first intensity threshold can be 100, and the above-mentioned second intensity threshold can be 30; the above-mentioned first intensity threshold can be 80, and the above-mentioned second intensity threshold can be 40, etc., which are all reasonable and are not specifically limited in the embodiments of the present invention.

[0141] Typically, as shown in FIG8( b ), based on the grayscale world theory assumption, assuming that the image to be processed is an 8-bit YUV image, when the image does not have color cast, the U mean and V mean of the image will tend to be equal, and both will be concentrated near the neutral gray area 128 of the grayscale image; when the image has color cast, the U mean or the V mean will deviate from 128, and the farther the U mean or the V mean is from 128, the more severe the color cast of the image will be.

[0142] That is to say, the mean value of the pixel values ​​of each pixel point in the image to be processed can be used to characterize the color cast intensity of the image to be processed. In the case that the image to be processed has color cast, the color cast direction of the image to be processed can be determined based on the mean value of the pixel values ​​of each pixel point in the image to be processed.

[0143] Based on this, optionally, in a specific implementation, the designated pixel values ​​may include first-category pixel values ​​and second-category pixel values. Then, step S102 of determining the color cast intensity of the image to be processed based on the distribution of designated pixel values ​​of each pixel point in the image to be processed may include the following step 31:

[0144] Step 31: Calculating a first mean of the first category of pixel values ​​for each pixel point in the image to be processed, and a second mean of the second category of pixel values ​​for each pixel point in the image to be processed, and calculating the color cast intensity of the image to be processed using the first mean and the second mean;

[0145] Accordingly, in this specific implementation, in the above step S103, determining the color cast direction of the image to be processed based on the distribution may include the following step 32:

[0146] Step 32: Determine the color cast direction of the image to be processed based on the relationship between the first mean and the second mean and the specified numerical range.

[0147] In the specific implementation, the specified pixel value can include a first pixel value and a second pixel value, i.e., the pixel value of each pixel point in the to-be-processed image can include the first pixel value and the second pixel value.

[0148] For example, when the to-be-processed image is a CIELAB image, each pixel point in the to-be-processed image can include an a color channel value and a b color channel value, so that the first pixel value can be the a color channel value, and the second pixel value can be the b color channel value.

[0149] When the to-be-processed image is a YUV image, each pixel point in the to-be-processed image can include a U component value and a V component value, so that the first pixel value can be the U component value, and the second pixel value can be the V component value.

[0150] In this way, after the to-be-processed image is obtained, a first mean value of the first pixel value of each pixel point in the to-be-processed image can be calculated, and a second mean value of the second pixel value of each pixel point in the to-be-processed image can be calculated, and then the color cast intensity of the to-be-processed image can be calculated using the first mean value and the second mean value, and when the to-be-processed image has color cast, the color cast direction of the to-be-processed image can be determined based on the relationship between the first mean value and the second mean value and the specified numerical range.

[0151] When the mean value distribution of the pixel value of each pixel point in the to-be-processed image is different, the color to which the to-be-processed image is cast is also different, and based on this, for each color, a specified numerical range corresponding to the color can be set in advance, and when the mean value is located in the specified numerical range, it can be considered that the color corresponding to the specified numerical range is the color cast direction of the to-be-processed image.

[0152] The specified numerical range can be specifically set according to factors such as image type and image bit number.

[0153] For example, when the to-be-processed image is an 8-bit YUV image, the value range of the first mean value and the second mean value is 0-255, and the value range can be divided into a plurality of numerical ranges for representing different color cast directions, so that the color cast direction of the to-be-processed image can be determined according to the relationship between the first mean value and the second mean value and any one of the specified numerical ranges.

[0154] S104: A color cast correction strategy matched with the color cast type and the color cast direction is used to perform color cast correction on the to-be-processed image to obtain a target image.

[0155] After determining the color cast type and color cast direction of the image to be processed, a color cast correction strategy matching the color cast type and color cast direction may be used to perform color cast correction on the image to be processed, thereby obtaining a target image.

[0156] Typically, the color cast correction of the image can be achieved by adjusting the white balance gain of the image. Based on this, optionally, when the image to be processed is not an RGB image, the image to be processed is converted into an RGB image and the color cast correction is performed on the image to be processed.

[0157] Different strategies are used to correct color casts for different types of color casts. If the image to be processed has global color cast, each pixel in the image has color casts. Therefore, when correcting the image, the entire image only needs to be processed.

[0158] Optionally, in a specific implementation, the color cast type of the image to be processed includes: global color cast;

[0159] like Figure 3 As shown, the above step S104 may include the following step S1041:

[0160] S1041: performing white balance processing on the image to be processed, and during the processing, reducing the proportion of the white balance gain of the colors included in the color cast direction in the white balance gain sum of all colors to obtain a target image.

[0161] In this specific implementation, when the color cast type of the above-mentioned image to be processed is global color cast, white balance processing can be performed on the image to be processed, and during the processing process, the proportion of the white balance gain of the colors included in the above-mentioned color cast direction in the white balance gain and value of all colors is reduced, thereby obtaining the target image.

[0162] Optionally, a specific value for reducing the white balance gain of the colors included in the above-mentioned color cast direction, or a specific value for increasing the white balance gain of other colors can be determined according to the color cast intensity. That is, when the color cast intensity is greater, the value for reducing the white balance gain of the colors included in the above-mentioned color cast direction is greater; and when the color cast intensity is smaller, the value for reducing the white balance gain of the colors included in the above-mentioned color cast direction is smaller.

[0163] When the color cast type of the above-mentioned image to be processed is local color cast, some areas in the image to be processed have color cast. Therefore, only using the white balance method to process the image to be processed may cause the non-color-cast areas to have reverse color cast due to the color cast correction. Therefore, when correcting the image with local color cast, the corrected image can be used to merge with the original image to be processed.

[0164] Optionally, in an embodiment, the color cast type is local color cast.

[0165] As shown in FIG. 10, the step S104 can include steps S1042-S1045. Figure 4

[0166] S1042: performing white balance processing on the to-be-processed image, and reducing the proportion of the white balance gain of the color included in the color cast direction in the white balance gain sum of all colors in the processing process to obtain a corrected image.

[0167] S1043: respectively calculating the saturation of the corrected image and the to-be-processed image, and respectively determining the credibility of the corrected image and the to-be-processed image according to a preset corresponding relationship between the saturation and the credibility.

[0168] S1044: respectively calculating the fusion weight of the corrected image and the to-be-processed image based on the credibility of the corrected image and the to-be-processed image.

[0169] S1045: performing image fusion on the corrected image and the to-be-processed image according to the fusion weight of the corrected image and the to-be-processed image to obtain a target image.

[0170] In the embodiment, if the color cast type of the to-be-processed image is local color cast, the to-be-processed image can be subjected to white balance processing, and the proportion of the white balance gain of the color included in the color cast direction in the white balance gain sum of all colors can be reduced in the processing process, so as to obtain a corrected image.

[0171] Then, the credibility of the corrected image and the to-be-processed image can be respectively determined based on the credibility of the corrected image and the to-be-processed image. Then, the fusion weight of the corrected image and the to-be-processed image can be respectively calculated based on the credibility of the corrected image and the to-be-processed image, and the image fusion can be performed on the corrected image and the to-be-processed image according to the fusion weight of the corrected image and the to-be-processed image to obtain a target image.

[0172] Optionally, the saturation of each pixel point in the corrected image and the to-be-processed image can be respectively calculated by using the following formula:

[0173]

[0174]

[0175] wherein, S1(x) is the saturation of the pixel point x in the corrected image, S2(x) is the saturation of the pixel point x in the to-be-processed image; max1 rgb (x) is the maximum value of the RGB component of the pixel point x in the corrected image, and max2​rgb (x) is the maximum value of the RGB components of the pixel x in the image to be processed; min1 rgb (x) is the minimum value of the RGB components of pixel x in the corrected image, min2 rgb (x) is the minimum value of the RGB components of pixel x in the image to be processed.

[0176] Optionally, when each minimum value is close to 0, the denominator in the above formula can be replaced by 1.

[0177] Usually, such as Figure 5 As shown in the saturation-credibility curve, there is an inverse relationship between the saturation of an image and its credibility, that is, the lower the saturation of an image, the higher its credibility. When the saturation of an image is the smallest, its credibility is the highest; as the saturation increases, its credibility gradually decreases to the lowest.

[0178] Furthermore, after determining the saturation of the corrected image and the image to be processed, the credibility of the corrected image and the image to be processed can be determined respectively using the preset correspondence between saturation and credibility. Then, the fusion weight of each pixel in the corrected image and the image to be processed can be calculated respectively using the following formula:

[0179]

[0180] Among them, C n (x) is the credibility of pixel x in the image to be processed, C c (x) is the credibility of pixel x in the corrected image; W n (x) is the weight of pixel x in the image to be processed, W c (x) is the weight of pixel x in the corrected image.

[0181] After determining the fusion weights of the corrected image and the image to be processed, the weights can be used to perform image fusion on the corrected image and the image to be processed. The process can be expressed as follows:

[0182]

[0183] in, is the RGB component value of the pixel x in the fused image; is the RGB component value of the pixel x in the image to be processed; is the RGB component value of pixel x in the corrected image.

[0184] Exemplarily, as shown in FIG6(a), the image to be processed is the current local color cast image. The color cast intensity and color cast direction of the image can be determined based on the color cast detection result, and reverse color temperature compensation is performed using white balance to obtain a reverse color temperature compensation map. In this way, the current local color cast image and the reverse color temperature compensation map can be fused with two color temperatures to obtain a non-color cast fused image.

[0185] As shown in FIG6(b), when the acquired object is a Bayer video stream, the ISP (Image Signal Processor) method can be used to process the video stream to obtain a current local color cast video stream for each frame. Furthermore, the color cast intensity and direction of the current local color cast video stream for each frame can be determined based on the color cast detection result, and reverse color temperature compensation can be performed using white balance to obtain reverse color temperature compensated video streams for each frame. In this way, the above-mentioned current local color cast video stream for each frame and the reverse color temperature compensated video stream for each frame can be subjected to dual color temperature fusion to obtain a non-color cast fused video stream.

[0186] Generally, for any image, there may be multiple color cast directions of different intensities in the image, or the image obtained after color cast processing may still have color cast. Based on this, after obtaining the target image, the above-mentioned image processing method can be used again to perform color cast detection and color cast processing on the obtained target image.

[0187] Optionally, in a specific implementation, such as Figure 7 As shown, the image processing method provided by this application may further include the following step S105:

[0188] S105: The target image is determined as a new image to be processed, and the process returns to the step of determining the color cast intensity of the image to be processed according to the distribution of the specified pixel values ​​of each pixel point in the image to be processed, until the color cast intensity does not meet the preset color cast requirement.

[0189] In this specific implementation, after obtaining a target image, the target image can be used as a new image to be processed. The process then returns to step S102, where the color cast intensity of the image to be processed is determined based on the distribution of the specified pixel values ​​of each pixel in the image to be processed. This process continues until the color cast intensity of the target image does not meet the preset color cast requirement. In this manner, the target image is free of color cast, and color cast processing of the image to be processed is complete.

[0190] As can be seen from the above, based on this, by applying the solution provided in the embodiment of the present application, after obtaining the image to be processed, the electronic device can automatically determine the color cast category and color cast direction of the image to be processed, and perform color cast correction on the image to be processed according to the determined color cast category and color cast direction, without the need for manual analysis and color cast correction of the image to be processed. Therefore, compared with the manual processing method, the image processing cycle is shortened, and thus the image processing efficiency is improved.

[0191] For different types of images to be processed, the methods for determining the color cast intensity and color cast direction of the image to be processed may be different.

[0192] Optionally, in a specific implementation, the image to be processed is a CIELAB image; the first type of pixel value is an a color channel value; and the second type of pixel value is a color channel value.

[0193] In the above step 31, the color cast intensity of the image to be processed is calculated using the first mean and the second mean. The image processing method may include the following steps 41-43:

[0194] Step 41: Calculate the average chromaticity of the image to be processed using the sum of the squares of the first mean and the second mean;

[0195] Step 42: Calculate the third mean of each first difference and the fourth mean of each second difference, and calculate the chromaticity center distance of the image to be processed using the square sum of the third mean and the fourth mean;

[0196] Each first difference is a difference between a first-category designated pixel value of a pixel point in the image to be processed and a first mean value, and each second difference is a difference between a second-category designated pixel value of a pixel point in the image to be processed and a second mean value.

[0197] Step 43: Calculate the ratio of the average chromaticity to the chromaticity center distance as the color cast intensity of the image to be processed.

[0198] In this specific implementation, when the above-mentioned image to be processed is a CIELAB image, the first type of pixel value of each pixel point of the image is the a color channel value, and the second type of pixel value is the b color channel value, then the first mean can be the mean of each a color channel value, and the second mean can be the mean of each b color channel value.

[0199] When determining the color cast intensity of the above-mentioned CIELAB image, the average chromaticity of the image to be processed can be first calculated using the sum of the squares of the above-mentioned first mean and the above-mentioned second mean. After that, the first differences between the first-category designated pixel value of a pixel point in the image to be processed and the first mean, as well as the second differences between the second-category designated pixel value of a pixel point in the image to be processed and the second mean can be calculated, and the third mean of each first difference and the fourth mean of each second difference can be calculated. In this way, the chromaticity center distance of the image to be processed can be calculated using the sum of the squares of the above-mentioned third mean and the above-mentioned fourth mean, and then the ratio of the above-mentioned average chromaticity and the chromaticity center distance can be calculated, and the above-mentioned ratio can be used as the color cast intensity of the image to be processed.

[0200] Optionally, an equivalent circle about the a color channel value and the b color channel value can be constructed in the ab chromaticity coordinate system, and then the coordinates of the center of the equivalent circle are (d a , d b ), the average chromaticity can be calculated using the following formula:

[0201]

[0202]

[0203] Among them, d a is the first mean, d b is the second mean, M and N are the width and height of the image to be processed, respectively, in pixels; is the sum of the squares of the first mean and the second mean, and D is the average chromaticity.

[0204] The third mean and fourth mean can be expressed as:

[0205]

[0206] Among them, M a is the third mean, M b The fourth mean.

[0207] The chromaticity center distance of the image to be processed can be expressed as:

[0208]

[0209] The ratio of the average chromaticity to the chromaticity center distance can be expressed as:

[0210] K= / M

[0211] The ratio of the average chromaticity to the chromaticity center distance may be used as the color cast intensity, and the ratio may be called a color cast factor. Furthermore, the larger the K value is, the greater the color cast intensity of the image is.

[0212] In order to determine the color cast direction of the above-mentioned image to be processed, a first value and a second value can be set in advance. In this way, the color cast direction of the image to be processed can be determined based on the corresponding relationship between the first mean and the above-mentioned first value, and the corresponding relationship between the second mean and the above-mentioned second value.

[0213] Based on this, optionally, in a specific implementation, the above step 32, determining the color cast direction of the image to be processed based on the relationship between the first mean and the second mean and the specified numerical range, may include steps 44-45:

[0214] Step 44: If the first mean value is greater than the first value, the color cast direction of the image to be processed includes: red; otherwise, the color cast direction of the image to be processed includes: green;

[0215] Step 45: If the second mean is greater than the second value, the color cast direction of the image to be processed includes: yellow; otherwise, the color cast direction of the image to be processed includes: blue.

[0216] In this specific implementation, a correspondence between the first value, the second value, and the color cast direction can be pre-established. The first value and the second value can be set as needed, for example, 0, 1, etc., which are all reasonable and are not specifically limited in this embodiment of the application.

[0217] Thus, if the first mean is greater than the first value, the color cast direction of the image to be processed may include: red; if the first mean is not greater than the first value, the color cast direction of the image to be processed may include: green.

[0218] If the second mean is greater than the second value, the color cast direction of the image to be processed may include yellow; if the second mean is not greater than the second value, the color cast direction of the image to be processed may include blue.

[0219] In this way, the color cast direction of the image to be processed can be determined based on the first mean value and the second mean value of each pixel point of the image to be processed.

[0220] Exemplarily, for any image, if the first mean value of the image is greater than the first value and the second mean value of the image is greater than the second value, then the color cast direction of the image includes red and yellow.

[0221] Optionally, in a specific implementation, the image to be processed is a YUV image; the first type of pixel value is a U component value, and the second type of pixel value is a V component value;

[0222] In the above step 31, the color cast intensity of the image to be processed is calculated using the first mean and the second mean. The image processing method may include the following steps 51-52:

[0223] Step 51: Calculate a third difference and a fourth difference between the first mean and the second mean and a preset center value respectively; wherein the preset center value is determined based on the number of bits of the image to be processed;

[0224] Step 52: Calculate the sum of the squares of the third difference and the fourth difference, and calculate the positive root of the sum of the squares as the color cast intensity of the image to be processed.

[0225] In this specific implementation, when the above-mentioned image to be processed is a YUV image, the first type of pixel value of each pixel point of the image is a U component value, and the second type of pixel value is a V component value, then the first mean can be the mean of each U component value, and the second mean can be the mean of each V component value.

[0226] When determining the color cast intensity of the YUV image, a preset center value can be first determined based on the number of image bits of the image to be processed. Then, a third difference and a fourth difference between the first and second means and the preset center value can be calculated. Then, the square sum of the third and fourth differences is calculated, and the positive root of the square sum is calculated, which is used as the color cast intensity of the image to be processed.

[0227] The preset center value is related to the image bit number of the image to be processed. If the image to be processed is 8 bits, the preset center value is 128; if the image to be processed is 16 bits, the preset center value is 32768.

[0228] Optionally, the above color cast intensity can be expressed as:

[0229]

[0230] in, is the third difference, is the fourth difference, and E is a positive root.

[0231] Moreover, the larger the integer root is, the greater the color cast intensity of the image to be processed is.

[0232] In order to determine the color cast direction of the image to be processed, a plurality of intervals may be preset. In this way, the color cast direction of the image to be processed may be determined based on the intervals in which the first mean value and the second mean value are located.

[0233] Optionally, in a specific implementation, the above step 32, determining the color cast direction of the image to be processed based on the relationship between the first mean and the second mean and the specified numerical range, may include steps 53-57:

[0234] Step 53: Using the first value range of the first category pixel values ​​as the horizontal coordinate and the second value range of the second category pixel values ​​as the vertical coordinate, intersecting the horizontal and vertical coordinates at a preset center value of the first category pixel values, and determining a preset circle with the intersection point as the center and the second intensity threshold as the radius; wherein the first value range is a range consisting of 0 and the maximum value of the first category pixel values; and the second value range is a range consisting of 0 and the maximum value of the second category pixel values;

[0235] Step 54: If the first mean is greater than the third value, the second mean is greater than the fourth value, and both the first mean and the second mean are not within the preset circle, then the color cast direction of the image to be processed includes: red;

[0236] Step 55: If the first mean is not greater than the third value, the second mean is greater than the fourth value, and both the first mean and the second mean are not within the preset circle, then the color cast direction of the image to be processed includes: blue;

[0237] Step 56: If the first mean is greater than the third value, the second mean is not greater than the fourth value, and both the first mean and the second mean are not within the preset circle, then the color cast direction of the image to be processed includes: yellow;

[0238] Step 57: If the first mean is not greater than the third value, the second mean is not greater than the fourth value, and both the first mean and the second mean are not within the preset circle, then the color cast direction of the image to be processed includes: green.

[0239] In this specific implementation, in order to determine the distribution of pixel values ​​of each pixel point of the above-mentioned image to be processed, as shown in Figure 8(a), the first value range of the first category pixel value is used as the horizontal coordinate, and the second value range of the second category pixel value is used as the vertical coordinate, and the above-mentioned horizontal and vertical coordinates are intersected at the preset center value of the first category pixel value. Thereafter, a preset circle is determined with the above-mentioned intersection point as the center of the circle and the above-mentioned second intensity threshold as the radius.

[0240] Afterwards, based on the above-mentioned second intensity threshold and the preset center value, a preset circle with the above-mentioned second intensity threshold as the radius and the preset center point as the center can be pre-determined, wherein the above-mentioned preset center point is a point with a coordinate value equal to the above-mentioned preset center value, and if the above-mentioned first mean and the above-mentioned second mean are located within the preset circle, then the image to be processed is not color-biased.

[0241] Furthermore, the color cast direction of the image to be processed can be determined based on the numerical relationship between the first mean and the third value and the numerical relationship between the second mean and the fourth value. If the first mean is greater than the third value, the second mean is greater than the fourth value, and both the first mean and the second mean are not within the preset circle, then the color cast direction of the image to be processed includes: red; if the first mean is not greater than the third value, the second mean is greater than the fourth value, and both the first mean and the second mean are not within the preset circle, then the color cast direction of the image to be processed includes: blue; if the first mean is greater than the third value, the second mean is not greater than the fourth value, and both the first mean and the second mean are not within the preset circle, then the color cast direction of the image to be processed includes: yellow; if the first mean is not greater than the third value, the second mean is not greater than the fourth value, and both the first mean and the second mean are not within the preset circle, then the color cast direction of the image to be processed includes: green.

[0242] Among them, the above-mentioned third value and the above-mentioned fourth value can be set according to actual needs. For example, the third value and the above-mentioned fourth value can both be preset center values, which is reasonable and is not specifically limited in the embodiments of the present application.

[0243] For example, as shown in FIG8( b ), when the image is an 8-bit grayscale image, the preset center value of the image is 128, then the preset center point is (128, 128), and the third value and the fourth value are both 128. The UV coordinates can be divided into five regions A, B, C, D, and E, wherein region A is a preset circle with (128, 128) as the center and 1 as the radius. If both the V mean and the U mean are located in region A, then the image has no color cast; if both the V mean and the U mean are located in region B, then the color cast direction of the image to be processed includes: red; if both the V mean and the U mean are located in region C, then the color cast direction of the image to be processed includes: blue; if both the V mean and the U mean are located in region D, then the color cast direction of the image to be processed includes: yellow; if both the V mean and the U mean are located in region E, then the color cast direction of the image to be processed includes: green.

[0244] In order to facilitate understanding of the image processing method provided by the above embodiment of the present application, Figure 9 and Figure 10 Give an example.

[0245] After obtaining the to-be-processed image, color cast detection can be first performed on the to-be-processed image. Thus, the color cast intensity of the to-be-processed image can be determined according to the distribution of the specified pixel value of each pixel point in the to-be-processed image, and the color cast classification of the to-be-processed image is determined based on the color cast intensity. If the color cast intensity is large, the to-be-processed image is globally color cast, and global color cast correction is performed on the to-be-processed image. If the color cast intensity is weak, the to-be-processed image is locally color cast, and local color cast correction is performed on the to-be-processed image. If the color cast intensity is extremely low, the to-be-processed image is not color cast, and no correction is needed.

[0246] After the color cast correction is performed on the to-be-processed image to obtain a target image, the target image can be used as a new to-be-processed image for color cast detection. This cycle is repeated until the obtained target image is not color cast.

[0247] If the to-be-processed image is an RGB image, when the color cast detection is performed on the to-be-processed image, the to-be-processed image can be first converted to the YUV color space. Then, the mean values of the U component and the V component can be calculated. Then, the U center deviation distance d u and the V center deviation distance d v can be calculated. Based on the deviation distances d u and d v , the image color cast distance D can be calculated. In this way, the color cast direction and the color cast intensity of the image can be determined based on the image color cast distance D.

[0248] Based on the same inventive concept, corresponding to the image processing method provided in the above embodiments of the present application, the embodiments of the present application also provide an image processing device. Figure 1

[0249] Figure 11 A structural schematic diagram of an image processing device provided in the embodiments of the present application is shown in FIG. 11. The device can include the following modules. Figure 11 The acquisition module 1110 is configured to acquire a to-be-processed image.

[0250] The intensity determination module 1120 is configured to determine the color cast intensity of the to-be-processed image according to the distribution of the specified pixel value of each pixel point in the to-be-processed image.

[0251] The type determination module 1130 is configured to determine the color cast type of the to-be-processed image if the color cast intensity meets the preset color cast requirement, and determine the color cast direction of the to-be-processed image based on the distribution. The color cast type includes global color cast or local color cast.

[0252]

[0253] ​​The correction module 1140 is configured to perform color cast correction on the image to be processed by adopting a color cast correction strategy that matches the color cast type and the color cast direction to obtain a target image.

[0254] As can be seen from the above, based on this, by applying the solution provided in the embodiment of the present application, after obtaining the image to be processed, the electronic device can automatically determine the color cast category and color cast direction of the image to be processed, and perform color cast correction on the image to be processed according to the determined color cast category and color cast direction, without the need for manual analysis and color cast correction of the image to be processed. Therefore, compared with the manual processing method, the image processing cycle is shortened, and thus the image processing efficiency is improved.

[0255] Optionally, in a specific implementation, the designated pixel values ​​include first-category pixel values ​​and second-category pixel values, and the intensity determination module 1120 includes:

[0256] an intensity determination submodule, configured to calculate a first mean of the first type of pixel values ​​of each pixel point in the image to be processed, and a second mean of the second type of pixel values ​​of each pixel point in the image to be processed, and calculate the color cast intensity of the image to be processed using the first mean and the second mean;

[0257] The type determination module 1130 includes:

[0258] The direction determination submodule is used to determine the color cast direction of the image to be processed according to the relationship between the first mean value and the second mean value and the specified numerical range respectively.

[0259] Optionally, in a specific implementation, the type determination module 1130 includes:

[0260] If the color cast intensity is greater than a first intensity threshold, determining that the color cast type of the image to be processed is global color cast;

[0261] If the color cast intensity is less than the first intensity threshold and greater than a second intensity threshold, it is determined that the color cast type of the image to be processed is local color cast; wherein the second intensity threshold is less than the first intensity threshold.

[0262] Optionally, in a specific implementation, the image to be processed is a CIELAB image; the first category pixel value is an a color channel value; the second category pixel value is a color channel value;

[0263] The intensity determination submodule is specifically configured to:

[0264] Calculating the average chromaticity of the image to be processed by using the sum of the squares of the first mean and the second mean;

[0265] Calculating a third mean of each first difference and a fourth mean of each second difference, and calculating the chromaticity center distance of the image to be processed using the sum of the squares of the third mean and the fourth mean; wherein each first difference is a difference between a first-category designated pixel value of a pixel point in the image to be processed and the first mean, and each second difference is a difference between a second-category designated pixel value of a pixel point in the image to be processed and the second mean;

[0266] The ratio of the average chromaticity to the chromaticity center distance is calculated as the color cast intensity of the image to be processed.

[0267] Optionally, in a specific implementation, the image to be processed is a YUV image; the first type of pixel value is a U component value, and the second type of pixel value is a V component value;

[0268] The intensity determination submodule is specifically configured to:

[0269] Calculating a third difference and a fourth difference between the first mean and the second mean and a preset center value, respectively; wherein the preset center value is determined based on the number of bits of the image to be processed;

[0270] Calculating a sum of squares of the third difference and the fourth difference, and calculating a positive root of the sum of squares as the color cast intensity of the image to be processed;

[0271] Optionally, in a specific implementation, the color cast type includes: global color cast;

[0272] The correction module 1140 is specifically configured to:

[0273] White balance processing is performed on the image to be processed, and during the processing, the proportion of the white balance gain of the colors included in the color cast direction in the white balance gain sum value of all colors is reduced to obtain a target image.

[0274] Optionally, in a specific implementation, the color cast type is: local color cast;

[0275] The correction module 1140 is specifically configured to:

[0276] performing white balance processing on the image to be processed, and during the processing, reducing the proportion of the white balance gain of the colors included in the color cast direction in the sum of the white balance gains of all colors to obtain a corrected image;

[0277] Calculating the saturation of the corrected image and the image to be processed respectively, and determining the credibility of the corrected image and the image to be processed respectively according to a preset correspondence between saturation and credibility;

[0278] Calculating the fusion weights of the corrected image and the image to be processed respectively based on the credibility of the corrected image and the image to be processed;

[0279] The corrected image and the image to be processed are fused according to their fusion weights to obtain a target image.

[0280] Optionally, in a specific implementation, the device further includes:

[0281] A return module is used to determine a new image to be processed from the target image, and return to the step of determining the color cast intensity of the image to be processed based on the distribution of specified pixel values ​​of each pixel point in the image to be processed, until the color cast intensity does not meet the preset color cast requirement.

[0282] Optionally, in a specific implementation, the obtaining module 1110 is specifically configured to:

[0283] Get the initial image;

[0284] If each pixel point in the initial image has the specified pixel value, the initial image is determined as the image to be processed;

[0285] Otherwise, the image type is converted to the initial image to obtain an image to be processed in which each pixel has the specified pixel value.

[0286] The present application also provides an electronic device, such as Figure 12 As shown, the electronic device includes:

[0287] Memory 1201, used for storing computer programs;

[0288] The processor 1202 is configured to implement any of the above-mentioned image processing methods when executing the program stored in the memory 1201 .

[0289] Furthermore, the electronic device may further include a communication bus and / or a communication interface, and the processor 1202, the communication interface, and the memory 1201 communicate with each other via the communication bus.

[0290] The communication bus mentioned in the electronic device mentioned above may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.

[0291] The communication interface is used for communication between the above electronic device and other devices.

[0292] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.

[0293] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.

[0294] In another embodiment provided by the present application, a computer-readable storage medium is further provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the steps of any of the above-mentioned image processing methods are implemented.

[0295] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any one of the image processing methods in the above embodiments.

[0296] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0297] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.

[0298] Each embodiment in this specification is described in a related manner. Similar portions between the various embodiments can be referenced to each other. Each embodiment focuses on the differences from other embodiments. In particular, since the apparatus embodiments, electronic device embodiments, computer-readable storage medium embodiments, and computer program product embodiments are generally similar to the method embodiments, their descriptions are relatively simple. For related portions, reference can be made to the descriptions of the method embodiments.

[0299] The above description is only a preferred embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application are included in the scope of protection of the present application.

Claims

1. An image processing method, characterized in that: The method comprises: Get the image to be processed; determining the color cast intensity of the image to be processed according to the distribution of the specified pixel values ​​of each pixel point in the image to be processed; If the color cast intensity meets the preset color cast requirement, determining the color cast type of the image to be processed, and determining the color cast direction of the image to be processed based on the distribution; wherein the color cast type includes global color cast or local color cast; Performing color cast correction on the image to be processed by adopting a color cast correction strategy that matches the color cast type and the color cast direction to obtain a target image; The step of adopting a color cast correction strategy that matches the color cast type and the color cast direction to perform color cast correction on the image to be processed to obtain a target image includes: When the color cast type is local color cast, performing white balance processing on the image to be processed, and during the processing, reducing the proportion of the white balance gain of the colors included in the color cast direction in the sum of the white balance gains of all colors, to obtain a corrected image; Calculating the saturation of the corrected image and the image to be processed respectively, and determining the credibility of the corrected image and the image to be processed respectively according to a preset correspondence between saturation and credibility; Calculating the fusion weights of the corrected image and the image to be processed respectively based on the credibility of the corrected image and the image to be processed; The corrected image and the image to be processed are fused according to their fusion weights to obtain a target image.

2. The method according to claim 1, characterized in that The designated pixel values ​​include first-category pixel values ​​and second-category pixel values, and determining the color cast intensity of the image to be processed based on the distribution of the designated pixel values ​​of each pixel point in the image to be processed includes: Calculating a first mean of first-category pixel values ​​of each pixel point in the image to be processed and a second mean of second-category pixel values ​​of each pixel point in the image to be processed, and calculating a color cast intensity of the image to be processed using the first mean and the second mean; Determining the color cast direction of the image to be processed based on the distribution includes: The color cast direction of the image to be processed is determined according to the relationship between the first mean value and the second mean value and the specified numerical range respectively.

3. The method according to claim 2, characterized in that If the color cast intensity satisfies a preset color cast requirement, determining the color cast type of the image to be processed includes: If the color cast intensity is greater than a first intensity threshold, determining that the color cast type of the image to be processed is global color cast; If the color cast intensity is less than the first intensity threshold and greater than a second intensity threshold, it is determined that the color cast type of the image to be processed is local color cast; wherein the second intensity threshold is less than the first intensity threshold.

4. The method according to claim 2 or 3, characterized in that The image to be processed is a CIELAB image; the first type of pixel value is a color channel value; The second type of pixel value is the b color channel value; The calculating the color cast intensity of the image to be processed by using the first mean and the second mean includes: Calculating the average chromaticity of the image to be processed by using the sum of the squares of the first mean and the second mean; Calculating a third mean of each first difference and a fourth mean of each second difference, and calculating the chromaticity center distance of the image to be processed using the sum of the squares of the third mean and the fourth mean; wherein each first difference is a difference between a first-category designated pixel value of a pixel point in the image to be processed and the first mean, and each second difference is a difference between a second-category designated pixel value of a pixel point in the image to be processed and the second mean; The ratio of the average chromaticity to the chromaticity center distance is calculated as the color cast intensity of the image to be processed.

5. The method according to claim 2 or 3, characterized in that The image to be processed is a YUV image; the first type of pixel values ​​are U component values, and the second type of pixel values ​​are V component values; The calculating the color cast intensity of the image to be processed by using the first mean and the second mean includes: Calculating a third difference and a fourth difference between the first mean and the second mean and a preset center value, respectively; wherein the preset center value is determined based on the number of bits of the image to be processed; A sum of squares of the third difference and the fourth difference is calculated, and a positive root of the sum of squares is calculated as the color cast intensity of the image to be processed.

6. The method according to claim 1, characterized in that The color cast types include: global color cast; The method further comprises: performing color cast correction on the image to be processed by adopting a color cast correction strategy that matches the color cast type and the color cast direction to obtain a target image; White balance processing is performed on the image to be processed, and during the processing, the proportion of the white balance gain of the colors included in the color cast direction in the white balance gain sum value of all colors is reduced to obtain a target image.

7. The method according to any one of claims 1 to 3, characterized in that The method further comprises: The target image is determined as a new image to be processed, and the step of determining the color cast intensity of the image to be processed according to the distribution of specified pixel values ​​of each pixel point in the image to be processed is returned to, until the color cast intensity does not meet the preset color cast requirement.

8. The method according to any one of claims 1 to 3, characterized in that The step of obtaining an image to be processed includes: Get the initial image; If each pixel point in the initial image has the specified pixel value, the initial image is determined as the image to be processed; Otherwise, the image type is converted to the initial image to obtain an image to be processed in which each pixel has the specified pixel value.

9. An image processing device, characterized in that: The device comprises: An acquisition module, used for acquiring an image to be processed; an intensity determination module, configured to determine the color cast intensity of the image to be processed based on the distribution of designated pixel values ​​of each pixel point in the image to be processed; a type determination module, configured to determine the color cast type of the image to be processed if the color cast intensity meets a preset color cast requirement, and determine the color cast direction of the image to be processed based on the distribution; wherein the color cast type includes global color cast or local color cast; a correction module, configured to perform color cast correction on the image to be processed by adopting a color cast correction strategy that matches the color cast type and the color cast direction to obtain a target image; The correction module is specifically used to: When the color cast type is local color cast, performing white balance processing on the image to be processed, and during the processing, reducing the proportion of the white balance gain of the colors included in the color cast direction in the sum of the white balance gains of all colors, to obtain a corrected image; Calculating the saturation of the corrected image and the image to be processed respectively, and determining the credibility of the corrected image and the image to be processed respectively according to a preset correspondence between saturation and credibility; Calculating the fusion weights of the corrected image and the image to be processed respectively based on the credibility of the corrected image and the image to be processed; The corrected image and the image to be processed are fused according to their fusion weights to obtain a target image.

10. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the method according to any one of claims 1 to 8 when executing a program stored in a memory.

11. 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 method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Off-color correction method based on color space

    CN104766276A

  • Color cast preventing method and terminal

    CN106572343A