CN115866413A - Image white balance adjusting method and device, electronic equipment and storage medium - Google Patents

Image white balance adjusting method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115866413A
CN115866413A CN202211527689.4A CN202211527689A CN115866413A CN 115866413 A CN115866413 A CN 115866413A CN 202211527689 A CN202211527689 A CN 202211527689A CN 115866413 A CN115866413 A CN 115866413A
Authority
CN
China
Prior art keywords
image data
original image
matting
point
initial color
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211527689.4A
Other languages
Chinese (zh)
Inventor
路谨豪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xian Wingtech Electronic Technology Co Ltd
Original Assignee
Xian Wingtech Electronic Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xian Wingtech Electronic Technology Co Ltd filed Critical Xian Wingtech Electronic Technology Co Ltd
Priority to CN202211527689.4A priority Critical patent/CN115866413A/en
Publication of CN115866413A publication Critical patent/CN115866413A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Processing Of Color Television Signals (AREA)
  • Color Television Image Signal Generators (AREA)

Abstract

The embodiment of the application discloses a white balance adjusting method and device for an image, electronic equipment and a storage medium, wherein the method comprises the following steps: identifying an initial color region from the original image; under the condition that the occupation ratio of the initial color area in the original image is higher than a proportion threshold value, carrying out point matting processing on the original image to obtain image data after point matting, wherein a target color area included in the image data after point matting is smaller than the initial color area; and carrying out white balance processing based on the image data after point scratching to obtain a target image corresponding to the original image. By implementing the embodiment of the application, the accuracy of white balance adjustment can be improved.

Description

Image white balance adjusting method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of image processing technologies, and in particular, to a method and an apparatus for adjusting white balance of an image, an electronic device, and a storage medium.
Background
Under a non-standard light source, an image acquired by a camera image sensor can generate a color cast phenomenon, and the Automatic White Balance (AWB) technology iteratively adjusts the gain of each corresponding channel by analyzing the color information of three components of the image R, G and B so as to remove the influence of different ambient light sources on the inherent color of an object in a scene and enable the output image to reflect the real color of the shot scene. Automatic white balance is a very important function in camera image processing algorithms, and can restore the true color of a scene to a great extent.
Existing automatic white balance methods include a gray world method, a perfect reflection method, and the like, but these methods may identify wrong statistical points on an image and misjudge a color temperature in the case of a color region with a large proportion in the image, resulting in a low accuracy of white balance adjustment.
Disclosure of Invention
The embodiment of the application discloses a method and a device for adjusting white balance of an image, electronic equipment and a storage medium, which can improve the accuracy of white balance adjustment.
The embodiment of the application discloses a white balance adjusting method of an image, which is characterized by comprising the following steps:
identifying an initial color region from the original image;
under the condition that the occupation ratio of the initial color area in the original image is higher than a proportional threshold, carrying out point matting processing on the original image to obtain image data after point matting, wherein a target color area included in the image data after point matting is smaller than the initial color area;
and carrying out white balance processing on the basis of the image data after the point scratching to obtain a target image corresponding to the original image.
As an alternative embodiment, the identifying the initial color region from the original image includes:
recognizing the outline of a photographic subject from an original image;
the initial color region is determined from image data within an outline of the subject.
As an alternative embodiment, the determining the initial color region from the image data within the outline of the photographic subject includes:
determining the initial color area from the image data within the outline of the photographic subject based on the color information corresponding to each pixel point in the image data within the outline of the photographic subject; the color information comprises spectral power distribution of the pixel points under different light sources, and/or RGB three-channel numerical values corresponding to the pixel points, and/or chromaticity ratios of the pixel points under different light sources; the RGB three-channel numerical value comprises numerical values corresponding to R, G and B channels respectively, and the chromaticity ratio comprises the proportion of the R channel numerical value to the G channel numerical value and the proportion of the B channel numerical value to the G channel numerical value in the RGB three-channel numerical value.
As an optional implementation manner, the determining the initial color region from the image data within the outline of the photographic subject based on the color information corresponding to each pixel point in the image data within the outline of the photographic subject includes:
acquiring an RGB three-channel numerical value corresponding to each pixel point in the image data within the outline of the shooting subject; the RGB three-channel numerical values comprise numerical values respectively corresponding to R, G and B channels;
calculating the difference value between the maximum value and the minimum value in the RGB three-channel numerical values corresponding to each pixel point;
determining the pixel points of which the difference values are larger than a first threshold value as color pixel points;
and determining the area of the color pixel point in the image data within the outline of the shooting subject as the initial color area.
As an optional implementation manner, the determining the initial color region from the image data within the outline of the photographic subject includes:
judging whether human face features exist in image data within the outline of the shooting subject or not;
under the condition that the human face features exist in the image data within the outline of the shooting subject, comparing the RGB three-channel numerical value corresponding to each pixel point in the image data within the outline of the shooting subject with the RGB three-channel numerical value of the human skin color to determine a non-human skin color area from the image data within the outline of the shooting subject; the RGB three-channel numerical values comprise numerical values respectively corresponding to R, G and B channels;
and determining the initial color area from the non-human body skin color area.
As an optional implementation manner, in a case that the occupation ratio of the initial color region in the original image is higher than a ratio threshold, performing a point matting process on the original image to obtain image data after point matting, including:
and under the condition that the occupation ratio of the initial color area in the original image is higher than a proportion threshold value, carrying out point matting processing on the original image until the occupation ratio of the initial color area in the original image is lower than the proportion threshold value, and obtaining image data after point matting.
As an optional implementation manner, in a case that the occupation ratio of the initial color region in the original image is higher than a ratio threshold, performing a point matting process on the original image to obtain image data after point matting, including:
under the condition that the occupation ratio of the initial color area in the original image is higher than a proportional threshold, performing point matting processing on the original image to completely scratch the initial color area in the original image to obtain image data after point matting.
The embodiment of the application discloses white balance adjusting device of image, the device includes:
the identification module is used for identifying an initial color area from an original image;
a matting module, configured to perform matting processing on the original image to obtain a matting image data when an occupation ratio of the initial color region in the original image is higher than a ratio threshold, where a target color region included in the matting image data is smaller than the initial color region;
and the processing module is used for carrying out white balance processing on the basis of the image data after the point matting to obtain a target image corresponding to the original image.
The embodiment of the application discloses an electronic device, which comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor is enabled to realize the white balance adjustment method of any image disclosed by the embodiment of the application.
The embodiment of the application discloses a computer-readable storage medium which stores a computer program, wherein the computer program enables a computer to execute any one of the white balance adjusting methods of an image disclosed in the embodiment of the application.
Compared with the related art, the embodiment of the application has the following beneficial effects:
identifying an original image to determine an initial color region from the original image; under the condition that the occupation ratio of the initial color area in the original image is higher than a ratio threshold, performing point matting processing on the original image to obtain image data after point matting, wherein the image data after point matting comprises a target color area smaller than the initial color area; and carrying out white balance processing according to the image data after point scratching to obtain a target image corresponding to the original image. The embodiment of the application can carry out point matting processing on the original image when the initial color area occupying a relatively large proportion appears in the original image, thereby avoiding the condition that the initial color area occupying a relatively large proportion causes abnormal white balance adjustment and improving the accuracy of the white balance adjustment.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a schematic flowchart of a method for adjusting white balance of an image according to an embodiment of the present application;
fig. 2 is a schematic flowchart of another method for adjusting white balance of an image according to an embodiment of the present application;
fig. 3 is a schematic flowchart of another method for adjusting white balance of an image according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a white balance adjustment apparatus for an image according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device disclosed in an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It is to be noted that the terms "comprises" and "comprising" and any variations thereof in the examples and figures of the present application are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements but may alternatively include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The embodiment of the application discloses a method and a device for adjusting white balance of an image, electronic equipment and a storage medium, which can improve the accuracy of white balance adjustment. The following are detailed descriptions.
Referring to fig. 1, fig. 1 is a schematic flow chart illustrating a method for adjusting white balance of an image according to an embodiment of the present disclosure. The method for adjusting white balance of an image described in fig. 1 may be applied to an electronic device such as a camera, a smart phone, a tablet computer, and a notebook computer with a camera module, and the embodiment of the present application is not limited thereto.
The camera module can comprise electronic devices such as a lens, a motor, a sensor, a soft board, an image processing chip and the like. The working principle of the camera module is as follows: the scene is projected on the surface of an image sensor through an optical image generated by a lens, then converted into an electric signal, converted into a digital image signal after analog-to-digital conversion, sent to an image processing chip for processing, transmitted to electronic equipment through a data bus for processing, and finally the image can be output through a display screen of the electronic equipment.
The image processing chip can be used for processing images such as white balance adjustment, lens correction, color space conversion, color and contrast enhancement and the like.
As shown in fig. 1, the white balance adjustment method of an image may include the steps of:
101. an initial color region is identified from the original image.
As an alternative embodiment, the electronic device may identify the initial color region from the original image, and may include:
the electronic equipment acquires RGB three-channel numerical values corresponding to each pixel point in an original image; judging whether the difference value between the maximum channel value and the minimum channel value in the RGB three-channel values corresponding to each pixel point is smaller than a difference value threshold value or not; if the pixel point is smaller than the preset threshold value, judging the pixel point to be a black, white and gray pixel point; if so, judging the pixel point as a color pixel point; and determining the area where the colored pixel points are located as an initial colored area.
The RGB three-channel numerical values comprise numerical values respectively corresponding to R, G and B channels and are used for indicating red, green and blue components in a certain color, and any color can be obtained according to different proportion mixing of red, green and blue primary colors.
For example, if the RGB three-channel values of a pixel point are (150, 152, 183), and the difference threshold is 10, the largest channel value is 183, and the smallest channel value is 150, the difference between the largest channel value and the smallest channel value is 33, which is greater than the difference threshold, in the RGB three-channel values corresponding to the pixel point, so that the pixel point can be determined as a color pixel point.
Because the black, white and gray pixels have little influence on the white balance adjustment of the original image, the color pixels need to be identified from the original image, and the initial color area where the color pixels are located needs to be processed.
As another alternative, the electronic device may identify the initial color region from the original image, and may include:
the electronic equipment divides an original image into a plurality of pure-color areas; specifically, regions with continuous and same RGB three-channel numerical values corresponding to pixel points in the original image can be determined as color regions of pure colors; calculating RGB three-channel numerical values corresponding to each pure color area; judging whether the difference value between the maximum channel numerical value and the minimum channel numerical value in the RGB three-channel numerical values corresponding to each pure color area is smaller than a difference value threshold value or not; and determining the color area of the pure color with the difference value larger than the difference value threshold value as the initial color area.
By implementing the steps, the RGB three-channel numerical value of each pixel point in the original image is directly judged, and the reasonable difference threshold value is determined, so that the initial color area can be efficiently and accurately identified from the original image.
As another alternative, the electronic device may identify the initial color region from the original image, and may include:
identifying the outline of a shooting subject from an original image; an initial color region is determined from image data within the outline of the subject. Wherein, the shooting subject can be human, animal, object, etc., and no establishment is made; the initial color area is determined from the image data within the outline of the shooting subject, namely the influence of the background part outside the outline of the shooting subject in the original image on the white balance adjustment is not considered, and only the influence of the image data within the shooting subject on the white balance of the whole picture is considered.
102. Under the condition that the occupation ratio of the initial color area in the original image is higher than a proportion threshold value, carrying out point matting processing on the original image to obtain image data after point matting.
And the target color area included in the image data after point matting is smaller than the initial color area.
It should be noted that the point matting process is to perform matting on pixel points; therefore, the point matting processing is carried out on the original image, namely pixel points in the middle region of the original image are scratched; for example, under the condition that the proportion of the initial color region in the original image is higher than the proportion threshold, performing point matting processing on the original image, which may be to perform point matting on pixel points of the initial color region in the original image to obtain point-scratched image data; the image data after point matting comprises an initial color area after point matting, namely a target color area; the target color area is smaller than the initial color area.
The pixel points of the initial color region in the original image are scratched, the pixel points of the initial color region can be scratched randomly, the pixel points can also be scratched along the edge of the initial color region, and the definition is not particularly limited.
In the embodiment of the application, before carrying out matting processing on an original image, the electronic device can count the proportion of an initial color region in the original image; the ratio of the initial color region in the original image may be the ratio of the area of the initial color region to the area of the original image, or may be the ratio of the number of pixels included in the initial color region to the number of pixels included in the original image, or may be the ratio of a statistical point on the initial color region to the original image, where the statistical point may be a different spectral power distribution point of each light source on the original image. And is not particularly limited.
When the proportion of the initial color area in the original image is high, the influence of the initial color area on white balance adjustment is large, so that matting processing is carried out on the original image; when the ratio of the initial color area in the original image is low, it is described that the initial color area has a small influence on the white balance adjustment, and therefore, the point matting processing is not performed on the original image. Illustratively, the ratio threshold may be 10% to 30%, and is not limited.
And the target color area included in the image data after point matting is smaller than the initial color area.
The electronic device performs point matting processing on the original image, and can scrub part or all of the initial color area from the original image. The target color region is a region remaining after the matting is performed on the basis of the initial color region, and therefore, the area of the target color region is smaller than that of the initial color region. Wherein the area of the target color region may be equal to 0, i.e. all of the initial color region is scratched out of the original image.
The above steps are performed to determine whether the initial color area has a large influence on the white balance adjustment of the original image by determining whether the ratio of the initial color area in the original image is higher than a ratio threshold, so that the influence of the large area of the initial color area on the accuracy of the white balance adjustment of the original image can be eliminated.
103. And carrying out white balance processing based on the image data after point scratching to obtain a target image corresponding to the original image.
The electronic equipment can carry out white balance processing on the image data after point scratching, and the specific white balance processing mode can be as follows: a gray world algorithm, a perfect reflection algorithm, a dynamic threshold-based algorithm, and the like, without limitation. Illustratively, the effective points of the image data after point matting can be counted through a simple gray scale world, then the effective points are processed through a high-level gray scale world, such as light source weight, distance weight and the like, and finally the processed image data and a scene analyzer are aggregated to obtain a target image corresponding to an original image; the target image is an image obtained by adjusting the white balance of the original image, and can reflect the real color of the shot scene.
The method comprises the steps of identifying an original image to determine an initial color area from the original image; under the condition that the proportion of the initial color area in the original image is higher than a proportion threshold value, performing point matting processing on the original image to obtain the image data after point matting, wherein the image data after point matting comprises a target color area smaller than the initial color area; and carrying out white balance processing according to the image data after point scratching to obtain a target image corresponding to the original image. The embodiment of the application can carry out point matting processing on the original image when the initial color area occupying a relatively large proportion appears in the original image, thereby avoiding the condition that the initial color area occupying a relatively large proportion causes abnormal white balance adjustment and improving the accuracy of the white balance adjustment.
Referring to fig. 2, fig. 2 is a schematic flowchart illustrating another method for adjusting white balance of an image according to an embodiment of the present disclosure. As shown in fig. 2, the method comprises the steps of:
201. the outline of the subject is recognized from the original image.
The method for recognizing the outline of the photographic subject from the original image may include: the differential method, the differential edge detection method, the laplacian edge detector, the Canny edge detection method, and the like are not particularly limited. The subject may be a human, an animal, an object, and the like, and is not particularly limited.
202. An initial color region is determined from the image data within the outline of the subject based on color information corresponding to each pixel point in the image data within the outline of the subject.
The initial color area may be a pure color area, and the pure color area with a larger proportion may affect the white balance adjustment of the entire original image, for example, when the subject is a person, and the proportion of the clothes on the person in the original image is larger, the white balance adjustment may be affected by different clothes colors, for example, red clothes and blue clothes may cause the entire color to be bluish or reddish, respectively.
The color information comprises spectral power distribution of the pixel points under different light sources, and/or RGB three-channel numerical values corresponding to the pixel points, and/or chromaticity ratios of the pixel points under different light sources.
The spectral power distribution of the pixel points under different light sources, namely, each pixel point corresponds to one or more light sources, the spectral power distribution corresponds to each light source, the spectral power distribution comprises the relation between the spectral energy and the wavelength of each light source, and the light source type corresponding to the pixel point can be obtained according to the spectral power distribution. For example, incandescent lamps have relatively high radiant energies in the red phase of the long wave; the fluorescent lamp has higher relative radiation energy in blue and green wave bands and lower relative radiation energy in red wave bands; sunlight is relatively balanced, and energy fluctuation is small in the visible light range. The light sources have different colors, and the colors of the light sources are changed when the light sources irradiate the same object. By obtaining the spectral power distribution, it is advantageous to reduce the color of the light source itself, which is caused by the original color of the object, in the white balance adjustment.
The RGB three-channel numerical values comprise numerical values respectively corresponding to R, G and B channels and are used for indicating red, green and blue components in a certain color, and any color can be obtained according to different proportion mixing of red, green and blue primary colors. For example, an RGB three-channel value (255, 127, 0) may represent orange, and an RGB three-channel value (127, 0, 255) may represent purple.
The chromaticity ratio includes a ratio of an R channel value to a G channel value in RGB three-channel values, and a ratio of a B channel value to a G channel value, and can be used to reflect properties such as color temperature of an original image. Meanwhile, the ratio of the R channel value to the G channel value and the ratio of the B channel value to the G channel value of the gray in the original image under different light sources can be used as a reference point for white balance adjustment and used for determining a gray area in the original image, and white balance adjustment based on the gray area is facilitated.
As an alternative embodiment, determining an initial color region from the image data within the outline of the photographic subject based on the color information corresponding to each pixel point in the image data within the outline of the photographic subject may include:
acquiring an RGB three-channel numerical value corresponding to each pixel point in image data within the outline of a shooting subject; the RGB three-channel numerical values comprise numerical values respectively corresponding to R, G and B channels; calculating the difference value between the maximum value and the minimum value in the RGB three-channel numerical values corresponding to each pixel point; determining the pixel points with the difference value larger than the first threshold value as color pixel points; and determining the area of the color pixel point in the image data within the outline of the shooting subject as an initial color area.
203. Under the condition that the occupation ratio of the initial color area in the original image is higher than a proportion threshold value, carrying out point matting processing on the original image to obtain image data after point matting.
And the target color area included in the image data after the point matting is smaller than the initial color area.
As an optional implementation manner, in a case that the proportion of the initial color region in the original image is higher than the ratio threshold, performing point matting processing on the original image to obtain image data after point matting, may include:
under the condition that the proportion of the initial color area in the original image is higher than a proportion threshold value, carrying out point matting processing on the original image until the proportion of the initial color area in the original image is lower than the proportion threshold value, and obtaining image data after point matting.
The initial color area in the original image can be randomly scratched until the proportion of the initial color area in the original image is lower than a proportion threshold, so that the white balance adjustment of the original image cannot be greatly influenced under the condition of reserving a part of the initial color area, and the accuracy of the white balance adjustment is improved.
As another optional implementation, in a case that the proportion of the initial color region in the original image is higher than the ratio threshold, performing point matting processing on the original image to obtain image data after point matting, may include:
under the condition that the occupation ratio of the initial color area in the original image is higher than a proportion threshold value, carrying out point matting processing on the original image so as to completely scratch the initial color area in the original image and obtain the image data after point matting.
The initial color areas in the original image are all scratched, so that the influence of the initial color areas on the white balance adjustment of the original image can be directly eliminated, and the accuracy of the white balance adjustment is improved.
204. And carrying out white balance processing on the basis of the image data after the point scratching to obtain a target image corresponding to the original image.
For the specific implementation of steps 203 to 204, reference may be made to steps 102 to 103, which are not described in detail.
By implementing the embodiment of the application, the initial color area is determined from the image data within the outline of the shooting subject, and the influence of the large-area color on the shooting subject on the white balance adjustment of the whole original image can be aimed at; for example, if the subject of the shooting is a person, and the proportion of clothes on the person in the original image is large, the color of the clothes has a large influence on the white balance adjustment of the whole original image; or the shooting main body is a table paved with table cloth with bright colors, the color of the table cloth has a larger influence on the white balance adjustment of the whole original image, so that the influence of a color area occupying a larger area on the shooting main body on the white balance adjustment of the original image can be eliminated, and the accuracy of the white balance adjustment is improved.
Referring to fig. 3, fig. 3 is a flowchart illustrating another method for adjusting white balance of an image according to an embodiment of the present disclosure.
301. The outline of the subject is recognized from the original image.
The step 201 may be referred to in the detailed implementation of the step 301.
302. And judging whether the image data within the outline of the shooting subject has a human face or not.
The method for determining whether a face exists in image data within the outline of the subject may be a face recognition method based on geometric features, a face recognition method based on feature face (PCA), a face recognition method based on a neural network, a face recognition method based on elastogram matching, a face recognition method based on a Support Vector Machine (SVM), or the like, and is not limited in particular.
303. Under the condition that the human face features exist in the image data within the outline of the shooting main body, comparing the RGB three-channel numerical value corresponding to each pixel point in the image data within the outline of the shooting main body with the RGB three-channel numerical value of the human skin color to determine a non-human body skin color area from the image data within the outline of the shooting main body.
The RGB three-channel numerical values comprise numerical values respectively corresponding to R, G and B channels.
As an alternative embodiment, the RGB three-channel values of the human skin color may be preset data stored in the electronic device in advance, and may include: (248, 197, 183), (235, 210, 194), (206, 123, 100), (254, 234, 230), (201, 156, 150), (223, 172, 162), (233, 215, 212), and the like, comparing the RGB three-channel value corresponding to each pixel point in the image data within the outline of the photographic subject with the RGB three-channel value of the human skin color, and if the difference values corresponding to the three channel values of R, G, B corresponding to the pixel point and the three channel values of R, G, B of any human skin color are greater than the skin color threshold value, determining the region corresponding to the pixel point as a non-human skin color region. The skin color threshold may be 10 to 20, and is not particularly limited.
As another alternative, the method for determining the non-human skin color region from the image data within the outline of the subject may further include: converting RGB three-channel numerical values corresponding to each pixel point in image data within the outline of the shooting subject into a Cb-Cr plane of a YCbCr color space, and if the Cb value corresponding to the pixel point does not fall into the range of 77-127, or the Cr value does not fall into the numerical value of 133-173, determining that a non-human body skin color region does not exist in the region where the pixel point is located.
304. An initial color region is determined from the non-human skin color region.
When the photographic subject is a person, the non-human skin color region in the image data within the outline of the photographic subject is mainly the clothes worn by the person, that is, it can be directly determined whether the clothes worn by the person have the initial color region.
As an alternative embodiment, a method for determining an initial color region from a non-human skin color region includes: acquiring an RGB three-channel numerical value corresponding to each pixel point in a non-human body skin color area; the RGB three-channel numerical values comprise numerical values respectively corresponding to R, G and B channels; calculating the difference value between the maximum value and the minimum value in the RGB three-channel numerical values corresponding to each pixel point; determining the pixel points with the difference value larger than the first threshold value as color pixel points; and determining the area where the color pixel points are located as an initial color area.
305. Under the condition that the occupation ratio of the initial color area in the original image is higher than a proportion threshold value, carrying out point matting processing on the original image to obtain image data after point matting.
And the target color area included in the image data after point matting is smaller than the initial color area.
306. And carrying out white balance processing based on the image data after point scratching to obtain a target image corresponding to the original image.
For the specific implementation of step 305 and step 306, reference may be made to step 102 to step 103, which are not described in detail.
In the embodiment of the application, the main subject of shooting in the original image is a person, and when a user is taking a self-portrait or the proportion of the half-length photograph occupying the original image is high, the pure-color clothes (such as clothes with colors of red, blue and the like) can cause the automatic white balance to recognize wrong counting points, cause abnormal judgment of color temperature and color cast of the whole white balance. By identifying the initial color area in the shooting subject and performing point matting processing, the influence caused by the mixed colors of color clothes on a person can be eliminated. The scheme identifies the color of a non-human body color area (such as clothes) in the portrait, eliminates the abnormal automatic white balance caused by clothes with different bright colors, meets the stability of a user to put on and put off pictures differently, eliminates the influence caused by different clothes colors, solves the problem that debugging personnel of a camera cannot cover the debugging of all clothes colors, and greatly reduces the abnormal probability of white balance adjustment colors.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an image white balance adjustment apparatus according to an embodiment of the present application. The device is applicable to electronic devices such as cameras, smart phones, tablet computers, and notebook computers equipped with camera modules, and is not particularly limited. As shown in fig. 4, the white balance adjustment apparatus 400 for an image may include: an identification module 410, a point scratching module 420 and a processing module 430;
an identifying module 410 for identifying an initial color region from an original image;
a point matting module 420, configured to perform point matting processing on the original image to obtain point-scratched image data when an occupation ratio of the initial color region in the original image is higher than a ratio threshold, where a target color region included in the point-scratched image data is smaller than the initial color region;
and the processing module 430 is configured to perform white balance processing based on the scratched image data to obtain a target image corresponding to the original image.
In one embodiment, the identification module 410 may include: an identification unit and a determination unit;
a recognition unit configured to recognize an outline of a photographic subject from an original image;
a determination unit configured to determine an initial color region from image data within an outline of the subject.
In one embodiment, the determining unit is further configured to determine an initial color region from the image data within the outline of the subject based on color information corresponding to each pixel point in the image data within the outline of the subject; the color information comprises spectral power distribution of the pixel points under different light sources, and/or RGB three-channel numerical values corresponding to the pixel points, and/or chromaticity ratios of the pixel points under different light sources; the RGB three-channel numerical value comprises numerical values respectively corresponding to R, G and B channels, and the chromaticity ratio comprises the proportion of the R channel numerical value to the G channel numerical value and the proportion of the B channel numerical value to the G channel numerical value in the RGB three-channel numerical value.
In one embodiment, the determining unit is further configured to obtain an RGB three-channel numerical value corresponding to each pixel point in the image data within the outline of the photographic subject; the RGB three-channel numerical values comprise numerical values respectively corresponding to R, G and B channels; calculating the difference value between the maximum value and the minimum value in the RGB three-channel numerical values corresponding to each pixel point; determining the pixel points with the difference value larger than the first threshold value as color pixel points; and determining the area of the color pixel point in the image data within the outline of the shooting subject as an initial color area.
In one embodiment, the determining unit is further configured to determine whether a human face feature exists in image data within the outline of the subject; under the condition that the human face features exist in the image data within the outline of the shooting subject, comparing the RGB three-channel numerical value corresponding to each pixel point in the image data within the outline of the shooting subject with the RGB three-channel numerical value of the human skin color to determine a non-human skin color area from the image data within the outline of the shooting subject; the RGB three-channel numerical values comprise numerical values respectively corresponding to R, G and B channels; an initial color region is determined from the non-human skin color region.
The matting module 420 is further configured to perform matting processing on the original image when the proportion of the initial color region in the original image is higher than the ratio threshold, until the proportion of the initial color region in the original image is lower than the ratio threshold, to obtain the image data after matting.
The point matting module 420 is further configured to perform point matting processing on the original image to completely scrub the original color area in the original image to obtain the image data after point matting when the proportion of the original color area in the original image is higher than the ratio threshold.
The method comprises the steps of identifying an original image to determine an initial color area from the original image; under the condition that the occupation ratio of the initial color area in the original image is higher than a ratio threshold, performing point matting processing on the original image to obtain image data after point matting, wherein the image data after point matting comprises a target color area smaller than the initial color area; and carrying out white balance processing according to the image data after point matting to obtain a target image corresponding to the original image. According to the method and the device, when the initial color area occupying a larger ratio appears in the original image, matting processing is carried out on the original image, so that the condition that the initial color area occupying a larger ratio causes abnormal white balance adjustment is avoided, and the accuracy of the white balance adjustment is improved.
Referring to fig. 5, fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
As shown in fig. 5, the electronic device 500 may include:
a memory 510 storing executable program code;
a processor 520 coupled to the memory 510;
the processor 520 calls the executable program code stored in the memory 510 to execute any one of the white balance adjustment methods for images disclosed in the embodiments of the present application.
The embodiment of the application discloses a computer-readable storage medium, which stores a computer program, wherein when the computer program is executed by a processor, the processor is enabled to realize the white balance adjustment method of any image disclosed in the embodiment of the application.
It should be appreciated that reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure or characteristic described in connection with the embodiment is included in at least one embodiment of the present application. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. Those skilled in the art should also appreciate that the embodiments described in this specification are exemplary embodiments in nature, and that acts and modules are not necessarily required to practice the invention.
In various embodiments of the present application, it should be understood that the size of the serial number of each process described above does not mean that the execution sequence is necessarily sequential, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated units, if implemented as software functional units and sold or used as separate products, may be stored in a computer accessible memory. Based on such understanding, the technical solution of the present application, which is a part of or contributes to the prior art in essence, or all or part of the technical solution, may be embodied in the form of a software product, stored in a memory, including several requests for causing a computer device (which may be a personal computer, a server, a network device, or the like, and may specifically be a processor in the computer device) to execute part or all of the steps of the above-described method of the embodiments of the present application.
It will be understood by those skilled in the art that all or part of the steps of the methods of the embodiments described above may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable storage medium, including Read-Only Memory (ROM), random Access Memory (RAM), programmable Read-Only Memory (PROM), erasable Programmable Read-Only Memory (EPROM), one-time Programmable Read-Only Memory (OTPROM), electrically Erasable Programmable Read-Only Memory (EEPROM), a Compact Disc-Read-Only Memory (CD-ROM) or other Memory capable of storing data, a magnetic tape, or any other computer-readable medium capable of storing data.
The foregoing describes in detail a method, an apparatus, an electronic device, and a storage medium for adjusting white balance of an image, which are disclosed in the embodiments of the present application, and specific examples are applied herein to illustrate the principles and implementations of the present application, and the descriptions of the foregoing embodiments are only used to help understand the method and the core ideas of the present application. Meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A method of adjusting white balance of an image, the method comprising:
identifying an initial color region from the original image;
under the condition that the occupation ratio of the initial color area in the original image is higher than a proportional threshold, carrying out point matting processing on the original image to obtain image data after point matting, wherein a target color area included in the image data after point matting is smaller than the initial color area;
and carrying out white balance processing on the basis of the image data after the point scratching to obtain a target image corresponding to the original image.
2. The method of claim 1, wherein the identifying the initial color region from the original image comprises:
recognizing the outline of a photographic subject from an original image;
the initial color region is determined from image data within an outline of the subject.
3. The method of claim 2, wherein said determining the initial color region from image data within the outline of the photographic subject comprises:
determining the initial color area from the image data within the outline of the photographic subject based on the color information corresponding to each pixel point in the image data within the outline of the photographic subject; the color information comprises spectral power distribution of the pixel points under different light sources, and/or RGB three-channel numerical values corresponding to the pixel points, and/or chromaticity ratios of the pixel points under different light sources; the RGB three-channel numerical values comprise numerical values respectively corresponding to R, G and B channels, and the chromaticity ratio comprises the proportion of the R channel numerical value to the G channel numerical value and the proportion of the B channel numerical value to the G channel numerical value in the RGB three-channel numerical values.
4. The method of claim 3, wherein the determining the initial color region from the image data within the outline of the photographic subject based on the color information corresponding to each pixel point in the image data within the outline of the photographic subject comprises:
acquiring an RGB three-channel numerical value corresponding to each pixel point in the image data within the outline of the shooting subject; the RGB three-channel numerical values comprise numerical values respectively corresponding to R, G and B channels;
calculating the difference value between the maximum value and the minimum value in the RGB three-channel numerical values corresponding to each pixel point;
determining the pixel points with the difference value larger than a first threshold value as color pixel points;
and determining the area of the color pixel point in the image data within the outline of the shooting subject as the initial color area.
5. The method of claim 2, wherein said determining the initial color region from image data within the outline of the subject comprises:
judging whether human face features exist in image data within the outline of the shooting subject or not;
under the condition that the human face features exist in the image data within the outline of the shooting subject, comparing the RGB three-channel numerical value corresponding to each pixel point in the image data within the outline of the shooting subject with the RGB three-channel numerical value of the human skin color to determine a non-human skin color area from the image data within the outline of the shooting subject; the RGB three-channel numerical values comprise numerical values respectively corresponding to R, G and B channels;
and determining the initial color area from the non-human body skin color area.
6. The method according to claim 1, wherein if the ratio of the initial color area in the original image is higher than a ratio threshold, performing a matting process on the original image to obtain a post-matting image data, includes:
under the condition that the occupation ratio of the initial color area in the original image is higher than a proportion threshold value, carrying out point matting processing on the original image until the occupation ratio of the initial color area in the original image is lower than the proportion threshold value, and obtaining image data after point matting.
7. The method according to claim 1, wherein in a case that the occupation ratio of the initial color region in the original image is higher than a ratio threshold, performing a point matting process on the original image to obtain image data after point matting, includes:
under the condition that the occupation ratio of the initial color area in the original image is higher than a proportional threshold, performing point matting processing on the original image to completely scratch the initial color area in the original image to obtain image data after point matting.
8. A white balance adjustment device, characterized in that the device comprises:
the identification module is used for identifying an initial color area from an original image;
a matting module, configured to perform matting processing on the original image to obtain a matting image data when an occupation ratio of the initial color region in the original image is higher than a ratio threshold, where a target color region included in the matting image data is smaller than the initial color region;
and the processing module is used for carrying out white balance processing on the basis of the image data after the point matting to obtain a target image corresponding to the original image.
9. An electronic device, comprising a memory and a processor, wherein a computer program is stored in the memory, and wherein the computer program, when executed by the processor, causes the processor to carry out the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
CN202211527689.4A 2022-11-30 2022-11-30 Image white balance adjusting method and device, electronic equipment and storage medium Pending CN115866413A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211527689.4A CN115866413A (en) 2022-11-30 2022-11-30 Image white balance adjusting method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211527689.4A CN115866413A (en) 2022-11-30 2022-11-30 Image white balance adjusting method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115866413A true CN115866413A (en) 2023-03-28

Family

ID=85668756

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211527689.4A Pending CN115866413A (en) 2022-11-30 2022-11-30 Image white balance adjusting method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115866413A (en)

Similar Documents

Publication Publication Date Title
CN108024055B (en) Method, apparatus, mobile terminal and the storage medium of white balance processing
US10542243B2 (en) Method and system of light source estimation for image processing
CN110163810B (en) Image processing method, device and terminal
US8355574B2 (en) Determination of main object on image and improvement of image quality according to main object
US7903870B1 (en) Digital camera and method
EP3657785B1 (en) Image white balance processing method and apparatus, and terminal device
US9460521B2 (en) Digital image analysis
CN109844804B (en) Image detection method, device and terminal
JP6553624B2 (en) Measurement equipment and system
JP3018914B2 (en) Gradation correction device
CN106611415B (en) Skin region detection method and device
CN107911625A (en) Light measuring method, device, readable storage medium storing program for executing and computer equipment
CN104735362A (en) Picture taking method and device
CN113792827B (en) Target object recognition method, electronic device, and computer-readable storage medium
CN109283439B (en) Discharge state identification method based on three-primary-color chrominance information and machine learning
CN113393540B (en) Method and device for determining color edge pixel points in image and computer equipment
CN111311500A (en) Method and device for carrying out color restoration on image
CN113676715B (en) Image processing method and device
CN108810397B (en) Image color cast correction method and terminal equipment
US20070041064A1 (en) Image sampling method for automatic white balance
CN107424134B (en) Image processing method, image processing device, computer-readable storage medium and computer equipment
CN109300186B (en) Image processing method and device, storage medium and electronic equipment
CN115866413A (en) Image white balance adjusting method and device, electronic equipment and storage medium
CN114286000A (en) Image color processing method and device and electronic equipment
CN109447925B (en) Image processing method and device, storage medium and electronic equipment

Legal Events

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