CN108810397B - Image color cast correction method and terminal equipment - Google Patents
Image color cast correction method and terminal equipment Download PDFInfo
- Publication number
- CN108810397B CN108810397B CN201810369972.6A CN201810369972A CN108810397B CN 108810397 B CN108810397 B CN 108810397B CN 201810369972 A CN201810369972 A CN 201810369972A CN 108810397 B CN108810397 B CN 108810397B
- Authority
- CN
- China
- Prior art keywords
- image
- color
- information
- gain
- eye
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 55
- 238000012937 correction Methods 0.000 title claims abstract description 20
- 238000012545 processing Methods 0.000 claims description 60
- 241001469893 Oxyzygonectes dovii Species 0.000 claims description 13
- 238000004590 computer program Methods 0.000 claims description 10
- 238000004364 calculation method Methods 0.000 claims description 7
- 238000000605 extraction Methods 0.000 claims description 2
- 230000000694 effects Effects 0.000 abstract description 10
- 238000004422 calculation algorithm Methods 0.000 description 13
- 230000008569 process Effects 0.000 description 13
- 238000001514 detection method Methods 0.000 description 8
- 239000003086 colorant Substances 0.000 description 7
- 230000011218 segmentation Effects 0.000 description 6
- 238000010586 diagram Methods 0.000 description 5
- 239000000284 extract Substances 0.000 description 5
- 230000004044 response Effects 0.000 description 4
- 230000000007 visual effect Effects 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 230000009466 transformation Effects 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 230000006872 improvement Effects 0.000 description 2
- 241000227425 Pieris rapae crucivora Species 0.000 description 1
- 210000004556 brain Anatomy 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000005286 illumination Methods 0.000 description 1
- 238000004020 luminiscence type Methods 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 239000011159 matrix material Substances 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000008447 perception Effects 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 230000005236 sound signal Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N9/00—Details of colour television systems
- H04N9/64—Circuits for processing colour signals
- H04N9/643—Hue control means, e.g. flesh tone control
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N23/00—Cameras or camera modules comprising electronic image sensors; Control thereof
- H04N23/80—Camera processing pipelines; Components thereof
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N23/00—Cameras or camera modules comprising electronic image sensors; Control thereof
- H04N23/80—Camera processing pipelines; Components thereof
- H04N23/84—Camera processing pipelines; Components thereof for processing colour signals
- H04N23/88—Camera processing pipelines; Components thereof for processing colour signals for colour balance, e.g. white-balance circuits or colour temperature control
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Image Processing (AREA)
- Facsimile Image Signal Circuits (AREA)
Abstract
The embodiment of the invention discloses an image color cast correction method and terminal equipment, wherein the method comprises the following steps: acquiring an eye white area in an image; counting color information of the eye white area; matching with standard eye white color information, and calculating color gain by using the color information; adjusting each pixel in the image with the color gain. The embodiment of the invention can more reliably realize the color cast correction of the skin color in the image under the condition of not increasing the cost, so that the image display effect is better.
Description
Technical Field
The present invention relates to the field of image processing, and in particular, to an image color shift correction method and a terminal device.
Background
With the improvement of the convenience of mobile phone photographing and the improvement of mobile phone photographing hardware, more and more people take photos by using mobile phones and record each wonderful moment around the people, family or friends and the like. However, because the user is in different lighting environments, the color cast of the skin color of the human body in the shot photo is easy to generate, which causes the photo to be unattractive. The color cast of an image can be understood as that the image acquired by the image acquisition device has deviation in brightness, hue, saturation and the like from the image formed by the human visual system. The human visual system is different from image acquisition equipment, the former has color constancy and can be automatically adjusted according to the change of a light source in a field environment, the influence of the light source on correctly perceiving the original color of an object is eliminated, the latter does not have color constancy, and the acquired image is easy to have the phenomenon of color cast. Therefore, it is necessary to correct the skin color in the photo, which is beneficial to improve the quality of the photo, thereby showing the real scene and the image of the person.
In view of the above problems, the following solutions can be used: the high-precision camera replaces a common camera, but the high-precision camera has higher price, is only applied to professional fields such as banks, traffic, real-time monitoring and the like at present, and cannot be popularized in a short time; the current method of correcting color shift is a white balance method, which is based on the assumption that a specular reflection area or a white area exists in an environment, and the reflected light part of the white area in the specular reflection area can represent the chromaticity information of a light source. Therefore, the white balance algorithm is to count the brightness maximum value of the RGB three channels or the brightness information of the pixels with the brightness value larger than the maximum value in a certain proportion, acquire the brightness and chromaticity information suitable for human eyes in a uniform Lab color space, and use the chromaticity distance between the acquired chromaticity information and an ideal light source as the standard for judging whether the color cast exists in the image.
However, when there is no white or high light reflective part in the scene, the result of the white balance color shift detection algorithm is unreliable; and under the condition that uniform standard white information is not used as a contrast sample, calculation errors are easy to occur, and the color cast correction of the image cannot be well carried out.
Disclosure of Invention
The embodiment of the invention provides an image color cast correction method and terminal equipment, which can more reliably realize color cast correction of skin color in an image under the condition of not increasing cost and enable the image display effect to be better.
In a first aspect, an embodiment of the present invention provides an image color shift correction method, where the method includes:
acquiring an eye white area in an image;
counting color information of the eye white area;
matching with standard eye white color information, and calculating color gain by using the color information;
adjusting each pixel in the image with the color gain.
In a second aspect, an embodiment of the present invention provides a terminal device, where the terminal device includes:
the acquisition unit is used for acquiring an eye white area in the image;
the statistical unit is used for counting the color information of the eye white area;
the calculating unit is used for matching with standard white eye color information and calculating color gain by using the color information;
an adjustment unit for adjusting each pixel in the image with the color gain.
In a third aspect, an embodiment of the present invention provides another terminal device, which includes a processor, an input device, an output device, and a memory, where the processor, the input device, the output device, and the memory are connected to each other, where the memory is used to store a computer program that supports the terminal device to execute the foregoing method, and the computer program includes program instructions, and the processor is configured to call the program instructions to execute the foregoing method according to the first aspect.
According to the embodiment of the invention, the white area of the eye in the image is collected, the color information of the white area of the eye is counted, the white area of the eye is matched with the standard white color of the eye, the color gain is calculated by utilizing the color information, and then each pixel in the image is adjusted by utilizing the color gain, so that the color cast correction of the image skin color can be realized, the image display effect is better, the white balance color cast detection algorithm is more reliable than that of a common white balance color cast detection algorithm, and the cost of using a high-precision camera is reduced.
Drawings
In order to more clearly illustrate the technical solution of the embodiment of the present invention, the drawings used in the description of the embodiment will be briefly introduced below.
FIG. 1 is a schematic flow chart of a method for correcting color shift of an image according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of a method for correcting color shift of an image according to another embodiment of the present invention;
fig. 3a is a schematic diagram of an image including a human face according to an embodiment of the present invention;
FIG. 3b is a schematic view of a processing region provided by an embodiment of the present invention;
FIG. 3c is a schematic diagram of an eye white region provided by an embodiment of the present invention;
fig. 3d is a schematic block diagram of a terminal device according to an embodiment of the present invention;
fig. 4 is a schematic block diagram of another terminal device provided in the embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the invention. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other 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 invention.
The terms "first," "second," and the like in the description and claims of the present invention and in the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, 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 listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
It is also to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the specification of the present invention and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to a determination" or "in response to a detection". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
In particular implementations, the terminal devices described in embodiments of the invention include, but are not limited to, other portable devices such as mobile phones, laptop computers, or tablet computers having touch sensitive surfaces (e.g., touch screen displays and/or touch pads). It should also be understood that in some embodiments, the device is not a portable communication device, but is a desktop computer having a touch-sensitive surface (e.g., a touch screen display and/or touchpad).
In the discussion that follows, a terminal device that includes a display and a touch-sensitive surface is described. However, it should be understood that the terminal device may include one or more other physical user interface devices such as a physical keyboard, mouse, and/or joystick.
The terminal device supports various applications, such as one or more of the following: a drawing application, a presentation application, a word processing application, a website creation application, a disc burning application, a spreadsheet application, a gaming application, a telephone application, a video conferencing application, an email application, an instant messaging application, an exercise support application, a photo management application, a digital camera application, a web browsing application, a digital music player application, and/or a digital video player application.
Various applications that may be executed on the terminal device may use at least one common physical user interface device, such as a touch-sensitive surface. One or more functions of the touch-sensitive surface and corresponding information displayed on the terminal device may be adjusted and/or changed between applications and/or within respective applications. In this way, a common physical architecture (e.g., touch-sensitive surface) of the terminal device may support various applications with user interfaces that are intuitive and transparent to the user.
The color cast of an image can be understood as that the image acquired by the image acquisition device has deviation in brightness, hue, saturation and the like from the image formed by the human visual system. The human visual system is different from image acquisition equipment, the former has color constancy and can be automatically adjusted according to the change of a light source in a field environment, the influence of the light source on correctly perceiving the original color of an object is eliminated, the latter does not have color constancy, and the acquired image is easy to have the phenomenon of color cast. Therefore, it is necessary to correct the skin color in the photo, which is beneficial to improve the quality of the photo, thereby showing the real scene and the image of the person.
White Balance (White Balance) as referred to in this application is actually the achievement of a reduction of White objects. The human brain can detect and correct color changes under different illumination, so that a white object is still seen as white regardless of sunlight, room, shadow, or fluorescence. However, image sensors do not have such adaptability, and the image output by the sensor may have color distortion, and the image may be reddish or bluish. Therefore, the image acquired by the sensor needs to be subjected to white balance processing.
Referring to fig. 1, which is a schematic flowchart of an image color shift correction method according to an embodiment of the present invention, as shown in fig. 1, the method may include:
101. the terminal equipment collects the white eye area in the image.
In the embodiment of the invention, the color cast correction of the image by the terminal equipment can be realized based on a computer vision library. For example, OpenCV is a cross-platform computer vision library issued based on BSD license (open source), can run on Linux, Windows, Android and Mac OS operating systems, is lightweight and efficient, and is composed of a series of C functions and a small number of C + + classes, and provides interfaces in languages such as Python, Ruby and MATLAB, so that many general algorithms in the aspects of image processing and computer vision are realized.
Specifically, the terminal device may process the image, obtain an area containing an eye image in the image, that is, may identify an eye in the image, and separate an image of the eye portion. The terminal device can call an eye classifier carried in OpenCV to obtain the area containing the eye image.
The Binarization processing, namely Image Binarization, mentioned in the embodiments of the present invention is a process of setting the gray level of a pixel point on an Image to 0 or 255, that is, making the whole Image exhibit an obvious black-and-white effect. In digital image processing, a binary image plays a very important role, and binarization of the image greatly reduces the data amount in the image, so that the outline of an object in the image can be highlighted.
Further, the terminal device may perform binarization processing on the obtained region including the eye to realize segmentation of the eye white region, that is, the eye white region may be extracted.
102. And the terminal equipment counts the color information of the eye white area.
The RGB color scheme is a color standard in the industry, and various colors are obtained by changing three color channels of red (R), green (G) and blue (B) and superimposing the three color channels on each other, where RGB represents colors of the three channels of red, green and blue, and the color standard almost includes all colors that can be perceived by human vision, and is one of the most widely used color systems at present.
The image is composed of a number of small blocks, so-called pixels (pixels), which have a well-defined position and assigned color values, and the color and position of these one block determine the way the image appears. A pixel can be considered to be an indivisible unit or element in the entire image, indivisible meaning that it cannot be cut into smaller units or elements again, which exist as a single color cell. Each dot matrix image contains a certain number of pixels that determine the size of the image to be presented on the screen.
The color information of the eye white region may be understood as color information of RGB channels of the eye white region, and the terminal device may count R, G, B channel information of the eye white region in units of pixels, respectively. Specifically, the terminal device may traverse and sum pixel information in the above-described white region, thereby counting color information of the above-described white region.
103. The terminal device is matched with standard eye white color information, and color gain is calculated by using the color information.
The terminal device may store or be provided with standard eye white color information, and it may be understood that the standard eye white color information is target reference information, is an effect that the eye white region is desired to be corrected, and may specifically be a set of RGB channel information.
The color gain is a gain value for adjusting the color information, and the terminal device may calculate the color gain based on the color information and the standard eye white color information, that is, may understand a difference between the color information and the standard eye white color information, and then execute step 104.
104. The terminal device adjusts each pixel in the image with the color gain.
Specifically, after the terminal device calculates the color gain, each pixel in the image is adjusted by the color gain, so that each pixel is compensated by the color gain. And performing color cast correction on the complexion of the human face by taking the color information of the white eye area as a source for calculating gain and based on the unchanged color of the white eye area.
The color model (Lab) mentioned in this application is based on human perception of color. The values in Lab describe all the colors that a person with normal vision can see. Lab is considered a device-independent color model because it describes how the color is displayed, and not the amount of a particular color material required by the device (e.g., display, desktop printer, or digital camera) to generate the color. The color management system uses Lab as a color scale to convert colors from one color space to another.
The Lab color model is composed of three elements of brightness (L) and related colors, namely a and b. L represents luminance (luminescence), a represents a range from magenta to green, and b represents a range from yellow to blue. The value range of L is from 0 to 100, and when L is 50, the color is equivalent to 50% of black; the value range of a and b is from +127 to-128, wherein +127a is red, and gradually transits to-128 a to become green; in the same principle, +127b is yellow and-128 b is blue. All colors are composed by alternating changes of these three values. For example, a color block has a Lab value of L100, a 30, and b 0, and is pink.
In a general white balance method, the basis is that a specular reflection area or a white area exists in an environment, and the reflected light part of the white area in the specular reflection area is considered to be capable of reflecting the chromaticity information of a light source, so that a white balance algorithm is to count the brightness maximum value of RGB three channels or the brightness information of pixels with the brightness value larger than 80% (which can be selected according to requirements), obtain the brightness and chromaticity information suitable for human eyes in a uniform Lab color space, and use the chromaticity distance between the obtained chromaticity information and an ideal light source as a standard for judging whether the color cast exists in an image.
The embodiment of the invention takes the color information of the white area in the image as the source of the calculation gain to correct the color cast of the image, thereby avoiding the situation that the result of a general white balance color cast detection algorithm is unreliable when no white or high light reflection part exists in the scene or no uniform standard white information exists as a contrast sample, and better improving the complexion of the portrait in the image to normalize and beautify the portrait.
Referring to fig. 2, which is a schematic flow chart of another audio signal processing method provided in an embodiment of the present invention, fig. 2 is further optimized on the basis of fig. 1, and as shown in fig. 2, the method may include:
201. the terminal device obtains a processing region in the image. The processing area contains an eye image.
Specifically, the terminal device may invoke an eye classifier provided in the OpenCV to process the image, so as to obtain a processing area in the image, where the processing area is an area including an eye image, that is, the eye in the image may be identified, and the image of the eye portion may be separated, and the processing area may be an area including one eye, and if there are multiple eyes in the image, an area of one of the eyes may be arbitrarily selected for processing, or an area of one of the eyes with the clearest display effect may be selected for processing. For example, as shown in fig. 3a, a photo containing a portrait, the processing area in the terminal device obtaining image may be the area containing an eye image shown in fig. 3 b.
202. The terminal equipment carries out binarization processing on the processing area and extracts an eye white area in the processing area.
Specifically, the terminal device may perform binarization processing on the image through a preset processing threshold, so as to implement segmentation of the white region, thereby obtaining a corresponding white region. One image includes a target object, a background and noise, and in order to directly extract the target object from a multi-valued digital image, the most common method is to set a threshold T, and divide the data of the image into two parts by T: pixel groups larger than T and pixel groups smaller than T. This is the most specific method for studying gray scale transformation, called binarization of the image. For example, as shown in fig. 3a, a photo containing a portrait, the processing area in the image obtained by the terminal device may be the area containing an eye image shown in fig. 3b, and further, referring to fig. 3c, the processing area is subjected to binarization processing and then displayed as black and white, and the effect is that only the white eye area shown in fig. 3c is light (white) in color relative to the other eye areas, and is not distinguished in color in the figure, and is only indicated by text labels. That is, the binarization processing is performed on the processing region, so that the white region in the image can be obtained, and step 203 is performed.
203. The terminal device counts the red channel information, the green channel information and the blue channel information of the eye white area.
Specifically, after extracting the above-mentioned whiteeye regions, the terminal device may count R, G, B channel information of the above-mentioned whiteeye regions, respectively, in units of pixels. Specifically, the terminal device may traverse and sum pixel information in the above-described white region, thereby counting color information of the above-described white region.
The terminal device may specifically count the red channel information, the green channel information, and the blue channel information of the above-mentioned eye white region by using the following formulas:
(1) red channel information:wherein r isew(i,1) pixel information representing an ith dot in a red channel;
(2) green channel information:wherein r isew(i,2) pixel information representing an ith dot in a green channel;
(3) blue channel information:wherein r isew(i,3) represents pixel information of the ith dot in the blue channel.
In the case that the terminal device counts the three channel information of the above-mentioned eye white region, step 204 may be executed.
204. The terminal device matches standard white eye color information, calculates a red channel gain using the red channel information, calculates a green channel gain using the green channel information, and calculates a blue channel gain using the blue channel information.
In particular, the terminal device may store or be provided with standard eye white color information, which may be understood as meaning the above-mentioned standard eye white color informationThe information is a target reference information, which is an effect to be achieved by correcting the above-mentioned white region, and may specifically be a set of RGB channel information (R)0,G0,B0)。
The terminal device may calculate the three channel gains based on the three channel information and the standard white color information, that is, the channel gain may be understood as a difference between the three channel information and the standard white color information. The specific formula can be:
(4) gain of red channel: hR=R0-Rs;
(5) Green channel gain: hG=R0-Rs;
(6) Blue channel gain: hB=R0-Rs。
Thus, the color gain for each channel derived as described above can be expressed as (H)R,HG,HB) Step 205 may be performed.
205. The terminal device adds the red channel gain to a red channel of each pixel of the image, adds the green channel gain to a green channel of each pixel of the image, and adds the blue channel gain to a blue channel of each pixel of the image.
Specifically, the terminal device may traverse all points in the image, and add corresponding gains to three channels of each pixel, respectively, to obtain a corrected image. Namely, the color information of the white region of the eyes is used as a source for calculating the gain, and the color cast correction is carried out on the complexion of the human face on the basis of the unchanged color of the white of the eyes.
The embodiment of the invention takes the color information of the white area in the image as the source of the calculation gain to correct the color cast of the image, thereby avoiding the situation that the result of a general white balance color cast detection algorithm is unreliable when no white or high light reflection part exists in the scene or no uniform standard white information exists as a contrast sample, and better improving the complexion of the portrait in the image to normalize and beautify the portrait.
As shown in fig. 3d, another embodiment of the present invention provides a terminal device, including: the device comprises a collecting unit 310, a counting unit 320, a calculating unit 330 and an adjusting unit 340; wherein,
the acquiring unit 310 is used for acquiring an eye white region in the image.
Specifically, the acquisition unit 310 may process the image to obtain an area of the image including the eye image, i.e., may identify the eye in the image and separate the image of the eye portion. The terminal device can call an eye classifier carried in OpenCV to obtain the area containing the eye image. Further, the acquisition unit 310 may perform binarization processing on the obtained region including the eye to realize segmentation of the white region, that is, the white region may be extracted.
Optionally, the collecting unit 310 may further include: an obtaining unit 311 and an extracting unit 312; an obtaining unit 311, configured to obtain a processing region in the image, where the processing region includes an eye image. An extracting unit 312, configured to process the processing region and extract an eye white region in the processing region.
Specifically, the obtaining unit 311 may call an eye classifier provided in OpenCV to process the image, and obtain a processing area in the image, where the processing area is an area including an eye image, that is, the eye in the image may be identified, and the image of the eye portion may be separated.
The extracting unit 312 may perform binarization processing on the image by using a preset processing threshold to realize segmentation of the white region, so as to obtain a corresponding white region. One image includes a target object, a background and noise, and in order to directly extract the target object from a multi-valued digital image, the most common method is to set a threshold T, and divide the data of the image into two parts by T: pixel groups larger than T and pixel groups smaller than T. This is the most specific method for studying gray scale transformation, called binarization of the image. In an embodiment of the present invention, the preset processing threshold may be 200. By performing binarization processing on the above-described processing region by the extraction unit 312, an eye white region in the image can be obtained.
A statistic unit 320, configured to count color information of the eye white region.
The color information of the eye white region may be understood as the color information of the RGB channels of the eye white region, and the statistical unit 320 may count the R, G, B channel information of the eye white region in units of pixels. Specifically, the statistical unit 320 may traverse and sum the pixel information in the white region, thereby counting the color information of the white region.
And a calculating unit 330, configured to match the standard white color information, and calculate a color gain by using the color information.
The terminal device may store or be provided with standard eye white color information, and it may be understood that the standard eye white color information is target reference information, is an effect that the eye white region is desired to be corrected, and may specifically be a set of RGB channel information.
The color gain is a gain value for adjusting the color information, and the calculating unit 330 may calculate the color gain based on the color information and the standard eye white color information, that is, the color gain may be understood as a difference between the color information and the standard eye white color information.
An adjusting unit 340 for adjusting each pixel in the image with the color gain.
Specifically, after the calculating unit 330 calculates the color gain, the adjusting unit 340 adjusts each pixel in the image by the color gain, so that each pixel is compensated by the color gain. With the color information of the white region as a source of the calculation gain, the adjusting unit 340 may perform color shift correction on the face skin color based on the color of the white region of the eyes unchanged.
Optionally, the statistical unit 320 may be specifically configured to:
counting red channel information, green channel information and blue channel information of the eye white area;
the calculating unit 330 is specifically configured to calculate a red channel gain using the red channel information, calculate a green channel gain using the green channel information, and calculate a blue channel gain using the blue channel information.
The adjusting unit 340 may be specifically configured to add the red channel gain to a red channel of each pixel of the image, add the green channel gain to a green channel of each pixel of the image, and add the blue channel gain to a blue channel of each pixel of the image.
In a general white balance method, the basis is that a specular reflection area or a white area exists in an environment, and the reflected light part of the white area in the specular reflection area is considered to be capable of reflecting the chromaticity information of a light source, so that a white balance algorithm is to count the brightness maximum value of RGB three channels or the brightness information of pixels with the brightness value larger than 80% (which can be selected according to requirements), obtain the brightness and chromaticity information suitable for human eyes in a uniform Lab color space, and use the chromaticity distance between the obtained chromaticity information and an ideal light source as a standard for judging whether the color cast exists in an image.
Each unit of the terminal device in the embodiment of the present invention may be executed by referring to the specific method in the embodiment shown in fig. 1 and fig. 2, and details are not described here.
The terminal equipment in the embodiment of the invention can carry out color cast correction on the image by taking the color information of the white eye area in the image as a source of the calculation gain, can avoid the condition that the result of a general white balance color cast detection algorithm is unreliable when no white or high light reflection part exists in a scene or no uniform standard white information is taken as a contrast sample, and can better improve the skin color of the portrait in the image so as to normalize and beautify the portrait.
Referring to fig. 4, a schematic block diagram of a terminal device according to another embodiment of the present invention is shown. As shown, the terminal device in this embodiment may include: one or more processors 401; one or more input devices 402, one or more output devices 403, and memory 404. The processor 401, the input device 402, the output device 403, and the memory 404 are connected by a bus 405. The memory 404 is used to store a computer program comprising program instructions and the processor 401 is used to execute the program instructions stored by the memory 404. Wherein processor 401 is configured to execute program instructions stored by memory 404.
A processor 401 for acquiring an eye white region in the image.
Specifically, the processor 401 may process the image to obtain an area of the image including the eye image, that is, may identify the eye in the image and separate the image of the eye portion. The terminal device can call an eye classifier carried in OpenCV to obtain the area containing the eye image. Further, the processor 401 may process the obtained region including the eye to realize segmentation of the white region, that is, the white region may be extracted.
Optionally, the processor 401 may specifically be configured to: obtaining a processing region in the image, the processing region comprising an eye image; and carrying out binarization processing on the processing area, and extracting an eye white area in the processing area.
Specifically, the processor 401 may invoke an eye classifier provided in OpenCV, process the image, and obtain a processing area in the image, where the processing area is an area including an eye image, that is, may identify an eye in the image and separate an image of an eye portion.
The processor 401 may perform binarization processing on the image through a preset processing threshold, so as to implement segmentation on the white region, thereby obtaining a corresponding white region. One image includes a target object, a background and noise, and in order to directly extract the target object from a multi-valued digital image, the most common method is to set a threshold T, and divide the data of the image into two parts by T: pixel groups larger than T and pixel groups smaller than T. This is the most specific method for studying gray scale transformation, called binarization of the image. In an embodiment of the present invention, the preset processing threshold may be 200. The processor 401 binarizes the processing region, and an eye white region in the image can be obtained.
The processor 401 is further configured to count color information of the white region.
The color information of the eye white region may be understood as color information of RGB channels of the eye white region, and the processor 401 may count R, G, B channel information of the eye white region in units of pixels. Specifically, the processor 401 may traverse and sum the pixel information in the white region, thereby counting the color information of the white region.
The processor 401 is further configured to match the standard white color information and calculate a color gain using the color information.
The terminal device may store or be provided with standard eye white color information, and it may be understood that the standard eye white color information is target reference information, is an effect that the eye white region is desired to be corrected, and may specifically be a set of RGB channel information.
The color gain is a gain value for adjusting the color information, and the processor 401 may calculate the color gain based on the color information and the standard eye white color information, that is, the color gain may be understood as a difference between the color information and the standard eye white color information.
The processor 401 is further configured to adjust each pixel in the image with the color gain.
Specifically, after the processor 401 calculates the color gain, the processor 401 adjusts each pixel in the image by the color gain so that each pixel compensates for the color gain. With the color information of the white region as a source for calculating the gain, the processor 401 may perform color shift correction on the face skin color based on the color of the white region of the eyes unchanged.
Optionally, the processor 401 may specifically be configured to:
counting red channel information, green channel information and blue channel information of the eye white area;
the processor 401 may be specifically configured to calculate a red channel gain using the red channel information, a green channel gain using the green channel information, and a blue channel gain using the blue channel information.
The processor 401 may be specifically configured to add the red channel gain to a red channel of each pixel of the image, add the green channel gain to a green channel of each pixel of the image, and add the blue channel gain to a blue channel of each pixel of the image.
In a general white balance method, the basis is that a specular reflection area or a white area exists in an environment, and the reflected light part of the white area in the specular reflection area is considered to be capable of reflecting the chromaticity information of a light source, so that a white balance algorithm is to count the brightness maximum value of RGB three channels or the brightness information of pixels with the brightness value larger than 80% (which can be selected according to requirements), obtain the brightness and chromaticity information suitable for human eyes in a uniform Lab color space, and use the chromaticity distance between the obtained chromaticity information and an ideal light source as a standard for judging whether the color cast exists in an image.
The processor of the terminal device in the embodiment of the present invention may refer to the functions of each unit in the embodiment shown in fig. 3d, which is not described herein again.
The terminal equipment in the embodiment of the invention can carry out color cast correction on the image by taking the color information of the white eye area in the image as a source of the calculation gain, can avoid the condition that the result of a general white balance color cast detection algorithm is unreliable when no white or high light reflection part exists in a scene or no uniform standard white information is taken as a contrast sample, and can better improve the skin color of the portrait in the image so as to normalize and beautify the portrait.
In another embodiment of the present invention, a computer readable medium, a computer readable storage medium, a computer storage medium, etc. are provided, wherein the computer readable medium stores a computer program, and the computer program includes program instructions, and when the computer program is executed by a processor, the computer program implements the method for correcting color shift of an image shown in fig. 1 and fig. 2.
The computer readable medium may be an internal storage unit of a device or system related to the image color shift correction method according to any of the foregoing embodiments, for example, a hard disk or a memory of a terminal device. The computer readable medium may also be an external storage device of the terminal device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the terminal device. Further, the computer readable medium may also include both an internal storage unit of the terminal device and an external storage device. The computer-readable medium is used for storing the computer program and other programs and data required by the terminal device. The computer readable medium may also be used for temporarily storing data that has been output or is to be output.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the terminal device and the unit described above may refer to corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may also be an electric, mechanical or other form of connection.
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 of the present invention.
In addition, functional units in the embodiments of the present invention 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 unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable medium. Based on such understanding, the technical solution of the present invention essentially or partially contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program instructions.
Claims (10)
1. An image color cast correction method, characterized in that the method comprises:
acquiring an eye white area in an image; no high light reflectance regions are included in the image;
counting color information of the eye white area;
matching with standard eye white color information, and calculating color gain by using the color information; the color gain is a difference value between the color information and the standard eye white color information;
adjusting each pixel in the image with the color gain.
2. The method of claim 1, wherein capturing the white eye region in the image comprises:
obtaining a processing region in the image, the processing region comprising an eye image;
and carrying out binarization processing on the processing area, and extracting an eye white area in the processing area.
3. The method according to claim 2, wherein the counting the color information of the white eye region comprises:
and counting the red channel information, the green channel information and the blue channel information of the eye white area.
4. The method of claim 3, wherein said calculating a color gain using said color information comprises:
calculating a red channel gain using the red channel information, calculating a green channel gain using the green channel information, and calculating a blue channel gain using the blue channel information.
5. The method of claim 4, wherein the adjusting each pixel in the image with the color gain comprises:
adding the red channel gain to a red channel of each pixel of the image, adding the green channel gain to a green channel of each pixel of the image, and adding the blue channel gain to a blue channel of each pixel of the image.
6. A terminal device, characterized in that the terminal device comprises:
the acquisition unit is used for acquiring an eye white area in the image; no high light reflectance regions are included in the image;
the statistical unit is used for counting the color information of the eye white area;
the calculating unit is used for matching with standard white eye color information and calculating color gain by using the color information; the color gain is a difference value between the color information and the standard eye white color information;
an adjustment unit for adjusting each pixel in the image with the color gain.
7. The terminal device of claim 6, wherein the acquisition unit further comprises:
an obtaining unit configured to obtain a processing region in the image, the processing region including an eye image;
and the extraction unit is used for carrying out binarization processing on the processing area and extracting an eye white area in the processing area.
8. The terminal device according to claim 7, wherein the statistical unit is specifically configured to:
counting red channel information, green channel information and blue channel information of the eye white area;
the calculation unit is specifically configured to calculate a red channel gain using the red channel information, calculate a green channel gain using the green channel information, and calculate a blue channel gain using the blue channel information.
9. The terminal device of claim 8, wherein the adjustment unit is specifically configured to add the red channel gain to a red channel of each pixel of the image, to add the green channel gain to a green channel of each pixel of the image, and to add the blue channel gain to a blue channel of each pixel of the image.
10. A terminal device comprising a processor, an input device, an output device and a memory, the processor, the input device, the output device and the memory being interconnected, wherein the memory is adapted to store a computer program enabling the terminal device to perform the above method, the computer program comprising program instructions, the processor being configured to invoke the program instructions to perform the method according to any of claims 1-5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810369972.6A CN108810397B (en) | 2018-04-23 | 2018-04-23 | Image color cast correction method and terminal equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810369972.6A CN108810397B (en) | 2018-04-23 | 2018-04-23 | Image color cast correction method and terminal equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108810397A CN108810397A (en) | 2018-11-13 |
CN108810397B true CN108810397B (en) | 2021-01-19 |
Family
ID=64093077
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810369972.6A Active CN108810397B (en) | 2018-04-23 | 2018-04-23 | Image color cast correction method and terminal equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108810397B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111008942A (en) * | 2019-12-16 | 2020-04-14 | 吴成 | Image processing method based on light change |
CN111507930B (en) * | 2020-06-18 | 2023-10-10 | 杭州海康威视数字技术股份有限公司 | Image fusion method, device, storage medium and computer equipment |
CN114739644A (en) * | 2022-06-10 | 2022-07-12 | 武汉精立电子技术有限公司 | Method, device and equipment for judging color cast and readable storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1694543A (en) * | 2004-05-09 | 2005-11-09 | 天瀚科技股份有限公司 | Method of automatic detection and processing main colour system of white balance |
CN101217621A (en) * | 2007-01-05 | 2008-07-09 | 安奇逻辑股份有限公司 | Camera module, electronic apparatus having the same and method of manufacturing the same |
CN102237025A (en) * | 2010-04-22 | 2011-11-09 | 冠捷投资有限公司 | Lookup table generation method used in display color correction |
CN105187810A (en) * | 2014-11-11 | 2015-12-23 | 怀效宁 | Automatic white balance method based on face color features and electronic media device |
Family Cites Families (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP4235903B2 (en) * | 2003-09-10 | 2009-03-11 | ソニー株式会社 | Imaging device |
JP2008182369A (en) * | 2007-01-23 | 2008-08-07 | Funai Electric Co Ltd | Imaging device |
CN101662581B (en) * | 2009-09-09 | 2011-06-01 | 谭洪舟 | Multifunctional certificate information collection system |
CN103139572B (en) * | 2011-11-24 | 2016-12-07 | 比亚迪股份有限公司 | Photosensitive device and for its white balance method and device |
CN102768758B (en) * | 2012-07-04 | 2014-10-29 | 南京工业职业技术学院 | Improved color image unsharp masking (USM) method |
CN107623845B (en) * | 2016-07-13 | 2019-09-06 | 中国科学院上海高等研究院 | A kind of image processing method and device based on priori knowledge |
CN106131526B (en) * | 2016-07-13 | 2018-11-16 | 凌云光技术集团有限责任公司 | A kind of white balancing treatment method and device based on rgb space |
CN107644437B (en) * | 2016-07-21 | 2021-01-26 | 宁波舜宇光电信息有限公司 | Color cast detection system and method based on blocks |
CN107135384A (en) * | 2017-05-19 | 2017-09-05 | 中国科学院深圳先进技术研究院 | White balance adjusting method, device, image processing terminal and storage medium |
-
2018
- 2018-04-23 CN CN201810369972.6A patent/CN108810397B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1694543A (en) * | 2004-05-09 | 2005-11-09 | 天瀚科技股份有限公司 | Method of automatic detection and processing main colour system of white balance |
CN101217621A (en) * | 2007-01-05 | 2008-07-09 | 安奇逻辑股份有限公司 | Camera module, electronic apparatus having the same and method of manufacturing the same |
CN102237025A (en) * | 2010-04-22 | 2011-11-09 | 冠捷投资有限公司 | Lookup table generation method used in display color correction |
CN105187810A (en) * | 2014-11-11 | 2015-12-23 | 怀效宁 | Automatic white balance method based on face color features and electronic media device |
Also Published As
Publication number | Publication date |
---|---|
CN108810397A (en) | 2018-11-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP2902941B1 (en) | System and method for visually distinguishing faces in a digital image | |
EP3039864B1 (en) | Automatic white balancing with skin tone correction for image processing | |
KR101554403B1 (en) | Image processing device, image processing method, and recording medium for control program | |
US11138695B2 (en) | Method and device for video processing, electronic device, and storage medium | |
US11321830B2 (en) | Image detection method and apparatus and terminal | |
CN108810397B (en) | Image color cast correction method and terminal equipment | |
CN106611415B (en) | Skin region detection method and device | |
US20140247984A1 (en) | Methods for color correcting digital images and devices thereof | |
US10204403B2 (en) | Method, device and medium for enhancing saturation | |
CN109089041A (en) | Recognition methods, device, electronic equipment and the storage medium of photographed scene | |
CN113298753A (en) | Sensitive muscle detection method, image processing method, device and equipment | |
CN106773453B (en) | Camera exposure method and device and mobile terminal | |
US20150271416A1 (en) | Information Processing Method and Electronic Device | |
CN108932703B (en) | Picture processing method, picture processing device and terminal equipment | |
CN112488933B (en) | Video detail enhancement method and device, mobile terminal and storage medium | |
US9092661B2 (en) | Facial features detection | |
CN108810407B (en) | Image processing method, mobile terminal and computer readable storage medium | |
EP4231621A1 (en) | Image processing method and electronic device | |
CN108805883B (en) | Image segmentation method, image segmentation device and electronic equipment | |
CN108470327B (en) | Image enhancement method and device, electronic equipment and storage medium | |
JPWO2010058678A1 (en) | Designated color region defining circuit, detection circuit, and image processing apparatus using the same | |
EP3273437A1 (en) | Method and device for enhancing readability of a display | |
CN111583163A (en) | AR-based face image processing method, device, equipment and storage medium | |
CN111275725B (en) | Method and device for determining color temperature and tone of image, storage medium and terminal | |
WO2019090591A1 (en) | Photography method and photography system based on smart terminal |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CP01 | Change in the name or title of a patent holder | ||
CP01 | Change in the name or title of a patent holder |
Address after: 518000 Guangdong science and technology innovation and Research Institute, Shenzhen, Shenzhen, Nanshan District No. 6, science and technology innovation and Research Institute, Shenzhen, D 10, 1004, 10 Patentee after: Shenzhen Hetai intelligent home appliance controller Co.,Ltd. Address before: 518000 Guangdong science and technology innovation and Research Institute, Shenzhen, Shenzhen, Nanshan District No. 6, science and technology innovation and Research Institute, Shenzhen, D 10, 1004, 10 Patentee before: SHENZHEN H&T DATA RESOURCES AND CLOUD TECHNOLOGY Ltd. |