WO2018171493A1 - Image processing method and device, and storage medium - Google Patents

Image processing method and device, and storage medium Download PDF

Info

Publication number
WO2018171493A1
WO2018171493A1 PCT/CN2018/079073 CN2018079073W WO2018171493A1 WO 2018171493 A1 WO2018171493 A1 WO 2018171493A1 CN 2018079073 W CN2018079073 W CN 2018079073W WO 2018171493 A1 WO2018171493 A1 WO 2018171493A1
Authority
WO
WIPO (PCT)
Prior art keywords
value
image
pixel
feature
standard
Prior art date
Application number
PCT/CN2018/079073
Other languages
French (fr)
Chinese (zh)
Inventor
钱梦仁
Original Assignee
腾讯科技(深圳)有限公司
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 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of WO2018171493A1 publication Critical patent/WO2018171493A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/80Camera processing pipelines; Components thereof

Definitions

  • the present invention relates to the field of image processing technologies, and in particular, to a method, an apparatus, and a storage medium for processing an image.
  • Embodiments of the present invention provide an image processing method and apparatus, which can reduce the probability of an image being overexposed or too dark, and can make the skin color in the image closer to the natural skin color of the user and improve the image quality.
  • An embodiment of the present invention provides an image processing method, including:
  • the preset standard average value including an image according to a preset standard The value of the characteristic parameter value of the standard feature pixel
  • the corrected original image is output.
  • An embodiment of the present invention further provides an image processing apparatus, the apparatus comprising a processor and a memory, the memory storing computer readable instructions, wherein the processor is:
  • the preset standard average value including an image according to a preset standard The value of the characteristic parameter value of the standard feature pixel
  • An output module for outputting the corrected original image.
  • the embodiment of the present application further provides a computer readable storage medium storing computer readable instructions, which may cause a processor to execute the methods of the embodiments.
  • FIG. 1 is a schematic diagram of an image processing method according to an embodiment of the present invention
  • FIG. 1b is a flowchart of an image processing method according to an embodiment of the present invention.
  • 1c is a flowchart of an image processing method according to another embodiment of the present invention.
  • FIG. 1 is a schematic diagram of skin color detection in an image processing method according to an embodiment of the invention
  • FIG. 2 is a flowchart of a method for correcting characteristic parameter values of image pixels of an original image in an image processing method according to an embodiment of the present invention
  • 2b is a frame diagram of obtaining a standard average value in an image processing method according to an embodiment of the present invention
  • FIG. 3 is a flowchart of correcting feature parameter values of each image pixel of an original image in an image processing method according to an embodiment of the present invention
  • FIG. 4 is a flowchart of an image processing method according to another embodiment of the present invention.
  • FIG. 5 is a flowchart of an image processing method according to another embodiment of the present invention.
  • FIG. 6 is a flowchart of an image processing method according to still another embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of an image processing apparatus according to an embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of an image processing apparatus according to another embodiment of the present invention.
  • FIG. 9 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
  • Embodiments of the present invention provide an image processing method and a processing device.
  • the image processing device may be specifically integrated in the terminal, and the terminal may be, for example, a smart phone, a tablet computer, a personal computer, or the like.
  • the image processing apparatus may acquire an original image, for example, may acquire a real-time image acquired by a camera or other image capturing device, or may acquire a picture selected by the user, or receive a picture sent by another device.
  • Etc. then perform skin color detection on the image pixels of the original image to determine the original skin color pixels in the original image, for example, skin color detection by skin color statistical model, such as RGB color space skin color statistics, or skin color detection by threshold segmentation, etc.
  • Etc. by calculating an average value of the characteristic parameter values of the original skin color pixels, and correcting the characteristic parameter values of the image pixels of the original image according to the difference between the preset standard average value and the calculated average value, thereby outputting The corrected original image.
  • the original image is optimized based on the skin color, that is, the feature parameter value of the skin color pixel of the original image and the feature parameter value of the skin color pixel of the preset standard image are referenced by the preset standard image.
  • the exposure of the original image can be judged to correct the original image, so that the skin color of the original image is closer to the skin color of the standard image, so that the illumination of the original image is closer to the natural situation, and can be avoided to a certain extent.
  • the phenomenon that the image is overexposed or too dark is conducive to improving the quality of the photo.
  • FIG. 1b is a flow chart of an embodiment of an image processing method of the present invention. As shown, the image processing method includes the following steps:
  • Step 101b Acquire an original image.
  • the acquiring the original image may be a picture acquired by a camera or other image capturing device in real time, or acquiring a photo selected by a user in an album in a terminal device (such as a mobile phone, etc.), or in a terminal device (such as a mobile phone, etc.)
  • the client such as WeChat, QQ, etc. receives pictures sent by other users.
  • the original image may be a person image, a landscape image, an animal image, or the like.
  • Step 102b Perform feature detection on image pixels of the selected area in the original image to determine feature pixels of the selected area in the original image.
  • the selected area in the original image may be a plurality of areas.
  • the feature pixels of the selected area may be the feature pixels of the plurality of areas.
  • the selected area when the original image is a character image, the selected area may be a face area, an entire image, or other areas of the original image that include human skin pixels.
  • the selected area when the original image is a landscape image, an animal image, or the like, the selected area may be an entire image, or may be an area occupied by a certain target object in the image.
  • the image pixels of the selected area in the original image are subjected to feature detection to detect the skin color of the image of the selected area in the original image, and the skin color detection manner may be various.
  • a skin color statistical model is established for skin color detection to determine all skin color pixels of a selected region (eg, a face region) in the original image.
  • the image pixels of the selected area in the original image are subjected to feature detection to perform target detection on the original image
  • the target detection manner is various, for example, RCNN algorithm (Region Convolutional Neural Network), Fast-RCNN algorithm, Faster-RCNN algorithm, Mask RCNN algorithm, etc., through the target detection, the target in the original image (such as animal, tree, Castle, etc., thereby determining the subject color of the target (when there are multiple targets in the original image, selecting the subject color of the subject target, such as the largest target in the image), for example, the color of the trunk The color of the castle wall, etc.
  • RCNN algorithm Regular Convolutional Neural Network
  • Fast-RCNN algorithm Faster-RCNN algorithm
  • Mask RCNN algorithm etc.
  • Step 103b Calculate an average value of the feature parameter values of the feature pixels.
  • the average value of the feature parameter values of all skin color pixels is calculated.
  • the tree in the landscape image is determined by step 102B, and the color of the trunk is determined, and the average value of the feature parameter values of all trunk colors is calculated.
  • Step 104b correcting, according to a difference between a preset standard average value and an average value of the feature parameter values, a feature parameter value of each image pixel of the original image, where the preset standard average value includes The value calculated from the characteristic parameter values of the standard feature pixels of the standard image.
  • Step 105b Output the corrected original image.
  • the target (person, tree, castle, animal, etc.) in the original image can be made closer to its natural color, so that the target display in the original image is more realistic, and the phenomenon of overexposure or overdark is avoided.
  • the feature pixels of the selected area are obtained by performing feature detection on the image pixels of the selected area in the original image, and the average value of the characteristic parameter values of the feature pixel is calculated according to a preset standard. The difference between the average value and the calculated average value is corrected for the characteristic parameter values of the image pixels of the original image. Therefore, with the technical solution of the present application, the original image can be calculated and corrected according to the feature pixels of the locally selected region in the original image.
  • the present application can improve the correction accuracy of the original image.
  • FIG. 1c is a flowchart of an embodiment of the image processing method of the present invention. As shown, the image processing method includes the following steps:
  • Step S101c Acquire an original image.
  • the original image is the image to be processed.
  • the obtained original image may be various.
  • acquiring the original image may include: acquiring a picture acquired by a camera or other image capturing device in real time to obtain an original image; or acquiring a picture selected by the user to obtain an original image; Or, receiving a picture sent by the terminal device to obtain an original image, and the like.
  • Step S102c Perform skin color detection on image pixels of the selected area in the original image to determine original skin color pixels of the selected area in the original image.
  • the skin color pixel is the human skin pixel.
  • the selected area is a face area
  • image pixels of the face area in the original image are selected for skin color detection.
  • face detection is performed on the original image to determine a face region of the original image.
  • performing skin color detection on the image pixels of the original image is specifically: performing skin color detection on the image pixels in the face region of the original image to determine original skin color pixels in the original image.
  • skin color detection is performed on the image pixels of the entire original image to determine the original skin color pixel of the original image.
  • a face detection function provided by a terminal system such as iOS or Android may be used to detect a face by using the face detection function when the image processing apparatus acquires a picture acquired by a camera or other image acquisition device in real time;
  • a face detection algorithm provided by software such as OpenCV (Open Source Computer Vision Library) and Tencent Excellent Picture. The above software is used when the image processing apparatus acquires a picture selected by a user or receives a picture transmitted by a terminal device.
  • the provided face detection algorithm detects the face.
  • the face region when the original image is obtained according to the user's selection, the face region may also be actively marked by the user. Specifically, when the user selects the original image, the face in the original image may be marked, thereby marking according to the user The area determines the face area in the original image.
  • skin color detection can be performed by establishing a skin color statistical model, such as based on Y (brightness) Cg (difference between green component and brightness) Cr (difference between red component and brightness) and YCgCb (blue Difference between color component and brightness) Skin color detection in color space.
  • the skin color detection result 10b is obtained by performing skin color detection on the face area 11, wherein the white area represents the skin color area and the black area represents the non-skin color area in the skin color detection result 10b.
  • the amount of calculation can be reduced, the cost of skin color detection can be reduced, and the noise point can be reduced, compared to the skin color detection of the full image region.
  • Step S103c Calculate an average value of the feature parameter values of the original skin color pixels.
  • the feature parameter value refers to the value of the parameter of the pixel, and may be, for example, a grayscale value, a chrominance value, or the like of the pixel.
  • the feature parameter values of the original skin color pixels may be one or more, and when there are multiple feature parameter values, the average value of each feature parameter value is calculated separately.
  • the calculating process of the average value of a certain feature parameter value may specifically include: acquiring feature parameter values of each original skin color pixel; counting the number of original skin color pixels; and calculating a sum of the same feature parameter values of all the original skin color pixels. Calculating the ratio of the sum to the number of original skin color pixels, thereby obtaining an average of the same feature parameter values of all the original skin color pixels.
  • Step S104c correcting the feature parameter values of each image pixel of the original image according to the difference between the preset standard average value and the average value of the feature parameters, and the preset standard average value is according to the preset standard image.
  • the characteristic parameter values of the standard skin color pixels are calculated.
  • Step S105c Output the corrected original image.
  • the skin color of the user is displayed in the standard image, and the image with normal exposure and brightness is relatively close to the natural condition, and the skin color in the standard image is the skin color closest to the natural skin color of the user.
  • the skin color of the original image is darker or brighter than the skin color of the standard image, and further Adjusting the original image according to the difference can make the skin color of the original image closer to the skin color of the standard image (that is, the user's natural skin color), so that the portrait image of the original image is more normal, avoiding overexposure or excessive darkness.
  • the whole image of the original image is adjusted, so that the brightness of the whole image is closer to the natural situation, the brightness of the light is more balanced, and the image is prevented from being overexposed or too dark, thereby improving the image quality.
  • the corrected original image is output and displayed as a real-time image.
  • the image processing apparatus in the terminal automatically adjusts the original image so that the real-time screen seen by the user is already the adjusted image, thereby Make the photos taken by users better.
  • the user is non-perceived, thereby further enhancing the user experience.
  • the original image is an image selected by the user, for example, an image selected by the user in the album
  • the corrected original image is output and saved in the album in step S105c.
  • the user selects one image in the album in the terminal, and the image processing device in the terminal adjusts the image, so that the image is rendered better. In this case, the user can clearly perceive the difference before and after the image adjustment.
  • the method further includes the step of calculating a standard average value. Specifically, referring to FIG. 2a, and in combination with FIG. 2b, each image of the original image is obtained according to a difference between the calculated average value and the preset standard value. Before the pixel's characteristic parameter values are corrected, the following steps are also included:
  • Step S201 Acquire at least two standard images.
  • the standard image can be selected by the user, and the user can select an image that is closer to the skin color of the user as a standard image, and obtain a standard image according to the user's selection.
  • Step S202 Perform skin color detection on image pixels of each standard image to determine standard skin color pixels of the standard image.
  • the method before step S202, further includes: performing face detection on each standard image to determine a face region of the standard image.
  • the skin color detection is performed on the image pixels of each standard image, specifically, the skin color detection is performed on the image pixels in the face region of the standard image to determine standard skin color pixels in the standard image.
  • skin color detection is performed on the image pixels of the entire standard image to determine standard skin color pixels.
  • Step S203 Calculate an average value of the feature parameter values of the standard skin color pixels of each standard image.
  • This step is similar to the calculation method of step S103b.
  • the calculation process may be as follows: acquiring the feature parameter value of the standard skin color pixel of the standard image ; count the number of standard skin color pixels; calculate the sum of the same feature parameter values of all standard skin color pixels, calculate the ratio of the sum to the number of standard skin color pixels, thereby obtaining the same feature parameter of all standard skin color pixels of each standard image The average of the values.
  • Step S204 averaging the average values of the characteristic parameter values of the standard skin color pixels of all standard images to obtain a standard average value.
  • the calculation step of the standard average includes: counting the total number of standard image images; calculating the sum of the average values of the same feature parameter values of the standard skin color pixels of all standard images; calculating the ratio of the sum to the total number of standard images, thereby obtaining a standard skin color
  • the standard average of the same characteristic parameter values for the pixel includes: counting the total number of standard image images; calculating the sum of the average values of the same feature parameter values of the standard skin color pixels of all standard images; calculating the ratio of the sum to the total number of standard images, thereby obtaining a standard skin color
  • the standard average of the same characteristic parameter values for the pixel includes: counting the total number of standard image images; calculating the sum of the average values of the same feature parameter values of the standard skin color pixels of all standard images; calculating the ratio of the sum to the total number of standard images, thereby obtaining a standard skin color
  • the standard average of the same characteristic parameter values for the pixel includes: counting the total number of standard image images; calculating the sum of the average values of the same
  • the standard average value can be made closer to the natural skin color of the user, and thus, based on the standard average value, according to the characteristics of the original skin color pixel
  • the difference between the average of the parameter values and the standard average adjusts the original image to make the skin tone in the original image closer to the user's natural skin tone.
  • a standard image may also be selected to calculate a standard average value, in which the standard average is the average of the characteristic parameter values of the standard skin color pixels of the standard image.
  • correcting the characteristic parameter values of each image pixel of the original image according to the difference between the calculated average value and the preset standard average value includes the following sub-steps:
  • Sub-step S301 Calculating the difference between the preset standard average value and the average value of the feature parameter values of the original skin color pixels.
  • the difference specifically refers to the difference between the standard average value minus the average value of the characteristic parameter values of the original skin color pixels.
  • Sub-step S302 Acquire feature parameter values of each image pixel of the original image.
  • Sub-step S303 calculating a correction coefficient of each image pixel according to an average value of the feature parameter values of the original skin color pixel and a feature parameter value of each image pixel.
  • the correction coefficient of the image pixel is a ratio of the feature parameter value of the image pixel to the average value of the feature parameter values of the original skin color pixel.
  • the feature parameter value of the image pixel is greater than the average value of the feature parameter value of the original skin color pixel, calculating a first difference between the preset constant and the feature parameter value of the image pixel, and calculating a preset constant and a feature of the original skin color pixel A second difference between the average values of the parameter values, the correction coefficient of the image being the ratio of the first difference to the second difference.
  • Sub-step S304 correcting the feature parameter values of the image pixels of the original image according to the difference between the preset standard average value and the average value of the feature parameter values of the original skin color pixels, and the correction coefficient of the image pixels.
  • the feature parameter values of the image pixels of the original image are corrected according to the following formula:
  • C 1 represents a characteristic parameter value of the corrected image pixel
  • C 0 represents a characteristic parameter value of the image pixel before the correction, that is, a characteristic parameter value of the original image pixel acquired in step S302
  • ⁇ C The difference between the standard average of the corresponding feature parameter values representing the standard skin color pixels and the average of the corresponding feature parameter values of the original skin color pixels
  • k represents the correction coefficient of the image pixels.
  • the correction coefficient k is:
  • the correction coefficient k is:
  • n (nC 0 ) / (nC a ), where C 0 > C a , n is a preset constant (3).
  • the feature parameter value includes pixel values of three primary color components of red, green, and blue in the first color space, wherein the first color space is red, green, and blue RGB (Red, Green) , Blue (blue)) color space.
  • the pixel value of each primary color component of the pixel ranges from 0 to 1.
  • the standard average value of the pixel values of the red, green, and blue primary color components of the standard skin color pixel of the standard image may be calculated in advance according to the above steps S201 to S204.
  • the image processing method of this embodiment specifically includes the following steps:
  • Step S401 Acquire an original image.
  • Step S402 Perform skin color detection on the image pixels of the original image to determine original skin color pixels in the original image.
  • Step S403 Obtain pixel values of three primary color components of red, green, and blue of each original skin color pixel in the original image, and calculate an average value of pixel values of three primary color components of red, green, and blue of all original skin color pixels in the original image. The average of the feature parameter values of the original skin tone pixels.
  • the total amount of the original skin color pixels is first counted.
  • the red component as an example, the pixel values of the red components of the original skin color pixels are obtained, the sum of the pixel values of the red components of all the original skin color pixels is calculated, and then the sum of the pixel values of the red components of all the original skin color pixels and the original skin color pixels are calculated.
  • the ratio of the total amount resulting in an average of the pixel values of the red component of the original skin tone pixel.
  • the average of the pixel values of the green component and the blue component can be calculated in a similar manner.
  • Step S404 calculating a difference between a standard average value of the pixel values of the three primary color components of the standard skin color pixels in the preset standard image and an average value of the pixel values of the corresponding primary color components of the original skin color pixel in the original image.
  • the standard average of the pixel values of the red component of the standard skin color pixel is subtracted from the average of the pixel values of the red component of the original skin color pixel, and the standard average of the pixel values of the green component of the standard skin color pixel, respectively.
  • the difference between the average value of the pixel values of the green component of the original skin color pixel, the standard average value of the pixel values of the blue component of the standard skin color pixel, and the difference of the average value of the pixel values of the blue component of the original skin color pixel are subtracted .
  • Step S405 Acquire pixel values of three primary color components of red, green, and blue of each image pixel to obtain characteristic parameter values of each image pixel.
  • Step S406 Calculate red, green, and blue of each image pixel according to an average value of pixel values of three primary color components of the original skin color pixel, and pixel values of three primary color components of red, green, and blue of each image pixel. A correction factor for the pixel values of the three primary color components.
  • the correction coefficients of the pixel values of the three primary color components of the red, green and blue of each image pixel in the original image are calculated according to the above formula 2 and formula 3.
  • the red component when the pixel value of the red component of the image pixel is less than or equal to the average value of the pixel value of the red component of the original skin color pixel, the correction coefficient of the pixel value of the red component of the image pixel is calculated by using the formula 2, where the formula C 0 in the two represents the pixel value of the red component of the image pixel, and C a represents the average value of the pixel values of the red component of the original skin color pixel.
  • the correction coefficient of the red component of the image pixel is calculated by using Equation 3, where n in Equation 3 is 1, that is, when the pixel When the value ranges from 0 to 1, the preset constant is 1.
  • C 0 , C a and n are substituted into the above formula 2 or formula 3 to calculate the image pixel.
  • the correction factor for the pixel value of the red component is substituted into the above formula 2 or formula 3 to calculate the image pixel.
  • correction coefficients of the pixel values of the green component and the blue component can be obtained in a similar manner, and will not be described herein.
  • Step S407 The difference between the standard average value of the pixel values of the red, green, and blue primary color components of the standard skin color pixel in the preset standard image and the average value of the pixel values of the corresponding primary color component of the original skin color pixel in the original image. And a correction coefficient of the pixel values of the three primary color components of the red, green, and blue components of each image pixel, and correcting the pixel values of the three primary color components of the red, green, and blue color of each image pixel.
  • the pixel values of the three primary color components of the red, green and blue of each image pixel of the pair of original images are corrected according to the above formula.
  • C 1 represents the pixel value of the red component of the corrected image pixel
  • C 0 represents the pixel value of the red component of the image pixel before correction
  • ⁇ C represents the standard skin color pixel.
  • k represents the correction coefficient of the image pixel, thereby substituting C 0 , ⁇ C, and k into the above formula 1
  • the pixel value of the red component of the corrected image pixel can be calculated.
  • the correction process of the pixel values of the green component and the blue component of the image pixel is thus derived.
  • the pixel values of the respective primary color components corrected for each image pixel can be obtained, and the original image can be corrected.
  • Step S408 Output the corrected original image.
  • the brightness of the corrected original image can be made closer to the natural situation, and the displayed skin color is closer to the natural skin color of the user. It is beneficial to reduce the phenomenon of excessive darkness or overexposure of images and improve image quality.
  • the feature parameter value includes a luminance value, a first chrominance value, and a second chrominance value on the second color space, wherein the second color space is YUV (Luminance, Chroma) Degree)) Color space, for convenience of description, the brightness value is represented by a Y value, the first chromaticity value is represented by a U value, and the second chromaticity value is represented by a V value.
  • the second color space is YUV (Luminance, Chroma) Degree)
  • the Y value, the U value, and the standard average value of the V value of the standard skin color pixel of the standard image may be calculated in advance according to the above steps S201 to S204.
  • the image processing method of this embodiment specifically includes the following steps:
  • Step S501 Acquire an original image.
  • Step S502 Perform skin color detection on image pixels of the original image to determine original skin color pixels in the original image.
  • Step S503 Obtain pixel values of three primary color components of red, green, and blue in the RGB color space of each original skin color pixel in the original image, according to pixel values of three primary color components of red, green, and blue of each original skin color pixel in the original image. Calculate the Y value, U value, and V value of each original skin color pixel in the YUV color space, and calculate the average value of the Y values of all the original skin color pixels, the average value of the U value, and the average value of the V values to obtain the original skin color pixels. The average of the characteristic parameter values.
  • the pixel value of each primary color component of each original skin color pixel ranges from 0 to 1.
  • Y 1 , U 1 , and V 1 respectively represent Y values, U values, and V values of the original skin color pixels in the YUV color space
  • R 1 , G 1 , and B 1 respectively represent the original skin color pixels in the RGB color space.
  • the total amount of the original skin color pixels is counted, and the sum of the Y values of all the original skin color pixels, the sum of the U values, and the sum of the V values are calculated, and then respectively calculated.
  • the ratio of the sum of the Y values to the total amount of the original skin color pixels, the ratio of the sum of the U values to the total amount of the original skin color pixels, and the ratio of the sum of the V values to the total amount of the original skin color pixels, thereby respectively obtaining the Y of the original skin color pixel The average of the values, the average of the U values, and the average of the V values.
  • Step S504 calculating a difference between a standard average value of the Y value, the U value, and the V value of the standard skin color pixel in the preset standard image and an average value of the corresponding Y value, the U value, and the V value of the original skin color pixel in the original image.
  • the difference between the standard average value of the Y value of the standard skin color pixel and the average value of the Y value of the original skin color pixel, the standard average value of the U value of the standard skin color pixel, and the U value of the original skin color pixel are respectively calculated.
  • the difference between the average values, the standard average of the V values of the standard skin tone pixels, and the difference between the average values of the V values of the original skin tone pixels are respectively calculated.
  • Step S505 Acquire a Y value, a U value, and a V value of each image pixel of the original image to obtain a feature parameter value of each image pixel of the original image.
  • the Y value, the U value, and the V value of each image pixel are similar to the calculation methods of the Y value, the U value, and the V value of the original skin color pixel, and can be implemented by referring to the above formula 4, and will not be described herein.
  • Step S506 Calculate the Y value and the U value of each image pixel according to the average value of the Y value of the original skin color pixel, the average value of the U value, and the average value of the V value, and the Y value, the U value, and the V value of each image pixel. And the correction factor of the V value.
  • the correction values of the Y value, the U value, and the V value of each image pixel in the original image are calculated according to the above formula 2 and formula 3.
  • the correction coefficient of the Y value of the image pixel is calculated by Equation 2, where C 0 in Formula 2 represents the image pixel.
  • the Y value, C a represents the average of the Y values of the original skin color pixels.
  • Equation 3 the correction coefficient of the red component of the image pixel is calculated using Equation 3, where n in Equation 3 is 1.
  • the correction coefficients of the U value and the V value can be obtained in a similar manner, and will not be described again.
  • Step S507 The difference between the standard average value of the Y value, the U value, and the V value of the standard skin color pixel in the preset standard image and the corresponding Y value, the U value, and the average value of the V value of the original skin color pixel in the original image. And a correction coefficient of the Y value, the U value, and the V value of each image pixel, and correct the Y value, the U value, and the V value of each image pixel.
  • the Y value, the U value, and the V value of each image pixel of the pair of original images are corrected according to the above formula.
  • C 1 represents the Y value of the corrected image pixel
  • C 0 represents the Y value of the image pixel before correction
  • ⁇ C represents the standard average value of the Y value of the standard skin color pixel.
  • k represents the correction coefficient of the image pixels.
  • the way in which the U and V values of the image pixels are corrected is thus derived. In the above manner, the corrected Y value, U value, and V value of each image pixel can be obtained, and the original image can be corrected.
  • Step S508 Output the corrected original image.
  • the outputting the corrected original image specifically includes: calculating, according to the corrected Y value, U value, and V value of each image pixel, pixel values of the three primary color components of the red, green, and blue color of each corrected image pixel, thereby obtaining RGB
  • the original image of the format, the original image of the corrected RGB format is output.
  • the pixel values of the three primary color components of the red, green and blue pixels of each image pixel after correction are calculated according to the following formula:
  • Y 2 , U 2 , and V 2 respectively represent Y values, U values, and V values of the corrected image pixels
  • R 2 , G 2 , and B 2 respectively represent the three primary colors of red, green, and blue of the corrected image pixels.
  • the pixel value of the component
  • the image quality of the corrected original image can be further improved, so that the brightness of the corrected original image is closer to the natural situation.
  • the displayed skin tone is closer to the user's natural skin tone.
  • only the Y value of the image pixel may be corrected without adjusting the U value and the Y value, and the U value and the V value are unchanged before and after the correction, that is, only the brightness of the original image is adjusted, and the original The chromaticity of the image is not adjusted. In this way, the probability of the original image being overexposed or too dark can be reduced to some extent, and the correction process can be simplified.
  • the main difference between the present embodiment and the embodiment shown in FIG. 5 is that the present embodiment only corrects the Y value of the image pixel. Therefore, the specific calibration process may be performed by referring to the Y value correction process of the embodiment shown in FIG. 5. For the sake of brevity, we will not repeat them here.
  • the feature parameter value includes a tone value, a saturation value, and a brightness value in a third color space, wherein the third color space is HSV (Hue, Saturation, Value (Lightness))
  • HSV Human, Saturation, Value (Lightness)
  • the tone value is represented by an H value
  • the saturation value is represented by an S value
  • the brightness value is represented by a V value.
  • the standard value of the H value, the S value, and the V value of the standard skin color pixel of the standard image may be calculated in advance according to the above steps S201 to S204.
  • the image processing method of this embodiment specifically includes the following steps:
  • Step S601 Acquire an original image.
  • Step S602 Perform skin color detection on image pixels of the original image to determine original skin color pixels in the original image.
  • Step S603 acquiring pixel values of three primary color components of red, green, and blue of each original skin color pixel in the original image, according to pixel values of three primary color components of red, green, and blue of each original skin color pixel in the original image. Calculate the H value, S value and V value of each original skin color pixel in the HSV color space, and calculate the average value of the H value of all the original skin color pixels, the average value of the S value, and the average value of the V value to obtain the original skin color pixel. The average of the characteristic parameter values.
  • the pixel value of each primary color component of each original skin color pixel ranges from 0 to 1.
  • the H value, S value, and V value in the HSV color space according to each original skin color pixel are calculated as follows:
  • the S value is calculated as follows:
  • the V value is calculated as follows:
  • V 1 M (eight)
  • H 1 , S 1 , and V 1 respectively represent H values, S values, and V values of the original skin color pixels in the HSV color space
  • R 1 , G 1 , and B 1 respectively represent the original skin color pixels on the RGB color space.
  • the total amount of the original skin color pixels is counted, and the sum of the H values of all the original skin color pixels, the sum of the S values, and the sum of the V values are calculated, and then respectively calculated.
  • the ratio of the sum of the H values to the total amount of the original skin color pixels, the ratio of the sum of the S values to the total amount of the original skin color pixels, and the ratio of the sum of the V values to the total amount of the original skin color pixels thereby respectively obtaining the H of the original skin color pixels.
  • Step S604 calculating a difference between a standard average value of the H value, the S value, and the V value of the standard skin color pixel in the preset standard image and an average value of the corresponding H value, the S value, and the V value of the original skin color pixel in the original image.
  • the difference between the standard average of the H value of the standard skin color pixel and the average value of the H value of the original skin color pixel, the standard average value of the S value of the standard skin color pixel, and the S value of the original skin color pixel are respectively calculated.
  • Step S605 Acquire an H value, an S value, and a V value of each image pixel of the original image to obtain a feature parameter value of each image pixel of the original image.
  • the H value, the S value, and the V value of each image pixel are similar to the calculation methods of the H value, the S value, and the V value of the original skin color pixel, and can be calculated by referring to the above formulas 6, 7, and 8. One by one.
  • Step S606 Calculate the H value and the S value of each image pixel according to the average value of the H value of the original skin color pixel, the average value of the S value, and the average value of the V value, and the H value, the S value, and the V value of each image pixel. And the correction factor of the V value.
  • the correction coefficients of the H value, the S value, and the V value of each image pixel in the original image are calculated according to the above formula 2 and formula 3.
  • the correction coefficient of the H value of the image pixel is calculated by Equation 2, where C 0 in Formula 2 represents the image pixel.
  • the value of H, C a represents the average of the H values of the original skin tone pixels.
  • the correction coefficient of the red component of the image pixel is calculated by Equation 3, where n in Equation 3 is 1.
  • the correction coefficients of the S value and the V value can be obtained in a similar manner, and will not be described again.
  • Step S607 The difference between the standard average value of the H value, the S value, and the V value of the standard skin color pixel in the preset standard image and the average value of the corresponding H value, the S value, and the V value of the original skin color pixel in the original image. And a correction coefficient of the H value, the S value, and the V value of each image pixel, and correct the H value, the S value, and the V value of each image pixel.
  • the H value, the S value, and the V value of each image pixel of the pair of original images are corrected according to the above formula.
  • C 1 represents the H value of the corrected image pixel
  • C 0 represents the H value of the image pixel before the correction
  • ⁇ C represents the standard average value of the H value of the standard skin color pixel.
  • k represents the correction coefficient of the image pixels.
  • the way to correct the S and V values of the image pixels is thus derived. In the above manner, the corrected H value, S value, and V value of each image pixel can be obtained, and the original image can be corrected.
  • Step S608 Output the corrected original image.
  • the outputting the corrected original image specifically includes: calculating, according to the corrected H value, S value, and V value of each image pixel, pixel values of the three primary color components of the red, green, and blue color of each corrected image pixel, thereby obtaining RGB
  • the original image of the format, the original image of the corrected RGB format is output.
  • the pixel values of the red, green and blue primary color components of each image pixel after correction are calculated as follows:
  • iH be an integer between 0 and (H 2 *6), including 0;
  • the pixel values of the red, green and blue primary colors of each image pixel after correction are:
  • H 2 , S 2 , and V 2 respectively represent the H value, the S value, and the V value of the corrected image pixel
  • R 2 , G 2 , and B 2 respectively represent the three primary colors of red, green, and blue of the corrected image pixel.
  • the pixel value of the component
  • the image quality of the corrected original image can be further improved, so that the brightness of the corrected original image is closer to the natural condition.
  • the displayed skin tone is closer to the user's natural skin tone.
  • the image processing apparatus may be a terminal device such as a mobile phone, a tablet computer or a personal computer.
  • the image processing apparatus includes a first acquisition module 701, a first skin color detection module 702, a first calculation module 703, a correction module 704, and an output module 705.
  • the first obtaining module 701 is configured to acquire an original image.
  • the original image is the image to be processed.
  • the obtained original image may be various.
  • acquiring the original image may include: acquiring a picture acquired by a camera or other image capturing device in real time to obtain an original image; or acquiring a picture selected by the user to obtain an original image; Or, receiving a picture sent by the terminal device to obtain an original image, and the like.
  • the first skin color detecting module 702 is configured to perform skin color detection on the image pixels of the original image acquired by the first acquiring module 701 to determine original skin color pixels in the original image.
  • the skin color pixel is the human skin pixel.
  • face detection there are various ways of face detection, such as a method based on traditional knowledge, a method based on geometric features, etc., and a combination of one or several methods may be used for face detection.
  • the face region when the original image is obtained according to the user's selection, the face region may be actively marked by the user. Specifically, when the user selects the original image, the face in the original image may be marked, thereby The area determines the face area in the original image.
  • skin color pixels There are many ways to detect skin color pixels.
  • skin color detection can be performed by establishing a skin color statistical model, such as based on Y (brightness) Cg (difference between green component and brightness) Cr (difference between red component and brightness) and YCgCb (blue Difference between color component and brightness) Skin color detection in color space.
  • a skin color statistical model such as based on Y (brightness) Cg (difference between green component and brightness) Cr (difference between red component and brightness) and YCgCb (blue Difference between color component and brightness) Skin color detection in color space.
  • the amount of calculation can be reduced, the cost of skin color detection can be reduced, and the noise point can be reduced.
  • the first calculation module 703 is configured to calculate an average value of the feature parameter values of the original skin color pixels.
  • the feature parameter value refers to the value of the parameter of the pixel, and may be, for example, a grayscale value, a chrominance value, or the like of the pixel.
  • the feature parameter values of the original skin color pixels may be one or more, and when there are multiple feature parameter values, the average value of each feature parameter value is calculated separately.
  • the first calculating module 703 acquires the feature parameter values of each original skin color pixel, and counts the number of the original skin color pixels, and then calculates the sum of the same feature parameter values of all the original skin color pixels, and calculates the sum and the original skin color pixels. The ratio of the number of the numbers, resulting in an average of the same characteristic parameter values for all of the original skin color pixels.
  • the correction module 704 is configured to correct the feature parameter values of each image pixel of the original image according to the difference between the preset standard average value and the calculated average value, and the standard average value is according to the preset standard image.
  • the characteristic parameter values of the standard skin color pixels are calculated.
  • the output module 705 is configured to output the corrected original image.
  • the skin color of the user is displayed in the standard image, and the image with normal exposure and brightness is relatively close to the natural condition, and the skin color in the standard image is the skin color closest to the natural skin color of the user.
  • the skin color of the original image is darker or brighter than the skin color of the standard image, and further Adjusting the original image according to the difference can make the skin color of the original image closer to the skin color of the standard image (that is, the user's natural skin color), so that the portrait image of the original image is more normal, avoiding overexposure or excessive darkness.
  • the whole image of the original image is adjusted, so that the brightness of the whole image is closer to the natural situation, the brightness of the light is more balanced, and the image is prevented from being overexposed or too dark, thereby improving the image quality.
  • the output module 705 is configured to output and display the corrected original image as a real-time image when the first acquisition module 701 acquires a real-time image acquired by a camera or other image acquisition device to obtain an original image.
  • the output module 705 is configured to output and save the corrected original image into the album.
  • the image processing apparatus further includes a first face detection module 801, a second acquisition module 802, a second skin color detection module 803, a second calculation module 804, and a second Face detection module 805.
  • the image pixels of the face region in the original image are selected for skin color detection.
  • the first face detection module 801 is configured to perform face detection on the original image acquired by the first acquisition module 701 to determine a face region of the original image before the first skin color detection module 702 performs skin color detection.
  • the first skin color detecting module 702 is specifically configured to perform skin color detection on image pixels in the face region of the original image to determine original skin color pixels in the original image. Wherein, when no human face is detected in the original image, the first skin color detecting module 702 performs skin color detection on the image pixels of the entire original image to determine the original skin color pixel of the original image.
  • the second obtaining module 802 is configured to acquire at least two standard images.
  • the standard image may be selected by the user, the user may select an image that is closer to the skin color of the user as the standard image, and the second obtaining module 707 obtains the standard image according to the user's selection.
  • the second face detection module 805 is configured to perform face detection on each standard image to determine a face area of the standard image.
  • the second skin color detecting module 803 is configured to perform skin color detection on the image pixels in the face region of each standard image to determine a standard skin color pixel of the standard image.
  • the second skin color detecting module 803 is configured to perform skin color detection on the entire standard image to determine a standard skin color pixel.
  • the second calculation module 804 is configured to calculate an average value of the feature parameter values of the standard skin color pixels of each standard image, and average the average values of the feature parameter values of the standard skin color pixels of all the standard images to obtain a standard average value.
  • the calculation process may be as follows: the second calculation module 804 acquires the feature parameter value of the standard skin color pixel of the standard image, and then counts the number of standard skin color pixels. And calculating the sum of the same feature parameter values of all standard skin color pixels, and then calculating the ratio of the sum to the number of standard skin color pixels, thereby obtaining an average of the same feature parameter values of all standard skin color pixels of each standard image.
  • the calculation process of the standard average value may be as follows: the second calculation module 804 counts the total number of standard images, and calculates the sum of the average values of the same feature parameter values of the standard skin color pixels of all standard images, and then calculates the sum and the standard image. The ratio of the totals, resulting in a standard average of the same characteristic parameter values for standard skin tone pixels.
  • the standard average value can be made closer to the natural skin color of the user, and thus, based on the standard average value, according to the characteristics of the original skin color pixel
  • the difference between the average of the parameter values and the standard average adjusts the original image to make the skin tone in the original image closer to the user's natural skin tone.
  • a standard image may also be selected to calculate a standard average value, in which the standard average is the average of the characteristic parameter values of the standard skin color pixels of the standard image.
  • the first face detection module 801 and the second face detection module 805 may be the same module or different modules, and the second acquisition module 802 and the first acquisition module 701 may be the same module or different modules.
  • the second skin color detecting module 803 and the first skin color detecting module 702 may be the same module or different modules, and the second calculating module 804 and the first calculating module 703 may be the same module or different modules.
  • the correction module 704 includes a first calculation unit 7041, an acquisition unit 7042, a second calculation unit 7043, and a correction unit 7044.
  • the first calculating unit 7041 is configured to calculate a difference between a preset standard average value and an average value of the feature parameter values of the original skin color pixel, where the difference specifically refers to a standard average value minus a characteristic parameter value of the original skin color pixel. The difference between the averages.
  • the obtaining unit 7042 is configured to acquire feature parameter values of each image pixel of the original image.
  • the second calculating unit 7043 is configured to calculate a correction coefficient of each image pixel according to an average value of the feature parameter values of the original skin color pixel and a feature parameter value of each image pixel. Specifically, the second calculating unit 7043 is configured to calculate an average value of the feature parameter value of the image pixel and the feature parameter value of the original skin color pixel when the feature parameter value of the image pixel is less than or equal to the average value of the feature parameter values of the original skin color pixel.
  • Ratio of the image thereby obtaining a correction coefficient of the image pixel; and for calculating the first between the preset constant and the characteristic parameter value of the image pixel when the feature parameter value of the image pixel is greater than the average value of the feature parameter value of the original skin color pixel a difference value, and calculating a second difference between the preset constant and an average value of the feature parameter values of the original skin color pixel, and a ratio of the first difference value to the second difference value, thereby obtaining a correction coefficient of the image pixel.
  • the correcting unit 7044 is configured to correct the feature parameter values of the image pixels of the original image according to the difference between the preset standard average value and the average value of the feature parameter values of the original skin color pixels, and the correction coefficient of the image pixels.
  • the feature parameter values of the image pixels of the original image are corrected according to the following formula:
  • C 1 represents a characteristic parameter value of the corrected image pixel
  • C 0 represents a characteristic parameter value of the image pixel before the correction, that is, a characteristic parameter value of the original image pixel acquired in step S302
  • ⁇ C The difference between the standard average of the corresponding feature parameter values representing the standard skin color pixels and the average of the corresponding feature parameter values of the original skin color pixels
  • k represents the correction coefficient of the image pixels.
  • the correction coefficient k is:
  • the correction coefficient k is:
  • n (nC 0 ) / (nC a ), where C 0 > C a , n is a preset constant (3).
  • the feature parameter value includes pixel values of three primary color components of red, green, and blue in the first color space, wherein the first color space is red, green, and blue RGB (Red (Red), Green (Green) ), Blue (blue)) color space.
  • the pixel value of each primary color component of the pixel ranges from 0 to 1.
  • the first calculating module 703 is specifically configured to obtain pixel values of three primary color components of the original skin color pixels in the original image, and calculate red, green, and blue colors of all the original skin color pixels in the original image. The average of the pixel values of the primary color components, thereby obtaining an average of the characteristic parameter values of the original skin color pixels.
  • the first calculating unit 7041 is configured to calculate a standard average value of the pixel values of the red, green, and blue primary color components of the standard skin color pixel in the preset standard image and an average value of the pixel values of the corresponding primary color components of the original skin color pixel in the original image. The difference between the two.
  • the obtaining unit 7042 is configured to obtain pixel values of three primary color components of red, green, and blue of each image pixel, to obtain feature parameter values of each image pixel.
  • the second calculating unit 7043 is configured to calculate the red color of each image pixel according to the average value of the pixel values of the three primary color components of the red, green, and blue color of the original skin color pixel, and the pixel values of the three primary color components of the red, green, and blue color of each image pixel. Correction coefficients for pixel values of the three primary color components of green, blue, and blue.
  • the correcting unit 7044 is configured to pre-equalize the average value of the pixel values of the corresponding primary color components of the original skin color pixels in the original image according to a standard average value of the pixel values of the red, green, and blue primary color components of the standard skin color pixel in the preset standard image.
  • the difference value, and the correction coefficient of the pixel values of the three primary color components of the red, green, and blue components of each image pixel correct the pixel values of the three primary color components of the red, green, and blue color of each image pixel.
  • the correcting unit 7044 corrects the pixel values of the three primary color components of the red, green, and blue color of each image pixel of the original image according to the above formula.
  • C 1 represents the pixel value of the red component of the corrected image pixel
  • C 0 represents the pixel value of the red component of the image pixel before correction
  • ⁇ C represents the standard skin color pixel.
  • k represents the correction factor for the image pixel.
  • the manner in which the pixel values of the green and blue components of the image pixel are corrected is thus derived. In the above manner, the pixel values of the respective primary color components corrected for each image pixel can be obtained, and the original image can be corrected.
  • the brightness of the corrected original image can be made closer to the natural situation, and the displayed skin color is closer to the natural skin color of the user. It is beneficial to reduce the phenomenon of excessive darkness or overexposure of images and improve image quality.
  • the feature parameter value includes a luminance value, a first chrominance value, and a second chrominance value on the second color space, wherein the second color space is YUV (Luminance, Chroma) Degree)) Color space, for convenience of description, the brightness value is represented by a Y value, the first chromaticity value is represented by a U value, and the second chromaticity value is represented by a V value.
  • the second color space is YUV (Luminance, Chroma) Degree)
  • the first calculating module 703 is configured to obtain pixel values of three primary color components of the original color skin pixels in the first color space in the original image, and according to the red color of each original skin color pixel in the original image. And the pixel values of the three primary color components of green, blue, calculate the luminance value, the first chrominance value, and the second chrominance value of each original skin color pixel in the second color space, and calculate an average value of the luminance values of all the original skin color pixels. The average of the first chrominance values and the average of the second chrominance values, thereby obtaining an average of the characteristic parameter values of the original skin color pixels.
  • the Y value, the U value, and the V value of each original skin color pixel in the YUV color space can be calculated according to the above formula 4.
  • the first calculating unit 7041 is configured to calculate a brightness value of the standard skin color pixel, a first chromaticity value, a standard average value of the second chromaticity value, and a corresponding brightness value, a first chromaticity value, and a second chromaticity value of the original skin color pixel. The difference between the averages.
  • the obtaining unit 7042 is configured to acquire a luminance value, a first chrominance value, and a second chrominance value of each image pixel of the original image, thereby obtaining feature parameter values of each image pixel of the original image.
  • the second calculating unit 7043 is configured to calculate an average value of the brightness values of the original skin color pixels, an average value of the first color value, and an average value of the second color value, and a brightness value, a first color value, and a color value of each image pixel.
  • the second chrominance value calculates a luminance coefficient of each image pixel, a first chrominance value, and a correction coefficient of the second chrominance value.
  • the correcting unit 7044 is configured to: according to the brightness value of the standard skin color pixel in the preset standard image, the first chromaticity value, the standard average value of the second chromaticity value, and the corresponding brightness value of the original skin color pixel in the original image, the first chromaticity value a difference between the average values of the second chrominance values, and a luminance value of each image pixel, a first chrominance value, and a correction coefficient of the second chrominance value, a luminance value for each image pixel, and a first chrominance The value and the second chrominance value are corrected.
  • the correcting unit 7044 corrects the Y value, the U value, and the V value of each image pixel of the pair of original images according to the above formula. Specifically, taking the value of Y as an example, in Equation 1, C 1 represents the Y value of the corrected image pixel, C 0 represents the Y value of the image pixel before correction, and ⁇ C represents the standard average value of the Y value of the standard skin color pixel. The difference from the average of the Y values of the original skin color pixels, k represents the correction coefficient of the image pixels. The way in which the U and V values of the image pixels are corrected is thus derived. In the above manner, the corrected Y value, U value, and V value of each image pixel can be obtained, and the original image can be corrected.
  • the output module 705 is specifically configured to calculate pixel values of the three primary color components of the red, green, and blue color of each image pixel according to the corrected Y value, U value, and V value of each image pixel, thereby obtaining the original RGB format. Image and output the original image in corrected RGB format.
  • the pixel values of the three primary color components of the red, green, and blue colors of the corrected image pixels may be calculated according to the above formula 5.
  • the image quality of the corrected original image can be further improved, so that the brightness of the corrected original image is closer to the natural situation.
  • the displayed skin tone is closer to the user's natural skin tone.
  • only the Y value of the image pixel may be corrected.
  • the main difference from the above embodiment is that the present embodiment only corrects the Y value of the image pixel, and does not correct the U value and the V value.
  • the U value and the V value are unchanged before and after the correction, and the specific correction manner is the same as the above embodiment. Similarly, I will not repeat them here.
  • the feature parameter value includes a tone value, a saturation value, and a brightness value in a third color space, wherein the third color space is HSV (Hue, Saturation, Value ( Lightness))
  • HSV Human, Saturation, Value ( Lightness)
  • the hue value is represented by the H value
  • the saturation value is represented by the S value
  • the brightness value is represented by the V value.
  • the first calculating module 703 is configured to obtain pixel values of three primary color components of the original color skin pixels in the first color space in the original image, and according to the red color of each original skin color pixel in the original image.
  • the pixel values of the three primary color components of green, blue, and blue calculate the hue value, the saturation value, and the brightness value of each original skin color pixel in the third color space, and calculate the average value and the saturation value of the hue values of all the original skin color pixels.
  • the average value and the average value of the brightness values are averaged to obtain the characteristic parameter values of the original skin color pixels.
  • the H value, the S value, and the V value of each original skin color pixel in the HSV color space may be calculated according to the above formulas 6, 7, and 8.
  • the first calculating unit 7041 is configured to calculate a tone value, a saturation value, a standard average value of the brightness value of the standard skin color pixel in the preset standard image, and an average value of the corresponding tone value, the saturation value, and the brightness value of the original skin color pixel in the original image. The difference between the values.
  • the obtaining unit 7042 is configured to acquire a tone value, a saturation value, and a brightness value of each image pixel of the original image to obtain a feature parameter value of each image pixel of the original image.
  • the second calculating unit 7043 is configured to calculate each image pixel according to an average value of the hue value of the original skin color pixel, an average value of the saturation value, and an average value of the brightness value, and a hue value, a saturation value, and a brightness value of each image pixel. The tonal value, the saturation value, and the correction factor for the brightness value.
  • the correcting unit 7044 is configured to: according to a standard average value of the hue value, the saturation value, and the brightness value of the standard skin color pixel in the preset standard image, and an average value of the corresponding hue value, the saturation value, and the brightness value of the original skin color pixel in the original image.
  • the difference between the image, the tone value of each image pixel, the saturation value, and the correction factor of the brightness value are corrected for the tone value, the saturation value, and the brightness value of each image pixel.
  • the H value, the S value, and the V value of each image pixel of the pair of original images can be corrected according to the above formula.
  • C 1 represents the H value of the corrected image pixel
  • C 0 represents the H value of the image pixel before the correction
  • ⁇ C represents the standard average value of the H value of the standard skin color pixel.
  • k represents the correction coefficient of the image pixels.
  • the way to correct the S and V values of the image pixels is thus derived. In the above manner, the corrected H value, S value, and V value of each image pixel can be obtained, and the original image can be corrected.
  • the output module 705 is specifically configured to calculate pixel values of the three primary color components of the red, green, and blue color of each image pixel according to the corrected H value, S value, and V value of each image pixel, thereby obtaining the original RGB format. Image and output the original image in corrected RGB format.
  • the pixel values of the three primary color components of the red, green and blue of each corrected image pixel can be calculated according to the above formulas IX and IX.
  • the image quality of the corrected original image can be further improved, so that the brightness of the corrected original image is closer to the natural condition.
  • the displayed skin tone is closer to the user's natural skin tone.
  • the embodiment of the present invention further provides a terminal.
  • the terminal may include a radio frequency (RF) circuit 901, a memory 902 including one or more computer readable storage media, an input unit 903, and a display.
  • unit 904 a sensor 905, an audio circuit 906, wireless fidelity (WiFi, W ireless fidelity) module 907, a processor comprises one or more processing cores 908, 909 and a power supply and other components.
  • RF radio frequency
  • a memory 902 including one or more computer readable storage media
  • an input unit 903 and a display.
  • unit 904 a sensor 905
  • an audio circuit 906 wireless fidelity (WiFi, W ireless fidelity) module 907
  • a processor comprises one or more processing cores 908, 909 and a power supply and other components.
  • FIG. 9 does not constitute a limitation to the terminal, and may include more or less components than those illustrated, or combine some components, or different component arrangements. among them:
  • the RF circuit 901 includes, but is not limited to, an antenna, at least one amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM), a transceiver, a coupler, and a low noise amplifier (LNA, Low Noise). Amplifier), duplexer, etc.
  • the RF circuit 901 can also communicate with the network and other devices through wireless communication.
  • the wireless communication may use any communication standard or protocol, including but not limited to Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), and Code Division Multiple Access (CDMA). , Code Division Multiple Access), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), e-mail, Short Messaging Service (SMS), and the like.
  • GSM Global System of Mobile communication
  • GPRS General Packet Radio Service
  • CDMA Code Division Multiple Access
  • WCDMA Wideband Code Division Multiple Access
  • LTE Long Term Evolution
  • SMS Short Messaging Service
  • the memory 902 can be used to store software programs and modules, such as computer readable instructions.
  • the processor 908 executes various functional applications and data processing by executing software programs and modules stored in the memory 902, for example, the above-described FIGS. 1b, 1c can be performed.
  • the memory 902 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may be stored according to Data created by the use of the terminal (such as audio data, phone book, etc.).
  • memory 902 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, memory 902 may also include a memory controller to provide access to memory 902 by processor 908 and input unit 903.
  • Input unit 903 can be used to receive input numeric or character information, as well as to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
  • input unit 903 can include a touch-sensitive surface as well as other input devices.
  • Touch-sensitive surfaces also known as touch screens or trackpads, collect touch operations on or near the user (such as the user using a finger, stylus, etc., any suitable object or accessory on a touch-sensitive surface or touch-sensitive Operation near the surface), and drive the corresponding connecting device according to a preset program.
  • the touch sensitive surface can include both portions of the touch detection device and the touch controller.
  • the touch detection device detects the touch orientation of the user, and detects a signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts the touch information into contact coordinates, and sends the touch information.
  • the processor 908 is provided and can receive commands from the processor 908 and execute them.
  • touch-sensitive surfaces can be implemented in a variety of types, including resistive, capacitive, infrared, and surface acoustic waves.
  • the input unit 903 can also include other input devices. Specifically, other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.), trackballs, mice, joysticks, and the like.
  • Display unit 904 can be used to display information entered by the user or information provided to the user, as well as various graphical user interfaces of the terminal, which can be composed of graphics, text, icons, video, and any combination thereof.
  • the display unit 904 can include a display panel.
  • the display panel can be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like.
  • the touch-sensitive surface can cover the display panel, and when the touch-sensitive surface detects a touch operation thereon or nearby, it is transmitted to the processor 908 to determine the type of the touch event, and then the processor 908 displays the type according to the type of the touch event. A corresponding visual output is provided on the panel.
  • the touch-sensitive surface and display panel are implemented as two separate components to implement input and input functions, in some embodiments, the touch-sensitive surface can be integrated with the display panel to implement input and output functions.
  • the terminal may also include at least one type of sensor 905, such as a light sensor, a motion sensor, and other sensors.
  • the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel according to the brightness of the ambient light, and the proximity sensor may close the display panel and/or the backlight when the terminal moves to the ear.
  • the gravity acceleration sensor can detect the magnitude of acceleration in all directions (usually three axes). When it is stationary, it can detect the magnitude and direction of gravity.
  • the terminal can also be configured with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors, no longer Narration.
  • the audio circuit 906, the speaker, and the microphone provide an audio interface between the user and the terminal.
  • the audio circuit 906 can transmit the converted electrical signal of the audio data to the speaker, and convert it into a sound signal output by the speaker; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 906 and then converted.
  • the audio data output processor 908 After the audio data is processed by the audio data output processor 908, it is sent to, for example, another terminal via the RF circuit 901, or the audio data is output to the memory 902 for further processing.
  • the audio circuit 906 may also include an earbud jack to provide communication between the peripheral earphone and the terminal.
  • WiFi is a short-range wireless transmission technology
  • terminal through WiFi module 907 can help users send and receive email, browse the web and access streaming media and so on, which provides wireless broadband Internet access for users.
  • FIG. 9 shows the WiFi module 907, it can be understood that it does not belong to the necessary configuration of the terminal, and may be omitted as needed within the scope of not changing the essence of the invention.
  • the processor 908 is the control center of the terminal, which connects various portions of the entire handset using various interfaces and lines, by executing or executing software programs and/or modules stored in the memory 902, and invoking data stored in the memory 902, executing Various functions of the terminal and processing data.
  • processor 908 can include one or more processing cores; preferably, processor 908 can integrate an application processor and a modem processor, wherein the application processor primarily processes an operating system, a user interface, and an application Etc.
  • the modem processor primarily handles wireless communications. It will be appreciated that the above described modem processor may also not be integrated into the processor 908.
  • the terminal also includes a power supply 909 (such as a battery) that supplies power to the various components.
  • the power supply 909 can be logically coupled to the processor 908 through a power management system to manage functions such as charging, discharging, and power management through the power management system.
  • the power supply 909 may also include any one or more of a DC or AC power source, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
  • the terminal may further include a camera, a Bluetooth module, and the like, and details are not described herein again.
  • the processor 908 in the terminal loads the executable file corresponding to the process of one or more applications into the memory 902 according to the following instructions, and is executed by the processor 908 to be stored in the memory.
  • the application in 902 to implement various functions:
  • the original image is the image to be processed.
  • the obtained original image may be various.
  • acquiring the original image may include: acquiring a picture acquired by a camera or other image capturing device in real time to obtain an original image; or acquiring a picture selected by the user to obtain an original image or the like.
  • the feature pixel may include: a skin color pixel, that is, a human skin pixel.
  • the skin color detection of the image pixels of the original image is specifically: skin color detection is performed on image pixels in the face region of the original image to determine original skin color pixels in the original image.
  • skin color detection is performed on the image pixels of the entire original image to determine the original skin color pixel of the original image.
  • the average of the characteristic parameter values of the feature pixels is calculated.
  • Correcting a characteristic parameter value of each image pixel of the original image according to a difference between the preset standard average value and the characteristic parameter value, and the preset standard average value includes: according to a standard pixel in the preset standard image The characteristic parameter values are calculated.
  • the difference between the preset standard average value and the average value of the feature parameter values of the original skin color pixels is first calculated.
  • the difference specifically refers to the difference between the standard average value minus the average value of the characteristic parameter values of the original skin color pixels.
  • the correction coefficient of each image pixel is calculated according to the above formulas 2 and 3, and the characteristic parameter values of each image pixel of the original image are calculated according to the formula.
  • the corrected original image is output.
  • the embodiments of the present application provide a non-transitory computer readable storage medium storing computer readable instructions that cause at least one processor to perform the operations in the methods and/or apparatus described above.
  • the program may be stored in a computer readable storage medium, and the storage medium may include: Read Only Memory (ROM), Random Access Memory (RAM), disk or optical disk.
  • ROM Read Only Memory
  • RAM Random Access Memory

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Image Processing (AREA)

Abstract

Disclosed in embodiments of the present invention are an image processing method and device. The method comprises: obtaining an original image; performing skin color detection on image pixels in a selected area of the original image to determine characteristic pixels in the selected area of the original image; calculating an average value of characteristic parameter values of the characteristic pixels; correcting a characteristic parameter value of each image pixel of the original image according to a difference value of a preset standard average value and the average value of the characteristic parameter values, the preset standard average value being a numerical value obtained by calculating according to characteristic parameter values of standard characteristic pixels of a preset standard image; and outputting the corrected original image.

Description

图像处理方法、装置及存储介质Image processing method, device and storage medium
本申请要求于2017年03月21日提交中国专利局、申请号为201710171010.5、发明名称为“一种图像处理方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. 200910171010.5, the entire disclosure of which is incorporated herein by reference. .
技术领域Technical field
本发明涉及图像处理技术领域,具体涉及一种图像的处理方法、装置及存储介质。The present invention relates to the field of image processing technologies, and in particular, to a method, an apparatus, and a storage medium for processing an image.
背景background
随着社交媒体的不断发展,照片正逐渐取代文字,成为用户记录生活点滴的主要内容方式,其中,又以自拍生活照居多。如今的大部分手机、平板电脑等终端设备都设置有前置摄像头,让自拍变得更加方便,随时随地都能自拍。现有的摄像技术在对照片进行处理时,一般都会根据环境光线自动对光圈进行调节,从而得到与当前环境光线匹配的曝光度。With the continuous development of social media, photos are gradually replacing text, becoming the main content way for users to record their lives. Among them, self-portrait life is more. Most of today's mobile phones, tablets and other terminal devices are equipped with a front camera, making self-timer more convenient and self-timer anytime, anywhere. When the existing camera technology processes the photos, the aperture is automatically adjusted according to the ambient light to obtain the exposure that matches the current ambient light.
技术内容Technical content
本发明实施例提供了一种图像处理方法及装置,能够降低图像过曝或过暗的几率,可以使得图像中的肤色更接近用户的自然真实肤色,提高图像质量。Embodiments of the present invention provide an image processing method and apparatus, which can reduce the probability of an image being overexposed or too dark, and can make the skin color in the image closer to the natural skin color of the user and improve the image quality.
本发明实施例提供一种图像处理方法,包括:An embodiment of the present invention provides an image processing method, including:
获取原始图像;Get the original image;
对所述原始图像中选定区域的图像像素进行特征检测,以确定所述原始图像中所述选定区域的特征像素;Performing feature detection on image pixels of selected regions in the original image to determine feature pixels of the selected region in the original image;
计算所述特征像素的特征参数值的平均值;Calculating an average value of characteristic parameter values of the feature pixels;
根据预设标准平均值与所述特征参数值的平均值之间的差值,对所述原始图像的各图像像素的特征参数值进行校正,所述预设标准平均值包括根据预设标准图像的标准特征像素的特征参数值计算得到的数值;Correcting a feature parameter value of each image pixel of the original image according to a difference between a preset standard average value and an average value of the feature parameter values, the preset standard average value including an image according to a preset standard The value of the characteristic parameter value of the standard feature pixel;
输出校正后的原始图像。The corrected original image is output.
本发明实施例还提供了一种图像处理装置,所述装置包括处理器和存储器,所述存储器存储有计算机可读指令,可以使所述处理器:An embodiment of the present invention further provides an image processing apparatus, the apparatus comprising a processor and a memory, the memory storing computer readable instructions, wherein the processor is:
获取原始图像;Get the original image;
对所述原始图像中选定区域的图像像素进行特征检测,以确定所述原始图像中所述选定区域的特征像素;Performing feature detection on image pixels of selected regions in the original image to determine feature pixels of the selected region in the original image;
计算所述特征像素的特征参数值的平均值;Calculating an average value of characteristic parameter values of the feature pixels;
根据预设标准平均值与所述特征参数值的平均值之间的差值,对所述原始图像的各图像像素的特征参数值进行校正,所述预设标准平均值包括根据预设标准图像的标准特征像素的特征参数值计算得到的数值;Correcting a feature parameter value of each image pixel of the original image according to a difference between a preset standard average value and an average value of the feature parameter values, the preset standard average value including an image according to a preset standard The value of the characteristic parameter value of the standard feature pixel;
输出模块,用于输出校正后的原始图像。An output module for outputting the corrected original image.
本申请实施例还提供了一种计算机可读存储介质,存储有计算机可读指令,可以使处理器执行各实施例的方法。The embodiment of the present application further provides a computer readable storage medium storing computer readable instructions, which may cause a processor to execute the methods of the embodiments.
附图简要说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the present invention. Other drawings can also be obtained from those skilled in the art based on these drawings without paying any creative effort.
图1a是本发明一实施例提供的图像处理方法的框架图;FIG. 1 is a schematic diagram of an image processing method according to an embodiment of the present invention; FIG.
图1b是本发明一实施例提供的图像处理方法的流程图;FIG. 1b is a flowchart of an image processing method according to an embodiment of the present invention;
图1c是本发明另一实施例提供的图像处理方法的流程图;1c is a flowchart of an image processing method according to another embodiment of the present invention;
图1d是本发明一实施例提供的图像处理方法中,肤色检测示意图;FIG. 1 is a schematic diagram of skin color detection in an image processing method according to an embodiment of the invention; FIG.
图2a是本发明一实施例提供的图像处理方法中,对原始图像的各图像像素的特征参数值进行校正之前的流程图;FIG. 2 is a flowchart of a method for correcting characteristic parameter values of image pixels of an original image in an image processing method according to an embodiment of the present invention; FIG.
图2b是本发明一实施例提供的图像处理方法中,获取标准平均值的框架图;2b is a frame diagram of obtaining a standard average value in an image processing method according to an embodiment of the present invention;
图3是本发明一实施例提供的图像处理方法中,对原始图像的各图像像素的特征参数值进行校正的流程图;FIG. 3 is a flowchart of correcting feature parameter values of each image pixel of an original image in an image processing method according to an embodiment of the present invention; FIG.
图4是本发明另一实施例提供的图像处理方法的流程图;4 is a flowchart of an image processing method according to another embodiment of the present invention;
图5是本发明又一实施例提供的图像处理方法的流程图;FIG. 5 is a flowchart of an image processing method according to another embodiment of the present invention; FIG.
图6是本发明又一实施例提供的图像处理方法的流程图;6 is a flowchart of an image processing method according to still another embodiment of the present invention;
图7是本发明一实施例提供的图像处理装置的结构示意图;FIG. 7 is a schematic structural diagram of an image processing apparatus according to an embodiment of the present invention; FIG.
图8是本发明另一实施例提供的图像处理装置的结构示意图;FIG. 8 is a schematic structural diagram of an image processing apparatus according to another embodiment of the present invention; FIG.
图9是本发明一实施例提供的终端的结构示意图。FIG. 9 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
实施方式Implementation
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, but not all embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
本发明实施例提供一种图像处理方法和处理装置。Embodiments of the present invention provide an image processing method and a processing device.
其中,图像处理装置具体可以集成在终端中,终端例如可以是智能 手机、平板电脑、个人计算机等。The image processing device may be specifically integrated in the terminal, and the terminal may be, for example, a smart phone, a tablet computer, a personal computer, or the like.
例如,如图1a所示,该图像处理装置可以获取原始图像,例如可以是获取摄像头或其他图像采集设备获取的实时画面,也可以是获取用户所选择的图片,或者是接收其他设备发送的图片等,然后对原始图像的图像像素进行肤色检测,以确定原始图像中的原始肤色像素,例如可以通过肤色统计模型进行肤色检测,如RGB色彩空间肤色统计,或者通过阈值分割方式进行肤色检测,等等,通过计算原始肤色像素的特征参数值的平均值,并根据预设标准平均值与计算得到的平均值之间的差值,对原始图像的各图像像素的特征参数值进行校正,从而输出校正后的原始图像。For example, as shown in FIG. 1a, the image processing apparatus may acquire an original image, for example, may acquire a real-time image acquired by a camera or other image capturing device, or may acquire a picture selected by the user, or receive a picture sent by another device. Etc., then perform skin color detection on the image pixels of the original image to determine the original skin color pixels in the original image, for example, skin color detection by skin color statistical model, such as RGB color space skin color statistics, or skin color detection by threshold segmentation, etc. Etc., by calculating an average value of the characteristic parameter values of the original skin color pixels, and correcting the characteristic parameter values of the image pixels of the original image according to the difference between the preset standard average value and the calculated average value, thereby outputting The corrected original image.
因此,本发明实施例是基于肤色对原始图像进行优化处理,即以预设的标准图像为参考,通过对原始图像的肤色像素的特征参数值与预设的标准图像的肤色像素的特征参数值做对比,根据对比结果可以判断原始图像的曝光情况,以对原始图像进行校正,使得原始图像的肤色更接近标准图像的肤色,从而使得原始图像的光照更接近自然情况,在一定程度上可以避免图像过曝或过暗的现象,有利于提高照片质量。Therefore, in the embodiment of the present invention, the original image is optimized based on the skin color, that is, the feature parameter value of the skin color pixel of the original image and the feature parameter value of the skin color pixel of the preset standard image are referenced by the preset standard image. For comparison, according to the comparison result, the exposure of the original image can be judged to correct the original image, so that the skin color of the original image is closer to the skin color of the standard image, so that the illumination of the original image is closer to the natural situation, and can be avoided to a certain extent. The phenomenon that the image is overexposed or too dark is conducive to improving the quality of the photo.
参阅图1b,图1b是本发明图像处理方法一实施例的流程图。如图所示,图像处理方法包括以下步骤:Referring to FIG. 1b, FIG. 1b is a flow chart of an embodiment of an image processing method of the present invention. As shown, the image processing method includes the following steps:
步骤101b:获取原始图像。Step 101b: Acquire an original image.
其中,所述获取原始图像可以为摄像头或其他图像采集设备实时获取的画面,或者获取用户在终端设备(如手机等)中的相册中选择的照片,或者在终端设备(如手机等)中的客户端(如微信、QQ等)中接收其他用户发送的图片等。The acquiring the original image may be a picture acquired by a camera or other image capturing device in real time, or acquiring a photo selected by a user in an album in a terminal device (such as a mobile phone, etc.), or in a terminal device (such as a mobile phone, etc.) The client (such as WeChat, QQ, etc.) receives pictures sent by other users.
这里,所述原始图像可以为人物图像、风景图像及动物图像等等。Here, the original image may be a person image, a landscape image, an animal image, or the like.
步骤102b:对所述原始图像中选定区域的图像像素进行特征检测, 以确定所述原始图像中所述选定区域的特征像素。Step 102b: Perform feature detection on image pixels of the selected area in the original image to determine feature pixels of the selected area in the original image.
在本申请一实施例中,该原始图像中的选定区域可以为多个区域。相应地,选定区域的特征像素可以为这多个区域的特征像素。In an embodiment of the present application, the selected area in the original image may be a plurality of areas. Correspondingly, the feature pixels of the selected area may be the feature pixels of the plurality of areas.
其中,当所述原始图像为人物图像时,所述选定区域可以为人脸区域、整张图像或者原始图像中其他包含人体皮肤像素的区域。当所述原始图像为风景图像、动物图像等时,所述选定区域可以为整张图像,也可以为该图像中的某个目标物体所占的区域。Wherein, when the original image is a character image, the selected area may be a face area, an entire image, or other areas of the original image that include human skin pixels. When the original image is a landscape image, an animal image, or the like, the selected area may be an entire image, or may be an area occupied by a certain target object in the image.
这里,当所述原始图像为人物图像时,所述对原始图像中选定区域的图像像素进行特征检测为对原始图像中选定区域的图像进行肤色检测,肤色检测的方式可以有多种,例如建立肤色统计模型进行肤色检测,从而确定原始图像中选定区域(例如人脸区域)的所有肤色像素。Here, when the original image is a person image, the image pixels of the selected area in the original image are subjected to feature detection to detect the skin color of the image of the selected area in the original image, and the skin color detection manner may be various. For example, a skin color statistical model is established for skin color detection to determine all skin color pixels of a selected region (eg, a face region) in the original image.
这里,当所述原始图像为风景图像或动物图像等时,所述对原始图像中选定区域的图像像素进行特征检测为对原始图像进行目标检测,所述目标检测的方式有多种,例如RCNN算法(Region Convolutional Neural Network,区域卷积神经网络)、Fast-RCNN算法、Faster-RCNN算法及Mask RCNN算法等,通过所述目标检测可以确定所述原始图像中的目标(如动物、树、城堡等),从而确定所述目标的主体颜色(当所述原始图像中具有多个目标时,选取主体目标的主体颜色,所述主体目标例如为图像中最大的目标),例如,树干的颜色、城堡墙体的颜色等。Here, when the original image is a landscape image or an animal image or the like, the image pixels of the selected area in the original image are subjected to feature detection to perform target detection on the original image, and the target detection manner is various, for example, RCNN algorithm (Region Convolutional Neural Network), Fast-RCNN algorithm, Faster-RCNN algorithm, Mask RCNN algorithm, etc., through the target detection, the target in the original image (such as animal, tree, Castle, etc., thereby determining the subject color of the target (when there are multiple targets in the original image, selecting the subject color of the subject target, such as the largest target in the image), for example, the color of the trunk The color of the castle wall, etc.
步骤103b:计算所述特征像素的特征参数值的平均值。Step 103b: Calculate an average value of the feature parameter values of the feature pixels.
这里,当所述原始图像为人物图像时,例如通过步骤102B中确定了人脸区域中的所有肤色像素,则计算所有肤色像素的特征参数值的平均值。Here, when the original image is a person image, for example, by determining all the skin color pixels in the face region in step 102B, the average value of the feature parameter values of all skin color pixels is calculated.
这里,当所述原始图像为风景图像时,通过步骤102B确定了风景图像中的树,并确定了树干的颜色,则计算所有树干颜色的特征参数值 的平均值。Here, when the original image is a landscape image, the tree in the landscape image is determined by step 102B, and the color of the trunk is determined, and the average value of the feature parameter values of all trunk colors is calculated.
步骤104b:根据预设标准平均值与所述特征参数值的平均值之间的差值,对所述原始图像的各图像像素的特征参数值进行校正,所述预设标准平均值包括根据预设标准图像的标准特征像素的特征参数值计算得到的数值。Step 104b: correcting, according to a difference between a preset standard average value and an average value of the feature parameter values, a feature parameter value of each image pixel of the original image, where the preset standard average value includes The value calculated from the characteristic parameter values of the standard feature pixels of the standard image.
步骤105b:输出校正后的原始图像。Step 105b: Output the corrected original image.
通过上述技术方案,可以使得原始图像中的目标(人物、树木、城堡、动物等)更接近其自然色,从而使得原始图像中的目标显示更真实,避免过曝或过暗的现象。利用本申请的技术方案,通过对所述原始图像中选定区域的图像像素进行特征检测,得到该选定区域的特征像素,计算所述特征像素的特征参数值的平均值,根据预设标准平均值与计算得到的平均值之间的差值,对所述原始图像的各图像像素的特征参数值进行校正。因此,可以利用本申请的技术方案,可以根据原始图像中的局部选定区域的特征像素进行计算和校正原始图像。与现有技术中采用模板中统一的滤镜、卡通贴纸,以及整体亮度均衡化技术等对所有原始图像进行模板化的校正技术相比,本申请可以提高原始图像的校正精度。Through the above technical solution, the target (person, tree, castle, animal, etc.) in the original image can be made closer to its natural color, so that the target display in the original image is more realistic, and the phenomenon of overexposure or overdark is avoided. Using the technical solution of the present application, the feature pixels of the selected area are obtained by performing feature detection on the image pixels of the selected area in the original image, and the average value of the characteristic parameter values of the feature pixel is calculated according to a preset standard. The difference between the average value and the calculated average value is corrected for the characteristic parameter values of the image pixels of the original image. Therefore, with the technical solution of the present application, the original image can be calculated and corrected according to the feature pixels of the locally selected region in the original image. Compared with the prior art, which uses a uniform filter in the template, a cartoon sticker, and an overall brightness equalization technique to correct all the original images, the present application can improve the correction accuracy of the original image.
下面以所述特征检测为肤色检测进行说明,参阅图1c,图1c是本发明图像处理方法一实施例的流程图。如图所示,图像处理方法包括以下步骤:Hereinafter, the detection of the skin color by the feature detection will be described. Referring to FIG. 1c, FIG. 1c is a flowchart of an embodiment of the image processing method of the present invention. As shown, the image processing method includes the following steps:
步骤S101c:获取原始图像。Step S101c: Acquire an original image.
原始图像为待处理的图像。获取的原始图像可以有多种,例如,获取原始图像具体可以包括:获取摄像头或其他图像采集设备实时获取的画面,以获取原始图像;或者,获取用户所选择的图片,以获取原始图像;又或者,接收终端设备发送的图片,以获取原始图像,等等。The original image is the image to be processed. The obtained original image may be various. For example, acquiring the original image may include: acquiring a picture acquired by a camera or other image capturing device in real time to obtain an original image; or acquiring a picture selected by the user to obtain an original image; Or, receiving a picture sent by the terminal device to obtain an original image, and the like.
步骤S102c:对原始图像中选定区域的图像像素进行肤色检测,以 确定原始图像中所述选定区域的原始肤色像素。Step S102c: Perform skin color detection on image pixels of the selected area in the original image to determine original skin color pixels of the selected area in the original image.
肤色像素即人体皮肤像素。本实施例中,所述选定区域为人脸区域,选取原始图像中的人脸区域的图像像素进行肤色检测。具体地,在步骤S102c之前,进行如下步骤:对原始图像进行人脸检测,以确定原始图像的人脸区域。当确定原始图像的人脸区域后,对原始图像的图像像素进行肤色检测具体为:对原始图像的人脸区域内的图像像素进行肤色检测,以确定原始图像中的原始肤色像素。当在原始图像中未检测到人脸时,则对整张原始图像的图像像素进行肤色检测,以确定原始图像的原始肤色像素。The skin color pixel is the human skin pixel. In this embodiment, the selected area is a face area, and image pixels of the face area in the original image are selected for skin color detection. Specifically, before step S102c, the following steps are performed: face detection is performed on the original image to determine a face region of the original image. After determining the face region of the original image, performing skin color detection on the image pixels of the original image is specifically: performing skin color detection on the image pixels in the face region of the original image to determine original skin color pixels in the original image. When a human face is not detected in the original image, skin color detection is performed on the image pixels of the entire original image to determine the original skin color pixel of the original image.
其中,人脸检测的方式有多种,例如有基于传统知识的方法、基于几何特征的方法等等,可以采用其中的一种或几种方法的结合进行人脸检测。具体的,例如可以为iOS、Android等终端系统自带的人脸检测功能,在所述图像处理装置获取摄像头或其他图像采集设备实时获取的画面时,采用上述人脸检测功能检测人脸;以及OpenCV(Open Source Computer Vision Library,开源计算机视觉库)、腾讯优图等软件提供的人脸检测算法,在所述图像处理装置获取用户所选择的图片或接收终端设备发送的图片时,采用上述软件提供的人脸检测算法检测人脸。其中,当原始图像是根据用户的选择获取的,则人脸区域还可以由用户主动标记,具体而言,用户在选择原始图像时,可以对原始图像中的人脸进行标记,从而根据用户标记的区域确定原始图像中的人脸区域。肤色像素的检测方式也可以有多种,例如可以通过建立肤色统计模型进行肤色检测,比如基于Y(亮度)Cg(绿色分量与亮度的差)Cr(红色分量与亮度的差)与YCgCb(蓝色分量与亮度的差)颜色空间的肤色检测。Among them, there are various ways of face detection, such as a method based on traditional knowledge, a method based on geometric features, and the like, and a combination of one or several methods may be used for face detection. Specifically, for example, a face detection function provided by a terminal system such as iOS or Android may be used to detect a face by using the face detection function when the image processing apparatus acquires a picture acquired by a camera or other image acquisition device in real time; A face detection algorithm provided by software such as OpenCV (Open Source Computer Vision Library) and Tencent Excellent Picture. The above software is used when the image processing apparatus acquires a picture selected by a user or receives a picture transmitted by a terminal device. The provided face detection algorithm detects the face. Wherein, when the original image is obtained according to the user's selection, the face region may also be actively marked by the user. Specifically, when the user selects the original image, the face in the original image may be marked, thereby marking according to the user The area determines the face area in the original image. There are many ways to detect skin color pixels. For example, skin color detection can be performed by establishing a skin color statistical model, such as based on Y (brightness) Cg (difference between green component and brightness) Cr (difference between red component and brightness) and YCgCb (blue Difference between color component and brightness) Skin color detection in color space.
例如,如图1d所示,对原始图像10a进行人脸检测,从而确定原始图像10a中的人脸区域11。通过对人脸区域11进行肤色检测,得到肤 色检测结果10b,其中在肤色检测结果10b中白色区域代表肤色区域,黑色区域代表非肤色区域。For example, as shown in FIG. 1d, face detection is performed on the original image 10a, thereby determining the face region 11 in the original image 10a. The skin color detection result 10b is obtained by performing skin color detection on the face area 11, wherein the white area represents the skin color area and the black area represents the non-skin color area in the skin color detection result 10b.
本实施例通过针对人脸区域进行肤色检测,相较于全图区域的肤色检测而言,可以减少运算量,降低肤色检测成本,且有利于减少噪声点。In this embodiment, by detecting the skin color for the face region, the amount of calculation can be reduced, the cost of skin color detection can be reduced, and the noise point can be reduced, compared to the skin color detection of the full image region.
步骤S103c:计算原始肤色像素的特征参数值的平均值。Step S103c: Calculate an average value of the feature parameter values of the original skin color pixels.
特征参数值指像素的参数的取值,例如可以是像素的灰阶值、色度值等。原始肤色像素的特征参数值可以是一个也可以是多个,有多个特征参数值时,分别计算每个特征参数值的平均值。其中,对于某个特征参数值的平均值的计算过程,具体可以包括:获取每个原始肤色像素的特征参数值;统计原始肤色像素的个数;计算所有原始肤色像素的同一特征参数值的总和;计算该总和与原始肤色像素的个数的比值,从而得到所有原始肤色像素的同一特征参数值的平均值。The feature parameter value refers to the value of the parameter of the pixel, and may be, for example, a grayscale value, a chrominance value, or the like of the pixel. The feature parameter values of the original skin color pixels may be one or more, and when there are multiple feature parameter values, the average value of each feature parameter value is calculated separately. The calculating process of the average value of a certain feature parameter value may specifically include: acquiring feature parameter values of each original skin color pixel; counting the number of original skin color pixels; and calculating a sum of the same feature parameter values of all the original skin color pixels. Calculating the ratio of the sum to the number of original skin color pixels, thereby obtaining an average of the same feature parameter values of all the original skin color pixels.
步骤S104c:根据预设标准平均值和所述特征参数的平均值之间的差值,对原始图像的各图像像素的特征参数值进行校正,预设标准平均值为根据预设标准图像中的标准肤色像素的特征参数值计算得到。Step S104c: correcting the feature parameter values of each image pixel of the original image according to the difference between the preset standard average value and the average value of the feature parameters, and the preset standard average value is according to the preset standard image. The characteristic parameter values of the standard skin color pixels are calculated.
步骤S105c:输出校正后的原始图像。Step S105c: Output the corrected original image.
其中,标准图像中显示有用户的肤色,为曝光正常、明暗程度较为接近自然情况的图像,将标准图像中的肤色作为与用户的自然肤色最相近的肤色。本实施例中,根据预设标准平均值与原始肤色像素的特征参数值的平均值之间的差值,可以判断出原始图像的肤色相较于标准图像的肤色是偏暗或偏亮,进而根据该差值对原始图像进行调整,可以使得原始图像的肤色更接近标准图像的肤色(也即用户的自然肤色),从而使得原始图像的人像显示更为正常,避免过曝或过暗的现象。并且,基于对原始图像的肤色检测分析,对原始图像的全图进行调整,可以使得整张图像明暗程度更接近自然情况,光线亮度更加均衡,避免图像过曝 或过暗,提高图像质量。Among them, the skin color of the user is displayed in the standard image, and the image with normal exposure and brightness is relatively close to the natural condition, and the skin color in the standard image is the skin color closest to the natural skin color of the user. In this embodiment, according to the difference between the preset standard average value and the average value of the feature parameter values of the original skin color pixel, it can be determined that the skin color of the original image is darker or brighter than the skin color of the standard image, and further Adjusting the original image according to the difference can make the skin color of the original image closer to the skin color of the standard image (that is, the user's natural skin color), so that the portrait image of the original image is more normal, avoiding overexposure or excessive darkness. . Moreover, based on the skin color detection analysis of the original image, the whole image of the original image is adjusted, so that the brightness of the whole image is closer to the natural situation, the brightness of the light is more balanced, and the image is prevented from being overexposed or too dark, thereby improving the image quality.
其中,当原始图像是由摄像头等图像采集设备获取的实时画面,在步骤S105c中,将校正后的原始图像作为实时画面输出并显示。具体的,例如,当用户使用终端中的相机进行拍照(例如自拍)时,终端中的上述图像处理装置自动对原始图像进行调整,使得用户看到的实时画面已经是经过调整后的图像,从而使得用户拍出的照片效果更好。此种情形下,用户是无感知的,从而进一步提升用户的体验效果。当原始图像为用户所选择的图像,例如为用户在相册中选择的图像,则在步骤S105c中,将校正后的原始图像输出并保存至相册中。具体的,例如,用户选择终端中的相册中的一张图像,终端中的上述图像处理装置对该图像进行调整,从而使得该图像的呈现效果更好。此种情形下,用户能够明显感知图像调整前后的区别。Wherein, when the original image is a real-time image acquired by an image capturing device such as a camera, in step S105c, the corrected original image is output and displayed as a real-time image. Specifically, for example, when the user performs photographing (for example, self-photographing) using a camera in the terminal, the image processing apparatus in the terminal automatically adjusts the original image so that the real-time screen seen by the user is already the adjusted image, thereby Make the photos taken by users better. In this case, the user is non-perceived, thereby further enhancing the user experience. When the original image is an image selected by the user, for example, an image selected by the user in the album, the corrected original image is output and saved in the album in step S105c. Specifically, for example, the user selects one image in the album in the terminal, and the image processing device in the terminal adjusts the image, so that the image is rendered better. In this case, the user can clearly perceive the difference before and after the image adjustment.
本实施例中,还包括计算标准平均值的步骤,具体地,参阅图2a,并结合图2b,在根据计算得到的平均值与预设标准值之间的差值,对原始图像的各图像像素的特征参数值进行校正之前,还包括以下步骤:In this embodiment, the method further includes the step of calculating a standard average value. Specifically, referring to FIG. 2a, and in combination with FIG. 2b, each image of the original image is obtained according to a difference between the calculated average value and the preset standard value. Before the pixel's characteristic parameter values are corrected, the following steps are also included:
步骤S201:获取至少两个标准图像。Step S201: Acquire at least two standard images.
其中,标准图像可以由用户进行选择,用户可选择较为接近自身肤色的图像作为标准图像,根据用户的选择获取标准图像。The standard image can be selected by the user, and the user can select an image that is closer to the skin color of the user as a standard image, and obtain a standard image according to the user's selection.
步骤S202:对每个标准图像的图像像素进行肤色检测,以确定标准图像的标准肤色像素。Step S202: Perform skin color detection on image pixels of each standard image to determine standard skin color pixels of the standard image.
本实施例中,在步骤S202之前,还包括:对每个标准图像进行人脸检测,以确定标准图像的人脸区域。步骤S202中,对每个标准图像的图像像素进行肤色检测具体为,对标准图像的人脸区域内的图像像素进行肤色检测,以确定标准图像中的标准肤色像素。当标准图像中未检测到人脸,则对整张标准图像的图像像素进行肤色检测以确定标准肤色 像素。通过上述方式,可以减小运算量,提高运算性能,且可以减少噪声点。In this embodiment, before step S202, the method further includes: performing face detection on each standard image to determine a face region of the standard image. In step S202, the skin color detection is performed on the image pixels of each standard image, specifically, the skin color detection is performed on the image pixels in the face region of the standard image to determine standard skin color pixels in the standard image. When no face is detected in the standard image, skin color detection is performed on the image pixels of the entire standard image to determine standard skin color pixels. In the above manner, the amount of calculation can be reduced, the calculation performance can be improved, and noise points can be reduced.
步骤S203:计算每个标准图像的标准肤色像素的特征参数值的平均值。Step S203: Calculate an average value of the feature parameter values of the standard skin color pixels of each standard image.
该步骤与步骤S103b的计算方式相类似,具体地,对于每个标准图像的标准肤色像素的每个特征参数值的平均值,其计算过程可以如下:获取标准图像的标准肤色像素的特征参数值;统计标准肤色像素的个数;计算所有标准肤色像素的同一特征参数值的总和,计算该总和与标准肤色像素的个数的比值,从而得到每个标准图像的所有标准肤色像素的同一特征参数值的平均值。This step is similar to the calculation method of step S103b. Specifically, for the average value of each feature parameter value of the standard skin color pixel of each standard image, the calculation process may be as follows: acquiring the feature parameter value of the standard skin color pixel of the standard image ; count the number of standard skin color pixels; calculate the sum of the same feature parameter values of all standard skin color pixels, calculate the ratio of the sum to the number of standard skin color pixels, thereby obtaining the same feature parameter of all standard skin color pixels of each standard image The average of the values.
步骤S204:对所有标准图像的标准肤色像素的特征参数值的平均值进行平均计算,得到标准平均值。Step S204: averaging the average values of the characteristic parameter values of the standard skin color pixels of all standard images to obtain a standard average value.
标准平均值的计算步骤,具体包括:统计标准图像的总数;计算所有标准图像的标准肤色像素的同一特征参数值的平均值的总和;计算该总和与标准图像的总数的比值,从而得到标准肤色像素的同一特征参数值的标准平均值。The calculation step of the standard average includes: counting the total number of standard image images; calculating the sum of the average values of the same feature parameter values of the standard skin color pixels of all standard images; calculating the ratio of the sum to the total number of standard images, thereby obtaining a standard skin color The standard average of the same characteristic parameter values for the pixel.
通过利用多个标准图像的标准肤色像素的特征参数值的平均值,计算标准平均值,可以使得标准平均值更接近用户的自然肤色,从而当以标准平均值为参考,根据原始肤色像素的特征参数值的平均值与标准平均值之间的差值对原始图像进行调整时,可以使得原始图像中的肤色更接近用户的自然肤色。By using the average of the characteristic parameter values of the standard skin color pixels of a plurality of standard images to calculate the standard average value, the standard average value can be made closer to the natural skin color of the user, and thus, based on the standard average value, according to the characteristics of the original skin color pixel The difference between the average of the parameter values and the standard average adjusts the original image to make the skin tone in the original image closer to the user's natural skin tone.
当然,在其他实施方式中,也可以选取一个标准图像计算标准平均值,此种方式中,标准平均值即为该标准图像的标准肤色像素的特征参数值的平均值。Of course, in other embodiments, a standard image may also be selected to calculate a standard average value, in which the standard average is the average of the characteristic parameter values of the standard skin color pixels of the standard image.
其中,如图3所示,根据计算得到的平均值与预设标准平均值之间 的差值,对原始图像的各图像像素的特征参数值进行校正具体包括以下子步骤:Wherein, as shown in FIG. 3, correcting the characteristic parameter values of each image pixel of the original image according to the difference between the calculated average value and the preset standard average value includes the following sub-steps:
子步骤S301:计算预设标准平均值与原始肤色像素的特征参数值的平均值之间的差值。Sub-step S301: Calculating the difference between the preset standard average value and the average value of the feature parameter values of the original skin color pixels.
该差值具体是指标准平均值减去原始肤色像素的特征参数值的平均值的差值。The difference specifically refers to the difference between the standard average value minus the average value of the characteristic parameter values of the original skin color pixels.
子步骤S302:获取原始图像的各图像像素的特征参数值。Sub-step S302: Acquire feature parameter values of each image pixel of the original image.
子步骤S303:根据原始肤色像素的特征参数值的平均值和各图像像素的特征参数值,计算各图像像素的校正系数。Sub-step S303: calculating a correction coefficient of each image pixel according to an average value of the feature parameter values of the original skin color pixel and a feature parameter value of each image pixel.
其中,当图像像素的特征参数值小于或等于原始肤色像素的特征参数值的平均值时,图像像素的校正系数为图像像素的特征参数值与原始肤色像素的特征参数值的平均值的比值。Wherein, when the feature parameter value of the image pixel is less than or equal to the average value of the feature parameter values of the original skin color pixel, the correction coefficient of the image pixel is a ratio of the feature parameter value of the image pixel to the average value of the feature parameter values of the original skin color pixel.
当图像像素的特征参数值大于原始肤色像素的特征参数值的平均值时,计算预设常数与图像像素的特征参数值之间的第一差值,以及计算预设常数与原始肤色像素的特征参数值的平均值之间的第二差值,图像的校正系数为第一差值和第二差值的比值。When the feature parameter value of the image pixel is greater than the average value of the feature parameter value of the original skin color pixel, calculating a first difference between the preset constant and the feature parameter value of the image pixel, and calculating a preset constant and a feature of the original skin color pixel A second difference between the average values of the parameter values, the correction coefficient of the image being the ratio of the first difference to the second difference.
子步骤S304:根据预设标准平均值与原始肤色像素的特征参数值的平均值之间的差值,以及图像像素的校正系数,对原始图像的各图像像素的特征参数值进行校正。Sub-step S304: correcting the feature parameter values of the image pixels of the original image according to the difference between the preset standard average value and the average value of the feature parameter values of the original skin color pixels, and the correction coefficient of the image pixels.
具体地,根据以下公式对原始图像的各图像像素的特征参数值进行校正:Specifically, the feature parameter values of the image pixels of the original image are corrected according to the following formula:
C 1=C 0+ΔC*k   (一) C 1 =C 0 +ΔC*k (1)
其中,在上述公式一中,C 1表示校正后的图像像素的特征参数值,C 0表示校正前的图像像素的特征参数值,也即步骤S302中获取的原始图像像素的特征参数值,ΔC表示标准肤色像素的相应特征参数值的标 准平均值与原始肤色像素的相应特征参数值的平均值之间的差值,k表示图像像素的校正系数。 Wherein, in the above formula 1, C 1 represents a characteristic parameter value of the corrected image pixel, and C 0 represents a characteristic parameter value of the image pixel before the correction, that is, a characteristic parameter value of the original image pixel acquired in step S302, ΔC The difference between the standard average of the corresponding feature parameter values representing the standard skin color pixels and the average of the corresponding feature parameter values of the original skin color pixels, and k represents the correction coefficient of the image pixels.
其中,当图像像素的特征参数值小于或等于原始肤色像素的特征参数值的平均值时,校正系数k为:Wherein, when the feature parameter value of the image pixel is less than or equal to the average value of the feature parameter values of the original skin color pixel, the correction coefficient k is:
k=C 0/C a,其中C 0≤C a   (二) k=C 0 /C a , where C 0 ≤C a (b)
当图像像素的特征参数值大于原始肤色像素的特征参数值的平均值时,校正系数k为:When the feature parameter value of the image pixel is greater than the average value of the feature parameter value of the original skin color pixel, the correction coefficient k is:
k=(n-C 0)/(n-C a),其中,C 0>C a,n为预设常数   (三)。 k = (nC 0 ) / (nC a ), where C 0 > C a , n is a preset constant (3).
下面将结合具体的特征参数值对本发明实施例做进一步描述。The embodiments of the present invention will be further described below in conjunction with specific characteristic parameter values.
在本发明一实施例中,特征参数值包括第一颜色空间上的红、绿和蓝三基色分量的像素值,其中第一颜色空间为红绿蓝RGB(Red(红),Green(绿),Blue(蓝))颜色空间。本实施例中,像素的各基色分量的像素值的取值范围为0~1。In an embodiment of the invention, the feature parameter value includes pixel values of three primary color components of red, green, and blue in the first color space, wherein the first color space is red, green, and blue RGB (Red, Green) , Blue (blue)) color space. In this embodiment, the pixel value of each primary color component of the pixel ranges from 0 to 1.
其中,可以根据上述步骤S201~步骤S204预先计算出标准图像的标准肤色像素的红、绿和蓝三基色分量的像素值的标准平均值。The standard average value of the pixel values of the red, green, and blue primary color components of the standard skin color pixel of the standard image may be calculated in advance according to the above steps S201 to S204.
参阅图4,本实施例的图像处理方法具体包括以下步骤:Referring to FIG. 4, the image processing method of this embodiment specifically includes the following steps:
步骤S401:获取原始图像。Step S401: Acquire an original image.
步骤S402:对原始图像的图像像素进行肤色检测,以确定原始图像中的原始肤色像素。Step S402: Perform skin color detection on the image pixels of the original image to determine original skin color pixels in the original image.
步骤S403:获取原始图像中各原始肤色像素的红、绿和蓝三基色分量的像素值,并计算原始图像中所有原始肤色像素的红、绿和蓝三基色分量的像素值的平均值,得到原始肤色像素的特征参数值的平均值。Step S403: Obtain pixel values of three primary color components of red, green, and blue of each original skin color pixel in the original image, and calculate an average value of pixel values of three primary color components of red, green, and blue of all original skin color pixels in the original image. The average of the feature parameter values of the original skin tone pixels.
具体地,首先统计原始肤色像素的总量,也即各基色分量的总量。以红色分量为例,获取各原始肤色像素的红色分量的像素值,计算所有 原始肤色像素的红色分量的像素值的总和,然后计算所有原始肤色像素的红色分量的像素值的总和与原始肤色像素的总量的比值,从而得到原始肤色像素的红色分量的像素值的平均值。绿色分量和蓝色分量的像素值的平均值可采用相类似的方法计算得到。Specifically, the total amount of the original skin color pixels, that is, the total amount of the respective primary color components, is first counted. Taking the red component as an example, the pixel values of the red components of the original skin color pixels are obtained, the sum of the pixel values of the red components of all the original skin color pixels is calculated, and then the sum of the pixel values of the red components of all the original skin color pixels and the original skin color pixels are calculated. The ratio of the total amount, resulting in an average of the pixel values of the red component of the original skin tone pixel. The average of the pixel values of the green component and the blue component can be calculated in a similar manner.
步骤S404:计算预设标准图像中标准肤色像素的红、绿和蓝三基色分量的像素值的标准平均值和原始图像中原始肤色像素的相应基色分量的像素值的平均值之间的差值。Step S404: calculating a difference between a standard average value of the pixel values of the three primary color components of the standard skin color pixels in the preset standard image and an average value of the pixel values of the corresponding primary color components of the original skin color pixel in the original image. .
具体而言,分别计算标准肤色像素的红色分量的像素值的标准平均值减去原始肤色像素的红色分量的像素值的平均值的差值、标准肤色像素的绿色分量的像素值的标准平均值减去原始肤色像素的绿色分量的像素值的平均值的差值、标准肤色像素的蓝色分量的像素值的标准平均值减去原始肤色像素的蓝色分量的像素值的平均值的差值。Specifically, the standard average of the pixel values of the red component of the standard skin color pixel is subtracted from the average of the pixel values of the red component of the original skin color pixel, and the standard average of the pixel values of the green component of the standard skin color pixel, respectively. The difference between the average value of the pixel values of the green component of the original skin color pixel, the standard average value of the pixel values of the blue component of the standard skin color pixel, and the difference of the average value of the pixel values of the blue component of the original skin color pixel are subtracted .
步骤S405:获取各图像像素的红、绿和蓝三基色分量的像素值,得到各图像像素的特征参数值。Step S405: Acquire pixel values of three primary color components of red, green, and blue of each image pixel to obtain characteristic parameter values of each image pixel.
步骤S406:根据原始肤色像素的红、绿和蓝三基色分量的像素值的平均值,以及各图像像素的红、绿和蓝三基色分量的像素值,计算各图像像素的红、绿和蓝三基色分量的像素值的校正系数。Step S406: Calculate red, green, and blue of each image pixel according to an average value of pixel values of three primary color components of the original skin color pixel, and pixel values of three primary color components of red, green, and blue of each image pixel. A correction factor for the pixel values of the three primary color components.
其中,根据上述公式二和公式三计算原始图像中各图像像素的红、绿和蓝三基色分量的像素值的校正系数。以红色分量为例,当图像像素的红色分量的像素值小于或等于原始肤色像素的红色分量的像素值的平均值,采用公式二计算该图像像素的红色分量的像素值的校正系数,其中公式二中的C 0表示该图像像素的红色分量的像素值,C a表示原始肤色像素的红色分量的像素值的平均值。当图像像素的红色分量的像素值大于原始肤色像素的红色分量的像素值的平均值时,采用公式三计算该图像像素的红色分量的校正系数,其中公式三中的n为1,即当像素 值的取值范围在0~1时,预设常数为1。由此,根据图像像素的红色分量的像素值和原始肤色像素的红色分量的像素值的平均值的对比结果,将C 0、C a和n代入上述公式二或公式三即可计算出图像像素的红色分量的像素值的校正系数。 Wherein, the correction coefficients of the pixel values of the three primary color components of the red, green and blue of each image pixel in the original image are calculated according to the above formula 2 and formula 3. Taking the red component as an example, when the pixel value of the red component of the image pixel is less than or equal to the average value of the pixel value of the red component of the original skin color pixel, the correction coefficient of the pixel value of the red component of the image pixel is calculated by using the formula 2, where the formula C 0 in the two represents the pixel value of the red component of the image pixel, and C a represents the average value of the pixel values of the red component of the original skin color pixel. When the pixel value of the red component of the image pixel is greater than the average value of the pixel value of the red component of the original skin color pixel, the correction coefficient of the red component of the image pixel is calculated by using Equation 3, where n in Equation 3 is 1, that is, when the pixel When the value ranges from 0 to 1, the preset constant is 1. Thus, according to the comparison result of the average value of the pixel value of the red component of the image pixel and the pixel value of the red component of the original skin color pixel, C 0 , C a and n are substituted into the above formula 2 or formula 3 to calculate the image pixel. The correction factor for the pixel value of the red component.
绿色分量和蓝色分量的像素值的校正系数可采用类似方法得到,对此不做赘述。The correction coefficients of the pixel values of the green component and the blue component can be obtained in a similar manner, and will not be described herein.
步骤S407:根据预设标准图像中标准肤色像素的红、绿和蓝三基色分量的像素值的标准平均值和原始图像中原始肤色像素的相应基色分量的像素值的平均值之间的差值,以及各图像像素的红、绿和蓝三基色分量的像素值的校正系数,对各图像像素的红、绿和蓝三基色分量的像素值进行校正。Step S407: The difference between the standard average value of the pixel values of the red, green, and blue primary color components of the standard skin color pixel in the preset standard image and the average value of the pixel values of the corresponding primary color component of the original skin color pixel in the original image. And a correction coefficient of the pixel values of the three primary color components of the red, green, and blue components of each image pixel, and correcting the pixel values of the three primary color components of the red, green, and blue color of each image pixel.
其中,根据上述公式一对原始图像的各图像像素的红、绿和蓝三基色分量的像素值的进行校正。具体地,以红色分量为例,在公式一中,C 1表示校正后的图像像素的红色分量的像素值,C 0表示校正前该图像像素的红色分量的像素值,ΔC表示标准肤色像素的红色分量的像素值的标准平均值与原始肤色像素的红色分量的像素值的平均值之间的差值,k表示该图像像素的校正系数,由此将C 0、ΔC和k代入上述公式一即可计算出校正后的图像像素的红色分量的像素值。 Wherein, the pixel values of the three primary color components of the red, green and blue of each image pixel of the pair of original images are corrected according to the above formula. Specifically, taking the red component as an example, in Equation 1, C 1 represents the pixel value of the red component of the corrected image pixel, C 0 represents the pixel value of the red component of the image pixel before correction, and ΔC represents the standard skin color pixel. The difference between the standard average of the pixel values of the red component and the average of the pixel values of the red component of the original skin color pixel, k represents the correction coefficient of the image pixel, thereby substituting C 0 , ΔC, and k into the above formula 1 The pixel value of the red component of the corrected image pixel can be calculated.
以此类推该图像像素的绿色分量和蓝色分量的像素值的校正过程。通过上述方式,可以得到各图像像素校正后的各基色分量的像素值,实现对原始图像的校正。The correction process of the pixel values of the green component and the blue component of the image pixel is thus derived. In the above manner, the pixel values of the respective primary color components corrected for each image pixel can be obtained, and the original image can be corrected.
步骤S408:输出校正后的原始图像。Step S408: Output the corrected original image.
本实施例中,通过对原始图像的各图像像素的各基色分量的像素值进行校正,可以使得校正后的原始图像的明暗程度更接近自然情况,所显示的肤色与用户的自然肤色更接近,有利于减少图像过暗或过曝的现 象,提高图像质量。In this embodiment, by correcting the pixel values of the respective primary color components of the image pixels of the original image, the brightness of the corrected original image can be made closer to the natural situation, and the displayed skin color is closer to the natural skin color of the user. It is beneficial to reduce the phenomenon of excessive darkness or overexposure of images and improve image quality.
在本发明另一实施例中,特征参数值包括第二颜色空间上的亮度值、第一色度值以及第二色度值,其中第二颜色空间为YUV(Luminance(亮度),Chroma(色度))颜色空间,为了便于描述,亮度值用Y值表示,第一色度值用U值表示,第二色度值用V值表示。In another embodiment of the present invention, the feature parameter value includes a luminance value, a first chrominance value, and a second chrominance value on the second color space, wherein the second color space is YUV (Luminance, Chroma) Degree)) Color space, for convenience of description, the brightness value is represented by a Y value, the first chromaticity value is represented by a U value, and the second chromaticity value is represented by a V value.
其中,可以根据上述步骤S201~步骤S204预先计算出标准图像的标准肤色像素的Y值、U值以及V值的标准平均值。The Y value, the U value, and the standard average value of the V value of the standard skin color pixel of the standard image may be calculated in advance according to the above steps S201 to S204.
参阅图5,本实施例的图像处理方法具体包括以下步骤:Referring to FIG. 5, the image processing method of this embodiment specifically includes the following steps:
步骤S501:获取原始图像。Step S501: Acquire an original image.
步骤S502:对原始图像的图像像素进行肤色检测,以确定原始图像中的原始肤色像素。Step S502: Perform skin color detection on image pixels of the original image to determine original skin color pixels in the original image.
步骤S503:获取原始图像中各原始肤色像素在RGB颜色空间上的红、绿和蓝三基色分量的像素值,根据原始图像中各原始肤色像素的红、绿和蓝三基色分量的像素值,计算各原始肤色像素在YUV颜色空间上的Y值、U值以及V值,并计算所有原始肤色像素的Y值的平均值、U值的平均值以及V值的平均值,得到原始肤色像素的特征参数值的平均值。Step S503: Obtain pixel values of three primary color components of red, green, and blue in the RGB color space of each original skin color pixel in the original image, according to pixel values of three primary color components of red, green, and blue of each original skin color pixel in the original image. Calculate the Y value, U value, and V value of each original skin color pixel in the YUV color space, and calculate the average value of the Y values of all the original skin color pixels, the average value of the U value, and the average value of the V values to obtain the original skin color pixels. The average of the characteristic parameter values.
其中,各原始肤色像素的各基色分量的像素值的取值范围为0~1。The pixel value of each primary color component of each original skin color pixel ranges from 0 to 1.
根据如下公式计算各原始肤色像素在YUV颜色空间上的Y值、U值以及V值:Calculate the Y value, U value, and V value of each original skin color pixel in the YUV color space according to the following formula:
Figure PCTCN2018079073-appb-000001
Figure PCTCN2018079073-appb-000001
其中,Y 1、U 1、V 1分别表示原始肤色像素在YUV颜色空间上的Y值、U值、V值,R 1、G 1、B 1分别表示该原始肤色像素在RGB颜色空 间上的红、绿和蓝基色分量的像素值。 Wherein, Y 1 , U 1 , and V 1 respectively represent Y values, U values, and V values of the original skin color pixels in the YUV color space, and R 1 , G 1 , and B 1 respectively represent the original skin color pixels in the RGB color space. The pixel values of the primary components of red, green, and blue.
计算得到各原始肤色像素的Y值、U值和V值后,统计原始肤色像素的总量,并计算所有原始肤色像素的Y值的总和、U值的总和以及V值的总和,然后分别计算Y值的总和与原始肤色像素的总量的比值、U值的总和与原始肤色像素的总量的比值以及V值的总和与原始肤色像素的总量的比值,从而分别得到原始肤色像素的Y值的平均值、U值的平均值以及V值的平均值。After calculating the Y value, the U value, and the V value of each original skin color pixel, the total amount of the original skin color pixels is counted, and the sum of the Y values of all the original skin color pixels, the sum of the U values, and the sum of the V values are calculated, and then respectively calculated. The ratio of the sum of the Y values to the total amount of the original skin color pixels, the ratio of the sum of the U values to the total amount of the original skin color pixels, and the ratio of the sum of the V values to the total amount of the original skin color pixels, thereby respectively obtaining the Y of the original skin color pixel The average of the values, the average of the U values, and the average of the V values.
步骤S504:计算预设标准图像中标准肤色像素的Y值、U值和V值的标准平均值和原始图像中原始肤色像素的相应Y值、U值和V值的平均值之间的差值。Step S504: calculating a difference between a standard average value of the Y value, the U value, and the V value of the standard skin color pixel in the preset standard image and an average value of the corresponding Y value, the U value, and the V value of the original skin color pixel in the original image. .
具体而言,分别计算标准肤色像素的Y值的标准平均值和原始肤色像素的Y值的平均值之间的差值、标准肤色像素的U值的标准平均值和原始肤色像素的U值的平均值之间的差值、标准肤色像素的V值的标准平均值和原始肤色像素的V值的平均值之间的差值。Specifically, the difference between the standard average value of the Y value of the standard skin color pixel and the average value of the Y value of the original skin color pixel, the standard average value of the U value of the standard skin color pixel, and the U value of the original skin color pixel are respectively calculated. The difference between the average values, the standard average of the V values of the standard skin tone pixels, and the difference between the average values of the V values of the original skin tone pixels.
步骤S505:获取原始图像的各图像像素的Y值、U值以及V值,得到原始图像的各图像像素的特征参数值。Step S505: Acquire a Y value, a U value, and a V value of each image pixel of the original image to obtain a feature parameter value of each image pixel of the original image.
其中,各图像像素的Y值、U值以及V值与上述原始肤色像素的Y值、U值以及V值的计算方法相类似,可参考上述公式四实现,在此不做一一赘述。The Y value, the U value, and the V value of each image pixel are similar to the calculation methods of the Y value, the U value, and the V value of the original skin color pixel, and can be implemented by referring to the above formula 4, and will not be described herein.
步骤S506:根据原始肤色像素的Y值的平均值、U值的平均值以及V值的平均值,以及各图像像素的Y值、U值和V值,计算各图像像素的Y值、U值以及V值的校正系数。Step S506: Calculate the Y value and the U value of each image pixel according to the average value of the Y value of the original skin color pixel, the average value of the U value, and the average value of the V value, and the Y value, the U value, and the V value of each image pixel. And the correction factor of the V value.
其中,根据上述公式二和公式三计算原始图像中各图像像素的Y值、U值以及V值的校正系数。以Y值为例,当图像像素的Y值小于或等于原始肤色像素的Y值的平均值,采用公式二计算该图像像素的Y 值的校正系数,其中公式二中的C 0表示该图像像素的Y值,C a表示原始肤色像素的Y值的平均值。当图像像素的Y值大于原始肤色像素的Y值的平均值时,采用公式三计算该图像像素的红色分量的校正系数,其中公式三中的n为1。U值和V值的校正系数可采用类似方法得到,对此不做赘述。 Wherein, the correction values of the Y value, the U value, and the V value of each image pixel in the original image are calculated according to the above formula 2 and formula 3. Taking the Y value as an example, when the Y value of the image pixel is less than or equal to the average value of the Y value of the original skin color pixel, the correction coefficient of the Y value of the image pixel is calculated by Equation 2, where C 0 in Formula 2 represents the image pixel. The Y value, C a represents the average of the Y values of the original skin color pixels. When the Y value of the image pixel is greater than the average value of the Y value of the original skin color pixel, the correction coefficient of the red component of the image pixel is calculated using Equation 3, where n in Equation 3 is 1. The correction coefficients of the U value and the V value can be obtained in a similar manner, and will not be described again.
步骤S507:根据预设标准图像中标准肤色像素的Y值、U值和V值的标准平均值和原始图像中原始肤色像素的相应Y值、U值和V值的平均值之间的差值,以及各图像像素的Y值、U值和V值的校正系数,对各图像像素的Y值、U值和V值进行校正。Step S507: The difference between the standard average value of the Y value, the U value, and the V value of the standard skin color pixel in the preset standard image and the corresponding Y value, the U value, and the average value of the V value of the original skin color pixel in the original image. And a correction coefficient of the Y value, the U value, and the V value of each image pixel, and correct the Y value, the U value, and the V value of each image pixel.
其中,根据上述公式一对原始图像的各图像像素的Y值、U值以及V值进行校正。具体地,以Y值为例,在公式一中,C 1表示校正后的图像像素的Y值,C 0表示校正前该图像像素的Y值,ΔC表示标准肤色像素的Y值的标准平均值与原始肤色像素的Y值的平均值之间的差值,k表示该图像像素的校正系数。以此类推该图像像素的U值和V值的校正方式。通过上述方式,可以得到各图像像素校正后的Y值、U值以及V值,实现对原始图像的校正。 Wherein, the Y value, the U value, and the V value of each image pixel of the pair of original images are corrected according to the above formula. Specifically, taking the value of Y as an example, in Equation 1, C 1 represents the Y value of the corrected image pixel, C 0 represents the Y value of the image pixel before correction, and ΔC represents the standard average value of the Y value of the standard skin color pixel. The difference from the average of the Y values of the original skin color pixels, k represents the correction coefficient of the image pixels. The way in which the U and V values of the image pixels are corrected is thus derived. In the above manner, the corrected Y value, U value, and V value of each image pixel can be obtained, and the original image can be corrected.
步骤S508:输出校正后的原始图像。Step S508: Output the corrected original image.
其中,输出校正后的原始图像具体包括:根据校正后的各图像像素的Y值、U值以及V值,计算校正后各图像像素的红、绿和蓝三基色分量的像素值,从而得到RGB格式的原始图像,输出校正后的RGB格式的原始图像。The outputting the corrected original image specifically includes: calculating, according to the corrected Y value, U value, and V value of each image pixel, pixel values of the three primary color components of the red, green, and blue color of each corrected image pixel, thereby obtaining RGB The original image of the format, the original image of the corrected RGB format is output.
其中,根据如下公式计算校正后各图像像素的红、绿和蓝三基色分量的像素值:Wherein, the pixel values of the three primary color components of the red, green and blue pixels of each image pixel after correction are calculated according to the following formula:
Figure PCTCN2018079073-appb-000002
Figure PCTCN2018079073-appb-000002
其中,Y 2、U 2、V 2分别表示校正后的图像像素的Y值、U值和V值,R 2、G 2、B 2分别表示校正后的图像像素的红、绿和蓝三基色分量的像素值。 Wherein Y 2 , U 2 , and V 2 respectively represent Y values, U values, and V values of the corrected image pixels, and R 2 , G 2 , and B 2 respectively represent the three primary colors of red, green, and blue of the corrected image pixels. The pixel value of the component.
本实施例中,通过对原始图像的各图像像素的Y值、U值和V值进行校正,可以进一步提高校正后的原始图像的图像质量,使得校正后的原始图像的明暗程度更接近自然情况,所显示的肤色与用户的自然肤色更接近。In this embodiment, by correcting the Y value, the U value, and the V value of each image pixel of the original image, the image quality of the corrected original image can be further improved, so that the brightness of the corrected original image is closer to the natural situation. The displayed skin tone is closer to the user's natural skin tone.
在本发明又一实施方式中,可以仅对图像像素的Y值进行校正而不对U值和Y值做调整,U值和V值在校正前后不变,即仅调整原始图像的亮度,对原始图像的色度不做调整,通过此种方式,可以在一定程度上降低原始图像过曝或过暗的几率,同时可以简化校正过程。其中,本实施例与图5所示实施例的主要不同在于,本实施例仅针对图像像素的Y值进行校正,因此具体的校正过程可参考图5所示实施例的Y值的校正过程进行,出于简洁的目的,在此不做一一赘述。In still another embodiment of the present invention, only the Y value of the image pixel may be corrected without adjusting the U value and the Y value, and the U value and the V value are unchanged before and after the correction, that is, only the brightness of the original image is adjusted, and the original The chromaticity of the image is not adjusted. In this way, the probability of the original image being overexposed or too dark can be reduced to some extent, and the correction process can be simplified. The main difference between the present embodiment and the embodiment shown in FIG. 5 is that the present embodiment only corrects the Y value of the image pixel. Therefore, the specific calibration process may be performed by referring to the Y value correction process of the embodiment shown in FIG. 5. For the sake of brevity, we will not repeat them here.
在本发明的又一实施例中,特征参数值包括第三颜色空间上的色调值、饱和度值和明度值,其中第三颜色空间为HSV(Hue(色调),Saturation(饱和度),Value(明度))颜色空间,为了便于描述,色调值用H值表示,饱和度值用S值表示,明度值用V值表示。In still another embodiment of the present invention, the feature parameter value includes a tone value, a saturation value, and a brightness value in a third color space, wherein the third color space is HSV (Hue, Saturation, Value (Lightness)) The color space. For convenience of description, the tone value is represented by an H value, the saturation value is represented by an S value, and the brightness value is represented by a V value.
其中,可以根据上述步骤S201~步骤S204预先计算出标准图像的标准肤色像素的H值、S值以及V值的标准平均值。The standard value of the H value, the S value, and the V value of the standard skin color pixel of the standard image may be calculated in advance according to the above steps S201 to S204.
参阅图6,本实施例的图像处理方法具体包括以下步骤:Referring to FIG. 6, the image processing method of this embodiment specifically includes the following steps:
步骤S601:获取原始图像。Step S601: Acquire an original image.
步骤S602:对原始图像的图像像素进行肤色检测,以确定原始图像中的原始肤色像素。Step S602: Perform skin color detection on image pixels of the original image to determine original skin color pixels in the original image.
步骤S603:获取原始图像中各原始肤色像素在RGB颜色空间上的红、绿和蓝三基色分量的像素值,根据原始图像中各原始肤色像素的红、绿和蓝三基色分量的像素值,计算各原始肤色像素在HSV颜色空间上的H值、S值以及V值,并计算所有原始肤色像素的H值的平均值、S值的平均值以及V值的平均值,得到原始肤色像素的特征参数值的平均值。Step S603: acquiring pixel values of three primary color components of red, green, and blue of each original skin color pixel in the original image, according to pixel values of three primary color components of red, green, and blue of each original skin color pixel in the original image. Calculate the H value, S value and V value of each original skin color pixel in the HSV color space, and calculate the average value of the H value of all the original skin color pixels, the average value of the S value, and the average value of the V value to obtain the original skin color pixel. The average of the characteristic parameter values.
其中,各原始肤色像素的各基色分量的像素值的取值范围为0~1。The pixel value of each primary color component of each original skin color pixel ranges from 0 to 1.
根据各原始肤色像素在HSV颜色空间上的H值、S值以及V值的计算方式如下:The H value, S value, and V value in the HSV color space according to each original skin color pixel are calculated as follows:
设M=max(R 1,G 1,B 1),即M等于R 1、G 1和B 1中的最大者,N=min(R 1,G 1,B 1),即N等于R 1、G 1和B 1中的最小者,H值的计算方式如下: Let M = max(R 1 , G 1 , B 1 ), ie M is equal to the largest of R 1 , G 1 and B 1 , N=min(R 1 , G 1 , B 1 ), ie N is equal to R 1 The smallest of G 1 and B 1 , the H value is calculated as follows:
Figure PCTCN2018079073-appb-000003
Figure PCTCN2018079073-appb-000003
S值的计算方式如下:The S value is calculated as follows:
Figure PCTCN2018079073-appb-000004
Figure PCTCN2018079073-appb-000004
V值的计算方式如下:The V value is calculated as follows:
V 1=M   (八) V 1 =M (eight)
其中,H 1、S 1、V 1分别表示原始肤色像素在HSV颜色空间上的H值、S值和V值,R 1、G 1、B 1分别表示该原始肤色像素在RGB颜色空间上的红、绿和蓝基色分量的像素值。 Wherein, H 1 , S 1 , and V 1 respectively represent H values, S values, and V values of the original skin color pixels in the HSV color space, and R 1 , G 1 , and B 1 respectively represent the original skin color pixels on the RGB color space. The pixel values of the primary components of red, green, and blue.
计算得到各原始肤色像素的H值、S值和V值后,统计原始肤色像素的总量,并计算所有原始肤色像素的H值的总和、S值的总和以及V值的总和,然后分别计算H值的总和与原始肤色像素的总量的比值、S值的总和与原始肤色像素的总量的比值以及V值的总和与原始肤色像素的总量的比值,从而分别得到原始肤色像素的H值的平均值、S值的平均值以及V值的平均值。After calculating the H value, the S value, and the V value of each original skin color pixel, the total amount of the original skin color pixels is counted, and the sum of the H values of all the original skin color pixels, the sum of the S values, and the sum of the V values are calculated, and then respectively calculated. The ratio of the sum of the H values to the total amount of the original skin color pixels, the ratio of the sum of the S values to the total amount of the original skin color pixels, and the ratio of the sum of the V values to the total amount of the original skin color pixels, thereby respectively obtaining the H of the original skin color pixels. The average of the values, the average of the S values, and the average of the V values.
步骤S604:计算预设标准图像中标准肤色像素的H值、S值和V值的标准平均值和原始图像中原始肤色像素的相应H值、S值和V值的平均值之间的差值。Step S604: calculating a difference between a standard average value of the H value, the S value, and the V value of the standard skin color pixel in the preset standard image and an average value of the corresponding H value, the S value, and the V value of the original skin color pixel in the original image. .
具体而言,分别计算标准肤色像素的H值的标准平均值和原始肤色像素的H值的平均值之间的差值、标准肤色像素的S值的标准平均值和原始肤色像素的S值的平均值之间的差值、标准肤色像素的V值的标准平均值和原始肤色像素的V值的平均值之间的差值。Specifically, the difference between the standard average of the H value of the standard skin color pixel and the average value of the H value of the original skin color pixel, the standard average value of the S value of the standard skin color pixel, and the S value of the original skin color pixel are respectively calculated. The difference between the average values, the standard average of the V values of the standard skin tone pixels, and the difference between the average values of the V values of the original skin tone pixels.
步骤S605:获取原始图像的各图像像素的H值、S值以及V值,得到原始图像的各图像像素的特征参数值。Step S605: Acquire an H value, an S value, and a V value of each image pixel of the original image to obtain a feature parameter value of each image pixel of the original image.
其中,各图像像素的H值、S值以及V值与上述原始肤色像素的H值、S值以及V值的计算方法相类似,可参考上述公式六、七、八计算得到,在此不做一一赘述。The H value, the S value, and the V value of each image pixel are similar to the calculation methods of the H value, the S value, and the V value of the original skin color pixel, and can be calculated by referring to the above formulas 6, 7, and 8. One by one.
步骤S606:根据原始肤色像素的H值的平均值、S值的平均值以及V值的平均值,以及各图像像素的H值、S值和V值,计算各图像像素的H值、S值以及V值的校正系数。Step S606: Calculate the H value and the S value of each image pixel according to the average value of the H value of the original skin color pixel, the average value of the S value, and the average value of the V value, and the H value, the S value, and the V value of each image pixel. And the correction factor of the V value.
其中,根据上述公式二和公式三计算原始图像中各图像像素的H 值、S值以及V值的校正系数。以H值为例,当图像像素的H值小于或等于原始肤色像素的H值的平均值,采用公式二计算该图像像素的H值的校正系数,其中公式二中的C 0表示该图像像素的H值,C a表示原始肤色像素的H值的平均值。当图像像素的H值大于原始肤色像素的H值的平均值时,采用公式三计算该图像像素的红色分量的校正系数,其中公式三中的n为1。S值和V值的校正系数可采用类似方法得到,对此不做赘述。 Wherein, the correction coefficients of the H value, the S value, and the V value of each image pixel in the original image are calculated according to the above formula 2 and formula 3. Taking the value of H as an example, when the H value of the image pixel is less than or equal to the average value of the H value of the original skin color pixel, the correction coefficient of the H value of the image pixel is calculated by Equation 2, where C 0 in Formula 2 represents the image pixel. The value of H, C a represents the average of the H values of the original skin tone pixels. When the H value of the image pixel is greater than the average value of the H value of the original skin color pixel, the correction coefficient of the red component of the image pixel is calculated by Equation 3, where n in Equation 3 is 1. The correction coefficients of the S value and the V value can be obtained in a similar manner, and will not be described again.
步骤S607:根据预设标准图像中标准肤色像素的H值、S值和V值的标准平均值和原始图像中原始肤色像素的相应H值、S值和V值的平均值之间的差值,以及各图像像素的H值、S值和V值的校正系数,对各图像像素的H值、S值和V值进行校正。Step S607: The difference between the standard average value of the H value, the S value, and the V value of the standard skin color pixel in the preset standard image and the average value of the corresponding H value, the S value, and the V value of the original skin color pixel in the original image. And a correction coefficient of the H value, the S value, and the V value of each image pixel, and correct the H value, the S value, and the V value of each image pixel.
其中,根据上述公式一对原始图像的各图像像素的H值、S值以及V值进行校正。具体地,以H值为例,在公式一中,C 1表示校正后的图像像素的H值,C 0表示校正前该图像像素的H值,ΔC表示标准肤色像素的H值的标准平均值与原始肤色像素的H值的平均值之间的差值,k表示该图像像素的校正系数。以此类推该图像像素的S值和V值的校正方式。通过上述方式,可以得到各图像像素校正后的H值、S值以及V值,实现对原始图像的校正。 Here, the H value, the S value, and the V value of each image pixel of the pair of original images are corrected according to the above formula. Specifically, taking the value of H as an example, in Equation 1, C 1 represents the H value of the corrected image pixel, C 0 represents the H value of the image pixel before the correction, and ΔC represents the standard average value of the H value of the standard skin color pixel. The difference from the average of the H values of the original skin color pixels, k represents the correction coefficient of the image pixels. The way to correct the S and V values of the image pixels is thus derived. In the above manner, the corrected H value, S value, and V value of each image pixel can be obtained, and the original image can be corrected.
步骤S608:输出校正后的原始图像。Step S608: Output the corrected original image.
其中,输出校正后的原始图像具体包括:根据校正后的各图像像素的H值、S值以及V值,计算校正后各图像像素的红、绿和蓝三基色分量的像素值,从而得到RGB格式的原始图像,输出校正后的RGB格式的原始图像。The outputting the corrected original image specifically includes: calculating, according to the corrected H value, S value, and V value of each image pixel, pixel values of the three primary color components of the red, green, and blue color of each corrected image pixel, thereby obtaining RGB The original image of the format, the original image of the corrected RGB format is output.
其中,校正后各图像像素的红、绿和蓝三基色分量的像素值的计算方式如下:The pixel values of the red, green and blue primary color components of each image pixel after correction are calculated as follows:
如果S 2=0,则R 2=G 2=B 2=V 2   (九) If S 2 =0, then R 2 = G 2 = B 2 = V 2 (9)
如果S 2≠0,则根据以下情况计算: If S 2 ≠ 0, it is calculated according to the following conditions:
设:iH为0到(H 2*6)范围之间的整数,包括0; Let iH be an integer between 0 and (H 2 *6), including 0;
f=H 2-iH; f=H 2 -iH;
a=V 2*(1-S 2) a=V 2 *(1-S 2 )
b=V 2*(1-S 2*f) b=V 2 *(1-S 2 *f)
c=V 2*(1-S 2*(1-f)) c=V 2 *(1-S 2 *(1-f))
校正后各图像像素的红绿蓝三基色分量的像素值为:The pixel values of the red, green and blue primary colors of each image pixel after correction are:
Figure PCTCN2018079073-appb-000005
Figure PCTCN2018079073-appb-000005
其中,H 2、S 2、V 2分别表示校正后的图像像素的H值、S值和V值,R 2、G 2、B 2分别表示校正后的图像像素的红、绿和蓝三基色分量的像素值。 Wherein, H 2 , S 2 , and V 2 respectively represent the H value, the S value, and the V value of the corrected image pixel, and R 2 , G 2 , and B 2 respectively represent the three primary colors of red, green, and blue of the corrected image pixel. The pixel value of the component.
本实施例中,通过对原始图像的各图像像素的H值、S值和V值进行校正,可以进一步提高校正后的原始图像的图像质量,使得校正后的原始图像的明暗程度更接近自然情况,所显示的肤色与用户的自然肤色更接近。In this embodiment, by correcting the H value, the S value, and the V value of each image pixel of the original image, the image quality of the corrected original image can be further improved, so that the brightness of the corrected original image is closer to the natural condition. The displayed skin tone is closer to the user's natural skin tone.
参阅图7,本发明图像处理装置的一实施例中,图像处理装置可以是手机、平板电脑或个人计算机等终端设备。图像处理装置包括第一获取模块701、第一肤色检测模块702、第一计算模块703、校正模块704以及输出模块705。Referring to FIG. 7, in an embodiment of the image processing apparatus of the present invention, the image processing apparatus may be a terminal device such as a mobile phone, a tablet computer or a personal computer. The image processing apparatus includes a first acquisition module 701, a first skin color detection module 702, a first calculation module 703, a correction module 704, and an output module 705.
其中,第一获取模块701用于获取原始图像。原始图像为待处理的 图像。获取的原始图像可以有多种,例如,获取原始图像具体可以包括:获取摄像头或其他图像采集设备实时获取的画面,以获取原始图像;或者,获取用户所选择的图片,以获取原始图像;又或者,接收终端设备发送的图片,以获取原始图像,等等。The first obtaining module 701 is configured to acquire an original image. The original image is the image to be processed. The obtained original image may be various. For example, acquiring the original image may include: acquiring a picture acquired by a camera or other image capturing device in real time to obtain an original image; or acquiring a picture selected by the user to obtain an original image; Or, receiving a picture sent by the terminal device to obtain an original image, and the like.
第一肤色检测模块702用于对第一获取模块701获取的原始图像的图像像素进行肤色检测,以确定原始图像中的原始肤色像素。肤色像素即人体皮肤像素。The first skin color detecting module 702 is configured to perform skin color detection on the image pixels of the original image acquired by the first acquiring module 701 to determine original skin color pixels in the original image. The skin color pixel is the human skin pixel.
其中,人脸检测的方式有多种,例如有基于传统知识的方法、基于几何特征的方法等,可以采用其中的一种或几种方法的结合进行人脸检测。其中,当原始图像是根据用户的选择获取的,则人脸区域可以由用户主动标记,具体而言,用户在选择原始图像时,可以对原始图像中的人脸进行标记,从而根据用户标记的区域确定原始图像中的人脸区域。肤色像素的检测方式也可以有多种,例如可以通过建立肤色统计模型进行肤色检测,比如基于Y(亮度)Cg(绿色分量与亮度的差)Cr(红色分量与亮度的差)与YCgCb(蓝色分量与亮度的差)颜色空间的肤色检测。Among them, there are various ways of face detection, such as a method based on traditional knowledge, a method based on geometric features, etc., and a combination of one or several methods may be used for face detection. Wherein, when the original image is obtained according to the user's selection, the face region may be actively marked by the user. Specifically, when the user selects the original image, the face in the original image may be marked, thereby The area determines the face area in the original image. There are many ways to detect skin color pixels. For example, skin color detection can be performed by establishing a skin color statistical model, such as based on Y (brightness) Cg (difference between green component and brightness) Cr (difference between red component and brightness) and YCgCb (blue Difference between color component and brightness) Skin color detection in color space.
通过针对人脸区域进行肤色检测,可以减少运算量,降低肤色检测成本,且有利于减少噪声点。By performing skin color detection on the face area, the amount of calculation can be reduced, the cost of skin color detection can be reduced, and the noise point can be reduced.
其中,第一计算模块703用于计算原始肤色像素的特征参数值的平均值。特征参数值指像素的参数的取值,例如可以是像素的灰阶值、色度值等。原始肤色像素的特征参数值可以是一个也可以是多个,有多个特征参数值时,分别计算每个特征参数值的平均值。具体地:第一计算模块703获取每个原始肤色像素的特征参数值,并统计原始肤色像素的个数,然后计算所有原始肤色像素的同一特征参数值的总和,并计算该总和与原始肤色像素的个数的比值,从而得到所有原始肤色像素的同一 特征参数值的平均值。The first calculation module 703 is configured to calculate an average value of the feature parameter values of the original skin color pixels. The feature parameter value refers to the value of the parameter of the pixel, and may be, for example, a grayscale value, a chrominance value, or the like of the pixel. The feature parameter values of the original skin color pixels may be one or more, and when there are multiple feature parameter values, the average value of each feature parameter value is calculated separately. Specifically, the first calculating module 703 acquires the feature parameter values of each original skin color pixel, and counts the number of the original skin color pixels, and then calculates the sum of the same feature parameter values of all the original skin color pixels, and calculates the sum and the original skin color pixels. The ratio of the number of the numbers, resulting in an average of the same characteristic parameter values for all of the original skin color pixels.
其中,校正模块704用于根据预设标准平均值和计算得到的平均值之间的差值,对原始图像的各图像像素的特征参数值进行校正,标准平均值为根据预设标准图像中的标准肤色像素的特征参数值计算得到。输出模块705用于输出校正后的原始图像。The correction module 704 is configured to correct the feature parameter values of each image pixel of the original image according to the difference between the preset standard average value and the calculated average value, and the standard average value is according to the preset standard image. The characteristic parameter values of the standard skin color pixels are calculated. The output module 705 is configured to output the corrected original image.
其中,标准图像中显示有用户的肤色,为曝光正常、明暗程度较为接近自然情况的图像,将标准图像中的肤色作为与用户的自然肤色最相近的肤色。本实施例中,根据预设标准平均值与原始肤色像素的特征参数值的平均值之间的差值,可以判断出原始图像的肤色相较于标准图像的肤色是偏暗或偏亮,进而根据该差值对原始图像进行调整,可以使得原始图像的肤色更接近标准图像的肤色(也即用户的自然肤色),从而使得原始图像的人像显示更为正常,避免过曝或过暗的现象。并且,基于对原始图像的肤色检测分析,对原始图像的全图进行调整,可以使得整张图像明暗程度更接近自然情况,光线亮度更加均衡,避免图像过曝或过暗,提高图像质量。Among them, the skin color of the user is displayed in the standard image, and the image with normal exposure and brightness is relatively close to the natural condition, and the skin color in the standard image is the skin color closest to the natural skin color of the user. In this embodiment, according to the difference between the preset standard average value and the average value of the feature parameter values of the original skin color pixel, it can be determined that the skin color of the original image is darker or brighter than the skin color of the standard image, and further Adjusting the original image according to the difference can make the skin color of the original image closer to the skin color of the standard image (that is, the user's natural skin color), so that the portrait image of the original image is more normal, avoiding overexposure or excessive darkness. . Moreover, based on the skin color detection analysis of the original image, the whole image of the original image is adjusted, so that the brightness of the whole image is closer to the natural situation, the brightness of the light is more balanced, and the image is prevented from being overexposed or too dark, thereby improving the image quality.
其中,当第一获取模块701获取摄像头或其他图像采集设备实时获取的画面以获取原始图像时,输出模块705用于将校正后的原始图像作为实时画面输出并显示。当第一获取模块701获取用户所选择的图片以获取原始图像时,输出模块705用于将校正后的原始图像输出并保存至相册中。The output module 705 is configured to output and display the corrected original image as a real-time image when the first acquisition module 701 acquires a real-time image acquired by a camera or other image acquisition device to obtain an original image. When the first acquisition module 701 acquires a picture selected by the user to acquire an original image, the output module 705 is configured to output and save the corrected original image into the album.
参阅图8,在本发明图像处理装置另一实施方式中,图像处理装置还包括第一人脸检测模块801、第二获取模块802、第二肤色检测模块803、第二计算模块804以及第二人脸检测模块805。Referring to FIG. 8, in another embodiment of the image processing apparatus of the present invention, the image processing apparatus further includes a first face detection module 801, a second acquisition module 802, a second skin color detection module 803, a second calculation module 804, and a second Face detection module 805.
本实施例中,选取原始图像中的人脸区域的图像像素进行肤色检测。具体地,第一人脸检测模块801用于在第一肤色检测模块702进行 肤色检测之前,对第一获取模块701获取的原始图像进行人脸检测,以确定原始图像的人脸区域。确定人脸区域后,第一肤色检测模块702具体用于对原始图像的人脸区域内的图像像素进行肤色检测,以确定原始图像中的原始肤色像素。其中,当在原始图像中未检测到人脸时,第一肤色检测模块702对整张原始图像的图像像素进行肤色检测,以确定原始图像的原始肤色像素。In this embodiment, the image pixels of the face region in the original image are selected for skin color detection. Specifically, the first face detection module 801 is configured to perform face detection on the original image acquired by the first acquisition module 701 to determine a face region of the original image before the first skin color detection module 702 performs skin color detection. After determining the face region, the first skin color detecting module 702 is specifically configured to perform skin color detection on image pixels in the face region of the original image to determine original skin color pixels in the original image. Wherein, when no human face is detected in the original image, the first skin color detecting module 702 performs skin color detection on the image pixels of the entire original image to determine the original skin color pixel of the original image.
其中,第二获取模块802用于获取至少两个标准图像。其中,标准图像可以由用户进行选择,用户可以选择较为接近自身肤色的图像作为标准图像,第二获取模块707根据用户的选择获取标准图像。The second obtaining module 802 is configured to acquire at least two standard images. The standard image may be selected by the user, the user may select an image that is closer to the skin color of the user as the standard image, and the second obtaining module 707 obtains the standard image according to the user's selection.
第二人脸检测模块805用于对每个标准图像进行人脸检测,以确定标准图像的人脸区域。当确定了人脸区域,第二肤色检测模块803用于对每个标准图像的人脸区域内的图像像素进行肤色检测,以确定标准图像的标准肤色像素。当标准图像中未检测到人脸,则第二肤色检测模块803用于对整张标准图像进行肤色检测以确定标准肤色像素。The second face detection module 805 is configured to perform face detection on each standard image to determine a face area of the standard image. When the face region is determined, the second skin color detecting module 803 is configured to perform skin color detection on the image pixels in the face region of each standard image to determine a standard skin color pixel of the standard image. When no face is detected in the standard image, the second skin color detecting module 803 is configured to perform skin color detection on the entire standard image to determine a standard skin color pixel.
第二计算模块804用于计算每个标准图像的标准肤色像素的特征参数值的平均值,并对所有标准图像的标准肤色像素的特征参数值的平均值进行平均计算,得到标准平均值。The second calculation module 804 is configured to calculate an average value of the feature parameter values of the standard skin color pixels of each standard image, and average the average values of the feature parameter values of the standard skin color pixels of all the standard images to obtain a standard average value.
对于每个标准图像的标准肤色像素的每个特征参数值的平均值,其计算过程可以如下:第二计算模块804获取标准图像的标准肤色像素的特征参数值,然后统计标准肤色像素的个数,并计算所有标准肤色像素的同一特征参数值的总和,之后计算该总和与标准肤色像素的个数的比值,从而得到每个标准图像的所有标准肤色像素的同一特征参数值的平均值。For the average value of each feature parameter value of the standard skin color pixel of each standard image, the calculation process may be as follows: the second calculation module 804 acquires the feature parameter value of the standard skin color pixel of the standard image, and then counts the number of standard skin color pixels. And calculating the sum of the same feature parameter values of all standard skin color pixels, and then calculating the ratio of the sum to the number of standard skin color pixels, thereby obtaining an average of the same feature parameter values of all standard skin color pixels of each standard image.
其中,标准平均值的计算过程可以如下:第二计算模块804统计标准图像的总数,并计算所有标准图像的标准肤色像素的同一特征参数值 的平均值的总和,之后计算该总和与标准图像的总数的比值,从而得到标准肤色像素的同一特征参数值的标准平均值。The calculation process of the standard average value may be as follows: the second calculation module 804 counts the total number of standard images, and calculates the sum of the average values of the same feature parameter values of the standard skin color pixels of all standard images, and then calculates the sum and the standard image. The ratio of the totals, resulting in a standard average of the same characteristic parameter values for standard skin tone pixels.
通过利用多个标准图像的标准肤色像素的特征参数值的平均值,计算标准平均值,可以使得标准平均值更接近用户的自然肤色,从而当以标准平均值为参考,根据原始肤色像素的特征参数值的平均值与标准平均值之间的差值对原始图像进行调整时,可以使得原始图像中的肤色更接近用户的自然肤色。By using the average of the characteristic parameter values of the standard skin color pixels of a plurality of standard images to calculate the standard average value, the standard average value can be made closer to the natural skin color of the user, and thus, based on the standard average value, according to the characteristics of the original skin color pixel The difference between the average of the parameter values and the standard average adjusts the original image to make the skin tone in the original image closer to the user's natural skin tone.
当然,在其他实施方式中,也可以选取一个标准图像计算标准平均值,此种方式中,标准平均值即为该标准图像的标准肤色像素的特征参数值的平均值。Of course, in other embodiments, a standard image may also be selected to calculate a standard average value, in which the standard average is the average of the characteristic parameter values of the standard skin color pixels of the standard image.
其中,第一人脸检测模块801与第二人脸检测模块805可以是同一个模块也可以是不同模块,第二获取模块802和第一获取模块701可以是同一个模块也可以是不同模块,第二肤色检测模块803和第一肤色检测模块702可以是同一个模块也可以是不同模块,第二计算模块804和第一计算模块703可以是同一模块也可以是不同模块。The first face detection module 801 and the second face detection module 805 may be the same module or different modules, and the second acquisition module 802 and the first acquisition module 701 may be the same module or different modules. The second skin color detecting module 803 and the first skin color detecting module 702 may be the same module or different modules, and the second calculating module 804 and the first calculating module 703 may be the same module or different modules.
本实施方式中,校正模块704包括第一计算单元7041、获取单元7042、第二计算单元7043以及校正单元7044。In this embodiment, the correction module 704 includes a first calculation unit 7041, an acquisition unit 7042, a second calculation unit 7043, and a correction unit 7044.
其中,第一计算单元7041用于计算预设标准平均值与原始肤色像素的特征参数值的平均值之间的差值,该差值具体是指标准平均值减去原始肤色像素的特征参数值的平均值的差值。The first calculating unit 7041 is configured to calculate a difference between a preset standard average value and an average value of the feature parameter values of the original skin color pixel, where the difference specifically refers to a standard average value minus a characteristic parameter value of the original skin color pixel. The difference between the averages.
获取单元7042用于获取原始图像的各图像像素的特征参数值。The obtaining unit 7042 is configured to acquire feature parameter values of each image pixel of the original image.
第二计算单元7043用于根据原始肤色像素的特征参数值的平均值和各图像像素的特征参数值,计算各图像像素的校正系数。具体地,第二计算单元7043用于当图像像素的特征参数值小于或等于原始肤色像素的特征参数值的平均值时,计算图像像素的特征参数值与原始肤色像 素的特征参数值的平均值的比值,从而得到图像像素的校正系数;并且用于当图像像素的特征参数值大于原始肤色像素的特征参数值的平均值时,计算预设常数与图像像素的特征参数值之间的第一差值,以及计算预设常数与原始肤色像素的特征参数值的平均值之间的第二差值,并第一差值和第二差值的比值,从而得到图像像素的校正系数。The second calculating unit 7043 is configured to calculate a correction coefficient of each image pixel according to an average value of the feature parameter values of the original skin color pixel and a feature parameter value of each image pixel. Specifically, the second calculating unit 7043 is configured to calculate an average value of the feature parameter value of the image pixel and the feature parameter value of the original skin color pixel when the feature parameter value of the image pixel is less than or equal to the average value of the feature parameter values of the original skin color pixel. Ratio of the image, thereby obtaining a correction coefficient of the image pixel; and for calculating the first between the preset constant and the characteristic parameter value of the image pixel when the feature parameter value of the image pixel is greater than the average value of the feature parameter value of the original skin color pixel a difference value, and calculating a second difference between the preset constant and an average value of the feature parameter values of the original skin color pixel, and a ratio of the first difference value to the second difference value, thereby obtaining a correction coefficient of the image pixel.
校正单元7044用于根据预设标准平均值与原始肤色像素的特征参数值的平均值之间的差值,以及图像像素的校正系数,对原始图像的各图像像素的特征参数值进行校正。The correcting unit 7044 is configured to correct the feature parameter values of the image pixels of the original image according to the difference between the preset standard average value and the average value of the feature parameter values of the original skin color pixels, and the correction coefficient of the image pixels.
具体地,根据以下公式对原始图像的各图像像素的特征参数值进行校正:Specifically, the feature parameter values of the image pixels of the original image are corrected according to the following formula:
C 1=C 0+ΔC*k   (一) C 1 =C 0 +ΔC*k (1)
其中,在上述公式一中,C 1表示校正后的图像像素的特征参数值,C 0表示校正前的图像像素的特征参数值,也即步骤S302中获取的原始图像像素的特征参数值,ΔC表示标准肤色像素的相应特征参数值的标准平均值与原始肤色像素的相应特征参数值的平均值之间的差值,k表示图像像素的校正系数。 Wherein, in the above formula 1, C 1 represents a characteristic parameter value of the corrected image pixel, and C 0 represents a characteristic parameter value of the image pixel before the correction, that is, a characteristic parameter value of the original image pixel acquired in step S302, ΔC The difference between the standard average of the corresponding feature parameter values representing the standard skin color pixels and the average of the corresponding feature parameter values of the original skin color pixels, and k represents the correction coefficient of the image pixels.
其中,当图像像素的特征参数值小于或等于原始肤色像素的特征参数值的平均值时,校正系数k为:Wherein, when the feature parameter value of the image pixel is less than or equal to the average value of the feature parameter values of the original skin color pixel, the correction coefficient k is:
k=C 0/C a,其中C 0≤C a   (二) k=C 0 /C a , where C 0 ≤C a (b)
当图像像素的特征参数值大于原始肤色像素的特征参数值的平均值时,校正系数k为:When the feature parameter value of the image pixel is greater than the average value of the feature parameter value of the original skin color pixel, the correction coefficient k is:
k=(n-C 0)/(n-C a),其中,C 0>C a,n为预设常数   (三)。 k = (nC 0 ) / (nC a ), where C 0 > C a , n is a preset constant (3).
在本发明一具体实施例中,特征参数值包括第一颜色空间上的红、绿和蓝三基色分量的像素值,其中第一颜色空间为红绿蓝RGB(Red (红),Green(绿),Blue(蓝))颜色空间。本实施例中,像素的各基色分量的像素值的取值范围为0~1。In a specific embodiment of the present invention, the feature parameter value includes pixel values of three primary color components of red, green, and blue in the first color space, wherein the first color space is red, green, and blue RGB (Red (Red), Green (Green) ), Blue (blue)) color space. In this embodiment, the pixel value of each primary color component of the pixel ranges from 0 to 1.
本实施例中,第一计算模块703具体用于获取原始图像中各原始肤色像素的红、绿和蓝三基色分量的像素值,并计算原始图像中所有原始肤色像素的红、绿和蓝三基色分量的像素值的平均值,从而得到原始肤色像素的特征参数值的平均值。In this embodiment, the first calculating module 703 is specifically configured to obtain pixel values of three primary color components of the original skin color pixels in the original image, and calculate red, green, and blue colors of all the original skin color pixels in the original image. The average of the pixel values of the primary color components, thereby obtaining an average of the characteristic parameter values of the original skin color pixels.
第一计算单元7041用于计算预设标准图像中标准肤色像素的红、绿和蓝三基色分量的像素值的标准平均值和原始图像中原始肤色像素的相应基色分量的像素值的平均值之间的差值。The first calculating unit 7041 is configured to calculate a standard average value of the pixel values of the red, green, and blue primary color components of the standard skin color pixel in the preset standard image and an average value of the pixel values of the corresponding primary color components of the original skin color pixel in the original image. The difference between the two.
获取单元7042用于获取各图像像素的红、绿和蓝三基色分量的像素值,得到各图像像素的特征参数值。The obtaining unit 7042 is configured to obtain pixel values of three primary color components of red, green, and blue of each image pixel, to obtain feature parameter values of each image pixel.
第二计算单元7043用于根据原始肤色像素的红、绿和蓝三基色分量的像素值的平均值,以及各图像像素的红、绿和蓝三基色分量的像素值,计算各图像像素的红、绿和蓝三基色分量的像素值的校正系数。The second calculating unit 7043 is configured to calculate the red color of each image pixel according to the average value of the pixel values of the three primary color components of the red, green, and blue color of the original skin color pixel, and the pixel values of the three primary color components of the red, green, and blue color of each image pixel. Correction coefficients for pixel values of the three primary color components of green, blue, and blue.
校正单元7044用于根据预设标准图像中标准肤色像素的红、绿和蓝三基色分量的像素值的标准平均值预和原始图像中原始肤色像素的相应基色分量的像素值的平均值之间的差值,以及各图像像素的红、绿和蓝三基色分量的像素值的校正系数,对各图像像素的红、绿和蓝三基色分量的像素值进行校正。The correcting unit 7044 is configured to pre-equalize the average value of the pixel values of the corresponding primary color components of the original skin color pixels in the original image according to a standard average value of the pixel values of the red, green, and blue primary color components of the standard skin color pixel in the preset standard image. The difference value, and the correction coefficient of the pixel values of the three primary color components of the red, green, and blue components of each image pixel, correct the pixel values of the three primary color components of the red, green, and blue color of each image pixel.
其中,校正单元7044根据上述公式一对原始图像的各图像像素的红、绿和蓝三基色分量的像素值的进行校正。具体地,以红色分量为例,在公式一中,C 1表示校正后的图像像素的红色分量的像素值,C 0表示校正前该图像像素的红色分量的像素值,ΔC表示标准肤色像素的红色分量的像素值的标准平均值与原始肤色像素的红色分量的像素值的平均值之间的差值,k表示该图像像素的校正系数。以此类推该图像像素的 绿色分量和蓝色分量的像素值的校正方式。通过上述方式,可以得到各图像像素校正后的各基色分量的像素值,实现对原始图像的校正。 The correcting unit 7044 corrects the pixel values of the three primary color components of the red, green, and blue color of each image pixel of the original image according to the above formula. Specifically, taking the red component as an example, in Equation 1, C 1 represents the pixel value of the red component of the corrected image pixel, C 0 represents the pixel value of the red component of the image pixel before correction, and ΔC represents the standard skin color pixel. The difference between the standard average of the pixel values of the red component and the average of the pixel values of the red component of the original skin tone pixel, k represents the correction factor for the image pixel. The manner in which the pixel values of the green and blue components of the image pixel are corrected is thus derived. In the above manner, the pixel values of the respective primary color components corrected for each image pixel can be obtained, and the original image can be corrected.
本实施例中,通过对原始图像的各图像像素的各基色分量的像素值进行校正,可以使得校正后的原始图像的明暗程度更接近自然情况,所显示的肤色与用户的自然肤色更接近,有利于减少图像过暗或过曝的现象,提高图像质量。In this embodiment, by correcting the pixel values of the respective primary color components of the image pixels of the original image, the brightness of the corrected original image can be made closer to the natural situation, and the displayed skin color is closer to the natural skin color of the user. It is beneficial to reduce the phenomenon of excessive darkness or overexposure of images and improve image quality.
在本发明另一实施例中,特征参数值包括第二颜色空间上的亮度值、第一色度值以及第二色度值,其中第二颜色空间为YUV(Luminance(亮度),Chroma(色度))颜色空间,为了便于描述,亮度值用Y值表示,第一色度值用U值表示,第二色度值用V值表示。In another embodiment of the present invention, the feature parameter value includes a luminance value, a first chrominance value, and a second chrominance value on the second color space, wherein the second color space is YUV (Luminance, Chroma) Degree)) Color space, for convenience of description, the brightness value is represented by a Y value, the first chromaticity value is represented by a U value, and the second chromaticity value is represented by a V value.
本实施例中,第一计算模块703用于获取原始图像中各原始肤色像素在第一颜色空间上的红、绿和蓝三基色分量的像素值,并根据原始图像中各原始肤色像素的红、绿和蓝三基色分量的像素值,计算各原始肤色像素在第二颜色空间上的亮度值、第一色度值、第二色度值,并计算所有原始肤色像素的亮度值的平均值、第一色度值的平均值以及第二色度值的平均值,从而得到原始肤色像素的特征参数值的平均值。In this embodiment, the first calculating module 703 is configured to obtain pixel values of three primary color components of the original color skin pixels in the first color space in the original image, and according to the red color of each original skin color pixel in the original image. And the pixel values of the three primary color components of green, blue, calculate the luminance value, the first chrominance value, and the second chrominance value of each original skin color pixel in the second color space, and calculate an average value of the luminance values of all the original skin color pixels. The average of the first chrominance values and the average of the second chrominance values, thereby obtaining an average of the characteristic parameter values of the original skin color pixels.
其中,可以根据上述公式四计算各原始肤色像素在YUV颜色空间上的Y值、U值以及V值。Wherein, the Y value, the U value, and the V value of each original skin color pixel in the YUV color space can be calculated according to the above formula 4.
第一计算单元7041用于计算标准肤色像素的亮度值、第一色度值、第二色度值的标准平均值和原始肤色像素的相应亮度值、第一色度值、第二色度值的平均值之间的差值。The first calculating unit 7041 is configured to calculate a brightness value of the standard skin color pixel, a first chromaticity value, a standard average value of the second chromaticity value, and a corresponding brightness value, a first chromaticity value, and a second chromaticity value of the original skin color pixel. The difference between the averages.
获取单元7042用于获取原始图像的各图像像素的亮度值、第一色度值以及第二色度值,从而得到原始图像的各图像像素的特征参数值。The obtaining unit 7042 is configured to acquire a luminance value, a first chrominance value, and a second chrominance value of each image pixel of the original image, thereby obtaining feature parameter values of each image pixel of the original image.
第二计算单元7043用于根据原始肤色像素的亮度值的平均值、第一色度值的平均值以及第二色度值的平均值,以及各图像像素的亮度 值、第一色度值以及第二色度值,计算各图像像素的亮度值、第一色度值以及第二色度值的校正系数。The second calculating unit 7043 is configured to calculate an average value of the brightness values of the original skin color pixels, an average value of the first color value, and an average value of the second color value, and a brightness value, a first color value, and a color value of each image pixel. The second chrominance value calculates a luminance coefficient of each image pixel, a first chrominance value, and a correction coefficient of the second chrominance value.
校正单元7044用于根据预设标准图像中标准肤色像素的亮度值、第一色度值、第二色度值的标准平均值和原始图像中原始肤色像素的相应亮度值、第一色度值、第二色度值的平均值之间的差值,以及各图像像素的亮度值、第一色度值以及第二色度值的校正系数,对各图像像素的亮度值、第一色度值以及第二色度值进行校正。The correcting unit 7044 is configured to: according to the brightness value of the standard skin color pixel in the preset standard image, the first chromaticity value, the standard average value of the second chromaticity value, and the corresponding brightness value of the original skin color pixel in the original image, the first chromaticity value a difference between the average values of the second chrominance values, and a luminance value of each image pixel, a first chrominance value, and a correction coefficient of the second chrominance value, a luminance value for each image pixel, and a first chrominance The value and the second chrominance value are corrected.
其中,校正单元7044其中,根据上述公式一对原始图像的各图像像素的Y值、U值以及V值进行校正。具体地,以Y值为例,在公式一中,C 1表示校正后的图像像素的Y值,C 0表示校正前该图像像素的Y值,ΔC表示标准肤色像素的Y值的标准平均值与原始肤色像素的Y值的平均值之间的差值,k表示该图像像素的校正系数。以此类推该图像像素的U值和V值的校正方式。通过上述方式,可以得到各图像像素校正后的Y值、U值以及V值,实现对原始图像的校正。 The correcting unit 7044 corrects the Y value, the U value, and the V value of each image pixel of the pair of original images according to the above formula. Specifically, taking the value of Y as an example, in Equation 1, C 1 represents the Y value of the corrected image pixel, C 0 represents the Y value of the image pixel before correction, and ΔC represents the standard average value of the Y value of the standard skin color pixel. The difference from the average of the Y values of the original skin color pixels, k represents the correction coefficient of the image pixels. The way in which the U and V values of the image pixels are corrected is thus derived. In the above manner, the corrected Y value, U value, and V value of each image pixel can be obtained, and the original image can be corrected.
其中,输出模块705具体用于根据校正后的各图像像素的Y值、U值以及V值,计算校正后各图像像素的红、绿和蓝三基色分量的像素值,从而得到RGB格式的原始图像,并输出校正后的RGB格式的原始图像。其中可以根据上述公式五计算校正后各图像像素的红、绿和蓝三基色分量的像素值。The output module 705 is specifically configured to calculate pixel values of the three primary color components of the red, green, and blue color of each image pixel according to the corrected Y value, U value, and V value of each image pixel, thereby obtaining the original RGB format. Image and output the original image in corrected RGB format. The pixel values of the three primary color components of the red, green, and blue colors of the corrected image pixels may be calculated according to the above formula 5.
本实施例中,通过对原始图像的各图像像素的Y值、U值和V值进行校正,可以进一步提高校正后的原始图像的图像质量,使得校正后的原始图像的明暗程度更接近自然情况,所显示的肤色与用户的自然肤色更接近。In this embodiment, by correcting the Y value, the U value, and the V value of each image pixel of the original image, the image quality of the corrected original image can be further improved, so that the brightness of the corrected original image is closer to the natural situation. The displayed skin tone is closer to the user's natural skin tone.
在本发明又一实施例中,可以仅对图像像素的Y值进行校正。与上述实施例主要不同在于,本实施例仅针对图像像素的Y值进行校正,而 不对U值和V值进行校正,在校正前后U值和V值不变,具体的校正方式与上述实施例相类似,在此不做一一赘述。In still another embodiment of the present invention, only the Y value of the image pixel may be corrected. The main difference from the above embodiment is that the present embodiment only corrects the Y value of the image pixel, and does not correct the U value and the V value. The U value and the V value are unchanged before and after the correction, and the specific correction manner is the same as the above embodiment. Similarly, I will not repeat them here.
在本发明又一实施例中,特征参数值包括第三颜色空间上的色调值、饱和度值和明度值,其中第三颜色空间为HSV(Hue(色调),Saturation(饱和度),Value(明度))颜色空间,为了便于描述,色调值用H值表示,饱和度值用S值表示,明度值用V值表示。In still another embodiment of the present invention, the feature parameter value includes a tone value, a saturation value, and a brightness value in a third color space, wherein the third color space is HSV (Hue, Saturation, Value ( Lightness)) The color space, for ease of description, the hue value is represented by the H value, the saturation value is represented by the S value, and the brightness value is represented by the V value.
本实施例中,第一计算模块703用于获取原始图像中各原始肤色像素在第一颜色空间上的红、绿和蓝三基色分量的像素值,并根据原始图像中各原始肤色像素的红、绿和蓝三基色分量的像素值,计算各原始肤色像素在第三颜色空间上的色调值、饱和度值和明度值,并计算所有原始肤色像素的色调值的平均值、饱和度值的平均值以及明度值的平均值,得到原始肤色像素的特征参数值的平均值。In this embodiment, the first calculating module 703 is configured to obtain pixel values of three primary color components of the original color skin pixels in the first color space in the original image, and according to the red color of each original skin color pixel in the original image. The pixel values of the three primary color components of green, blue, and blue, calculate the hue value, the saturation value, and the brightness value of each original skin color pixel in the third color space, and calculate the average value and the saturation value of the hue values of all the original skin color pixels. The average value and the average value of the brightness values are averaged to obtain the characteristic parameter values of the original skin color pixels.
其中,可以根据上述公式六、七、八计算各原始肤色像素在HSV颜色空间上的H值、S值以及V值。Wherein, the H value, the S value, and the V value of each original skin color pixel in the HSV color space may be calculated according to the above formulas 6, 7, and 8.
第一计算单元7041用于计算预设标准图像中标准肤色像素的色调值、饱和度值、明度值的标准平均值和原始图像中原始肤色像素的相应色调值、饱和度值、明度值的平均值之间的差值。The first calculating unit 7041 is configured to calculate a tone value, a saturation value, a standard average value of the brightness value of the standard skin color pixel in the preset standard image, and an average value of the corresponding tone value, the saturation value, and the brightness value of the original skin color pixel in the original image. The difference between the values.
获取单元7042用于获取原始图像的各图像像素的色调值、饱和度值以及明度值,得到原始图像的各图像像素的特征参数值。The obtaining unit 7042 is configured to acquire a tone value, a saturation value, and a brightness value of each image pixel of the original image to obtain a feature parameter value of each image pixel of the original image.
第二计算单元7043用于根据原始肤色像素的色调值的平均值、饱和度值的平均值以及明度值的平均值,以及各图像像素的色调值、饱和度值以及明度值,计算各图像像素的色调值、饱和度值以及明度值的校正系数。The second calculating unit 7043 is configured to calculate each image pixel according to an average value of the hue value of the original skin color pixel, an average value of the saturation value, and an average value of the brightness value, and a hue value, a saturation value, and a brightness value of each image pixel. The tonal value, the saturation value, and the correction factor for the brightness value.
校正单元7044用于根据预设标准图像中标准肤色像素的色调值、饱和度值和明度值的标准平均值和原始图像中原始肤色像素的相应色 调值、饱和度值和明度值的平均值之间的差值,以及各图像像素的色调值、饱和度值以及明度值的校正系数,对各图像像素的色调值、饱和度值以及明度值进行校正。The correcting unit 7044 is configured to: according to a standard average value of the hue value, the saturation value, and the brightness value of the standard skin color pixel in the preset standard image, and an average value of the corresponding hue value, the saturation value, and the brightness value of the original skin color pixel in the original image. The difference between the image, the tone value of each image pixel, the saturation value, and the correction factor of the brightness value are corrected for the tone value, the saturation value, and the brightness value of each image pixel.
其中,可以根据上述公式一对原始图像的各图像像素的H值、S值以及V值进行校正。具体地,以H值为例,在公式一中,C 1表示校正后的图像像素的H值,C 0表示校正前该图像像素的H值,ΔC表示标准肤色像素的H值的标准平均值与原始肤色像素的H值的平均值之间的差值,k表示该图像像素的校正系数。以此类推该图像像素的S值和V值的校正方式。通过上述方式,可以得到各图像像素校正后的H值、S值以及V值,实现对原始图像的校正。 Wherein, the H value, the S value, and the V value of each image pixel of the pair of original images can be corrected according to the above formula. Specifically, taking the value of H as an example, in Equation 1, C 1 represents the H value of the corrected image pixel, C 0 represents the H value of the image pixel before the correction, and ΔC represents the standard average value of the H value of the standard skin color pixel. The difference from the average of the H values of the original skin color pixels, k represents the correction coefficient of the image pixels. The way to correct the S and V values of the image pixels is thus derived. In the above manner, the corrected H value, S value, and V value of each image pixel can be obtained, and the original image can be corrected.
其中,输出模块705具体用于根据校正后的各图像像素的H值、S值以及V值,计算校正后各图像像素的红、绿和蓝三基色分量的像素值,从而得到RGB格式的原始图像,并输出校正后的RGB格式的原始图像。其中,可以根据上述公式九、十计算校正后各图像像素的红、绿和蓝三基色分量的像素值。The output module 705 is specifically configured to calculate pixel values of the three primary color components of the red, green, and blue color of each image pixel according to the corrected H value, S value, and V value of each image pixel, thereby obtaining the original RGB format. Image and output the original image in corrected RGB format. Wherein, the pixel values of the three primary color components of the red, green and blue of each corrected image pixel can be calculated according to the above formulas IX and IX.
本实施例中,通过对原始图像的各图像像素的H值、S值和V值进行校正,可以进一步提高校正后的原始图像的图像质量,使得校正后的原始图像的明暗程度更接近自然情况,所显示的肤色与用户的自然肤色更接近。In this embodiment, by correcting the H value, the S value, and the V value of each image pixel of the original image, the image quality of the corrected original image can be further improved, so that the brightness of the corrected original image is closer to the natural condition. The displayed skin tone is closer to the user's natural skin tone.
本发明实施例还提供一种终端,如图9所示,该终端可以包括射频(RF,Radio Frequency)电路901、包括有一个或一个以上计算机可读存储介质的存储器902、输入单元903、显示单元904、传感器905、音频电路906、无线保真(WiFi,W ireless Fidelity)模块907、包括有一个或者一个以上处理核心的处理器908、以及电源909等部件。本领域技术人员可以理解,图9中示出的终端结构并不构成对终端的限定,可以 包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。其中: The embodiment of the present invention further provides a terminal. As shown in FIG. 9, the terminal may include a radio frequency (RF) circuit 901, a memory 902 including one or more computer readable storage media, an input unit 903, and a display. unit 904, a sensor 905, an audio circuit 906, wireless fidelity (WiFi, W ireless fidelity) module 907, a processor comprises one or more processing cores 908, 909 and a power supply and other components. It will be understood by those skilled in the art that the terminal structure shown in FIG. 9 does not constitute a limitation to the terminal, and may include more or less components than those illustrated, or combine some components, or different component arrangements. among them:
RF电路901包括但不限于天线、至少一个放大器、调谐器、一个或多个振荡器、用户身份模块(SIM,Subscriber Identity Module)卡、收发信机、耦合器、低噪声放大器(LNA,Low Noise Amplifier)、双工器等。此外,RF电路901还可以通过无线通信与网络和其他设备通信。所述无线通信可以使用任一通信标准或协议,包括但不限于全球移动通讯系统(GSM,Global System of Mobile communication)、通用分组无线服务(GPRS,General Packet Radio Service)、码分多址(CDMA,Code Division Multiple Access)、宽带码分多址(WCDMA,Wideband Code Division Multiple Access)、长期演进(LTE,Long Term Evolution)、电子邮件、短消息服务(SMS,Short Messaging Service)等。The RF circuit 901 includes, but is not limited to, an antenna, at least one amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM), a transceiver, a coupler, and a low noise amplifier (LNA, Low Noise). Amplifier), duplexer, etc. In addition, the RF circuit 901 can also communicate with the network and other devices through wireless communication. The wireless communication may use any communication standard or protocol, including but not limited to Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), and Code Division Multiple Access (CDMA). , Code Division Multiple Access), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), e-mail, Short Messaging Service (SMS), and the like.
存储器902可用于存储软件程序以及模块,例如计算机可读指令,处理器908通过运行存储在存储器902的软件程序以及模块,从而执行各种功能应用以及数据处理,例如可以执行上述图1b,1c,2a,3,4,5,6所示的方法以及图7和图8所示的装置。存储器902可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据终端的使用所创建的数据(比如音频数据、电话本等)等。此外,存储器902可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。相应地,存储器902还可以包括存储器控制器,以提供处理器908和输入单元903对存储器902的访问。The memory 902 can be used to store software programs and modules, such as computer readable instructions. The processor 908 executes various functional applications and data processing by executing software programs and modules stored in the memory 902, for example, the above-described FIGS. 1b, 1c can be performed. The method shown in 2a, 3, 4, 5, and 6 and the apparatus shown in Figs. 7 and 8. The memory 902 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may be stored according to Data created by the use of the terminal (such as audio data, phone book, etc.). Moreover, memory 902 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, memory 902 may also include a memory controller to provide access to memory 902 by processor 908 and input unit 903.
输入单元903可用于接收输入的数字或字符信息,以及产生与用户设置以及功能控制有关的键盘、鼠标、操作杆、光学或者轨迹球信号输 入。具体地,在一个具体的实施例中,输入单元903可包括触敏表面以及其他输入设备。触敏表面,也称为触摸显示屏或者触控板,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触敏表面上或在触敏表面附近的操作),并根据预先设定的程式驱动相应的连接装置。在一些实例中,触敏表面可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器908,并能接收处理器908发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触敏表面。除了触敏表面,输入单元903还可以包括其他输入设备。具体地,其他输入设备可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种。 Input unit 903 can be used to receive input numeric or character information, as well as to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls. In particular, in one particular embodiment, input unit 903 can include a touch-sensitive surface as well as other input devices. Touch-sensitive surfaces, also known as touch screens or trackpads, collect touch operations on or near the user (such as the user using a finger, stylus, etc., any suitable object or accessory on a touch-sensitive surface or touch-sensitive Operation near the surface), and drive the corresponding connecting device according to a preset program. In some examples, the touch sensitive surface can include both portions of the touch detection device and the touch controller. Wherein, the touch detection device detects the touch orientation of the user, and detects a signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts the touch information into contact coordinates, and sends the touch information. The processor 908 is provided and can receive commands from the processor 908 and execute them. In addition, touch-sensitive surfaces can be implemented in a variety of types, including resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch-sensitive surface, the input unit 903 can also include other input devices. Specifically, other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.), trackballs, mice, joysticks, and the like.
显示单元904可用于显示由用户输入的信息或提供给用户的信息以及终端的各种图形用户接口,这些图形用户接口可以由图形、文本、图标、视频和其任意组合来构成。显示单元904可包括显示面板,在一些实例中,可以采用液晶显示器(LCD,Liquid Crystal Display)、有机发光二极管(OLED,Organic Light-Emitting Diode)等形式来配置显示面板。进一步的,触敏表面可覆盖显示面板,当触敏表面检测到在其上或附近的触摸操作后,传送给处理器908以确定触摸事件的类型,随后处理器908根据触摸事件的类型在显示面板上提供相应的视觉输出。虽然在图9中,触敏表面与显示面板是作为两个独立的部件来实现输入和输入功能,但是在某些实施例中,可以将触敏表面与显示面板集成而实现输入和输出功能。 Display unit 904 can be used to display information entered by the user or information provided to the user, as well as various graphical user interfaces of the terminal, which can be composed of graphics, text, icons, video, and any combination thereof. The display unit 904 can include a display panel. In some examples, the display panel can be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like. Further, the touch-sensitive surface can cover the display panel, and when the touch-sensitive surface detects a touch operation thereon or nearby, it is transmitted to the processor 908 to determine the type of the touch event, and then the processor 908 displays the type according to the type of the touch event. A corresponding visual output is provided on the panel. Although in FIG. 9, the touch-sensitive surface and display panel are implemented as two separate components to implement input and input functions, in some embodiments, the touch-sensitive surface can be integrated with the display panel to implement input and output functions.
终端还可包括至少一种传感器905,比如光传感器、运动传感器以 及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板的亮度,接近传感器可在终端移动到耳边时,关闭显示面板和/或背光。作为运动传感器的一种,重力加速度传感器可检测各个方向上(一般为三轴)加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换、相关游戏、磁力计姿态校准)、振动识别相关功能(比如计步器、敲击)等;至于终端还可配置的陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器,在此不再赘述。The terminal may also include at least one type of sensor 905, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel according to the brightness of the ambient light, and the proximity sensor may close the display panel and/or the backlight when the terminal moves to the ear. . As a kind of motion sensor, the gravity acceleration sensor can detect the magnitude of acceleration in all directions (usually three axes). When it is stationary, it can detect the magnitude and direction of gravity. It can be used to identify the gesture of the mobile phone (such as horizontal and vertical screen switching, related Game, magnetometer attitude calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for the terminal can also be configured with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors, no longer Narration.
音频电路906、扬声器,传声器可提供用户与终端之间的音频接口。音频电路906可将接收到的音频数据转换后的电信号,传输到扬声器,由扬声器转换为声音信号输出;另一方面,传声器将收集的声音信号转换为电信号,由音频电路906接收后转换为音频数据,再将音频数据输出处理器908处理后,经RF电路901以发送给比如另一终端,或者将音频数据输出至存储器902以便进一步处理。音频电路906还可能包括耳塞插孔,以提供外设耳机与终端的通信。The audio circuit 906, the speaker, and the microphone provide an audio interface between the user and the terminal. The audio circuit 906 can transmit the converted electrical signal of the audio data to the speaker, and convert it into a sound signal output by the speaker; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 906 and then converted. After the audio data is processed by the audio data output processor 908, it is sent to, for example, another terminal via the RF circuit 901, or the audio data is output to the memory 902 for further processing. The audio circuit 906 may also include an earbud jack to provide communication between the peripheral earphone and the terminal.
WiFi属于短距离无线传输技术,终端通过WiFi模块907可以帮助用户收发 电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图9示出了WiFi模块907,但是可以理解的是,其并不属于终端的必须构成,完全可以根据需要在不改变发明的本质的范围内而省略。 WiFi is a short-range wireless transmission technology, terminal through WiFi module 907 can help users send and receive email, browse the web and access streaming media and so on, which provides wireless broadband Internet access for users. Although FIG. 9 shows the WiFi module 907, it can be understood that it does not belong to the necessary configuration of the terminal, and may be omitted as needed within the scope of not changing the essence of the invention.
处理器908是终端的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在存储器902内的软件程序和/或模块,以及调用存储在存储器902内的数据,执行终端的各种功能和处理数据。在一些实例中,处理器908可包括一个或多个处理核心;优选的,处理器908可集成应用处理器和调制解调处理器,其中,应用处理器主 要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器908中。The processor 908 is the control center of the terminal, which connects various portions of the entire handset using various interfaces and lines, by executing or executing software programs and/or modules stored in the memory 902, and invoking data stored in the memory 902, executing Various functions of the terminal and processing data. In some examples, processor 908 can include one or more processing cores; preferably, processor 908 can integrate an application processor and a modem processor, wherein the application processor primarily processes an operating system, a user interface, and an application Etc. The modem processor primarily handles wireless communications. It will be appreciated that the above described modem processor may also not be integrated into the processor 908.
终端还包括给各个部件供电的电源909(比如电池),电源909可以通过电源管理系统与处理器908逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。电源909还可以包括一个或一个以上的直流或交流电源、再充电系统、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。The terminal also includes a power supply 909 (such as a battery) that supplies power to the various components. The power supply 909 can be logically coupled to the processor 908 through a power management system to manage functions such as charging, discharging, and power management through the power management system. The power supply 909 may also include any one or more of a DC or AC power source, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
尽管未示出,终端还可以包括摄像头、蓝牙模块等,在此不再赘述。具体在本实施例中,终端中的处理器908会按照如下的指令,将一个或一个以上的应用程序的进程对应的可执行文件加载到存储器902中,并由处理器908来运行存储在存储器902中的应用程序,从而实现各种功能:Although not shown, the terminal may further include a camera, a Bluetooth module, and the like, and details are not described herein again. Specifically, in this embodiment, the processor 908 in the terminal loads the executable file corresponding to the process of one or more applications into the memory 902 according to the following instructions, and is executed by the processor 908 to be stored in the memory. The application in 902 to implement various functions:
获取原始图像。原始图像为待处理的图像。获取的原始图像可以有多种,例如,获取原始图像具体可以包括:获取摄像头或其他图像采集设备实时获取的画面,以获取原始图像;或者,获取用户所选择的图片,以获取原始图像等。Get the original image. The original image is the image to be processed. The obtained original image may be various. For example, acquiring the original image may include: acquiring a picture acquired by a camera or other image capturing device in real time to obtain an original image; or acquiring a picture selected by the user to obtain an original image or the like.
对原始图像中选定区域的图像像素进行特征检测,以确定原始图像中所述选定区域的特征像素。在本申请一实施例中,该特征像素可以包括:肤色像素即人体皮肤像素。Feature detection is performed on image pixels of selected regions in the original image to determine feature pixels of the selected region in the original image. In an embodiment of the present application, the feature pixel may include: a skin color pixel, that is, a human skin pixel.
在进行肤色检测之前,对原始图像进行人脸检测,以确定原始图像的人脸区域。对原始图像的图像像素进行肤色检测具体为:对原始图像的人脸区域内的图像像素进行肤色检测,以确定原始图像中的原始肤色像素。当在原始图像中未检测到人脸时,则对整张原始图像的图像像素进行肤色检测,以确定原始图像的原始肤色像素。Before the skin color detection is performed, face detection is performed on the original image to determine the face area of the original image. The skin color detection of the image pixels of the original image is specifically: skin color detection is performed on image pixels in the face region of the original image to determine original skin color pixels in the original image. When a human face is not detected in the original image, skin color detection is performed on the image pixels of the entire original image to determine the original skin color pixel of the original image.
计算特征像素的特征参数值的平均值。The average of the characteristic parameter values of the feature pixels is calculated.
根据预设标准平均值和所述特征参数值的之间的差值,对原始图像的各图像像素的特征参数值进行校正,预设标准平均值包括:根据预设标准图像中的标准像素的特征参数值计算得到。Correcting a characteristic parameter value of each image pixel of the original image according to a difference between the preset standard average value and the characteristic parameter value, and the preset standard average value includes: according to a standard pixel in the preset standard image The characteristic parameter values are calculated.
其中,首先计算预设标准平均值与原始肤色像素的特征参数值的平均值之间的差值。该差值具体是指标准平均值减去原始肤色像素的特征参数值的平均值的差值。然后根据上述公式二、三计算各图像像素的校正系数,并根据公式一对原始图像的各图像像素的特征参数值。Wherein, the difference between the preset standard average value and the average value of the feature parameter values of the original skin color pixels is first calculated. The difference specifically refers to the difference between the standard average value minus the average value of the characteristic parameter values of the original skin color pixels. Then, the correction coefficient of each image pixel is calculated according to the above formulas 2 and 3, and the characteristic parameter values of each image pixel of the original image are calculated according to the formula.
输出校正后的原始图像。The corrected original image is output.
以上各个操作的具体实施可参见前面的实施例,在此不再赘述。For the specific implementation of the foregoing operations, refer to the foregoing embodiments, and details are not described herein again.
本申请实施例提供非易失性计算机可读存储介质,存储有计算机可读指令,可以使至少一个处理器执行上述方法和/或装置中的操作。The embodiments of the present application provide a non-transitory computer readable storage medium storing computer readable instructions that cause at least one processor to perform the operations in the methods and/or apparatus described above.
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:只读存储器(ROM,Read Only Memory)、随机存取记忆体(RAM,Random Access Memory)、磁盘或光盘等。A person skilled in the art may understand that all or part of the various steps of the foregoing embodiments may be performed by a program to instruct related hardware. The program may be stored in a computer readable storage medium, and the storage medium may include: Read Only Memory (ROM), Random Access Memory (RAM), disk or optical disk.
以上对本发明实施例所提供的一种图像处理方法、装置及存储介质进行了详细介绍,本文中应用了具体个例对本发明实施例的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明实施例的方法及其核心思想;同时,对于本领域的技术人员,依据本发明实施例的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明实施例的限制。The image processing method, device, and storage medium provided by the embodiments of the present invention are described in detail. The principles and implementation manners of the embodiments of the present invention are described in the specific examples. The description of the above embodiments is only used. To help understand the method and the core idea of the embodiments of the present invention; at the same time, for those skilled in the art, according to the idea of the embodiment of the present invention, there are some changes in the specific implementation manner and the application scope. The content of the present specification should not be construed as limiting the embodiments of the present invention.

Claims (19)

  1. 一种图像处理方法,应用于图像处理装置,其中,包括:An image processing method is applied to an image processing apparatus, including:
    获取原始图像;Get the original image;
    对所述原始图像中选定区域的图像像素进行特征检测,以确定所述原始图像中所述选定区域的特征像素;Performing feature detection on image pixels of selected regions in the original image to determine feature pixels of the selected region in the original image;
    计算所述特征像素的特征参数值的平均值;Calculating an average value of characteristic parameter values of the feature pixels;
    根据预设标准平均值与所述特征参数值的平均值之间的差值,对所述原始图像的各图像像素的特征参数值进行校正,所述预设标准平均值包括根据预设标准图像的标准特征像素的特征参数值计算得到的数值;Correcting a feature parameter value of each image pixel of the original image according to a difference between a preset standard average value and an average value of the feature parameter values, the preset standard average value including an image according to a preset standard The value of the characteristic parameter value of the standard feature pixel;
    输出校正后的原始图像。The corrected original image is output.
  2. 根据权利要求1所述的图像处理方法,其中,所述对原始图像中选定区域的图像像素进行特征检测,以确定所述原始图像中所述选定区域的特征像素,包括:The image processing method according to claim 1, wherein the performing feature detection on the image pixels of the selected area in the original image to determine the feature pixels of the selected area in the original image comprises:
    对原始图像中选定区域的图像像素进行肤色检测,以确定所述原始图像中所述选定区域的原始肤色像素;Performing skin color detection on image pixels of selected regions in the original image to determine original skin color pixels of the selected region in the original image;
    其中,所述预设标准平均值包括:根据预设标准图像的标准肤色像素的特征参数值计算得到的数值。The preset standard average value includes: a value calculated according to a characteristic parameter value of a standard skin color pixel of the preset standard image.
  3. 根据权利要求2所述的图像处理方法,其中,在对所述原始图像的图像像素进行肤色检测,以确定所述原始图像中的原始肤色像素之前,还包括:对所述原始图像进行人脸检测,以确定所述原始图像的人脸区域;The image processing method according to claim 2, wherein before performing skin color detection on the image pixels of the original image to determine an original skin color pixel in the original image, the method further comprises: performing a face on the original image Detecting to determine a face area of the original image;
    所述对所述原始图像中选定区域的图像像素进行肤色检测,以确定所述原始图像中所述选定区域的原始肤色像素,包括:对所述原始图像的人脸区域内的图像像素进行肤色检测,以确定所述原始图像中人脸区 域的原始肤色像素。Performing skin color detection on the image pixels of the selected area in the original image to determine original skin color pixels of the selected area in the original image, including: image pixels in a face area of the original image Skin color detection is performed to determine the original skin color pixels of the face region in the original image.
  4. 根据权利要求2所述的图像处理方法,其中,所述根据预设标准平均值与所述特征参数值的平均值之间的差值,对所述原始图像的各图像像素的特征参数值进行校正,包括:The image processing method according to claim 2, wherein said characteristic parameter values of respective image pixels of said original image are performed according to a difference between a preset standard average value and an average value of said characteristic parameter values Correction, including:
    计算预设标准平均值与所述特征像素的特征参数值的平均值之间的差值;Calculating a difference between a preset standard average value and an average value of the feature parameter values of the feature pixels;
    获取所述原始图像的各图像像素的特征参数值;Obtaining feature parameter values of each image pixel of the original image;
    根据所述特征像素的特征参数值的平均值和各图像像素的特征参数值,计算各图像像素的校正系数;Calculating a correction coefficient of each image pixel according to an average value of the feature parameter values of the feature pixel and a feature parameter value of each image pixel;
    根据所述差值以及各图像像素的校正系数,对各图像像素的特征参数值进行校正。The feature parameter values of the respective image pixels are corrected based on the difference and the correction coefficient of each image pixel.
  5. 根据权利要求4所述的图像处理方法,其中,所述根据所述特征像素的特征参数值的平均值和各图像像素的特征参数值,计算各图像像素的校正系数,包括:The image processing method according to claim 4, wherein the calculating a correction coefficient of each image pixel according to an average value of the feature parameter values of the feature pixels and a feature parameter value of each image pixel comprises:
    当所述图像像素的特征参数值小于或等于所述特征像素的特征参数值的平均值,所述图像像素的校正系数为所述图像像素的特征参数值与所述特征像素的特征参数值的平均值的比值;When the feature parameter value of the image pixel is less than or equal to an average value of the feature parameter values of the feature pixel, the correction coefficient of the image pixel is a feature parameter value of the image pixel and a feature parameter value of the feature pixel. The ratio of the average values;
    当所述图像像素的特征参数值大于所述特征像素的特征参数值的平均值,计算预设常数与所述图像像素的特征参数值之间的第一差值,以及计算所述预设常数与所述特征像素的特征参数值的平均值之间的第二差值,所述图像像素的校正系数为所述第一差值和所述第二差值的比值。Calculating a first difference between a preset constant and a feature parameter value of the image pixel, and calculating the preset constant when a feature parameter value of the image pixel is greater than an average value of a feature parameter value of the feature pixel And a second difference between the average value of the feature parameter values of the feature pixels, the correction coefficient of the image pixel being a ratio of the first difference value to the second difference value.
  6. 根据权利要求4所述的图像处理方法,其中,所述特征参数值包括的红、绿和蓝三基色分量的像素值;The image processing method according to claim 4, wherein said characteristic parameter value includes pixel values of three primary color components of red, green, and blue;
    所述计算所述特征像素的特征参数值的平均值,包括:获取原始图 像中各特征像素的红、绿和蓝三基色分量的像素值;计算原始图像中所有特征像素的红、绿和蓝三基色分量的像素值的平均值,得到特征像素的特征参数值的平均值;The calculating an average value of the feature parameter values of the feature pixel includes: acquiring pixel values of three primary color components of red, green, and blue of each feature pixel in the original image; calculating red, green, and blue of all feature pixels in the original image An average value of the pixel values of the three primary color components, and an average value of the characteristic parameter values of the feature pixels is obtained;
    所述计算预设标准平均值与所述特征像素的特征参数值的平均值之间的差值,包括:计算预设标准图像中标准肤色像素的红、绿和蓝三基色分量的像素值的标准平均值和所述特征像素的相应基色分量的像素值的平均值之间的差值;Calculating a difference between an average value of the preset standard and an average value of the feature parameter values of the feature pixel, comprising: calculating pixel values of three primary color components of red, green, and blue of the standard skin color pixel in the preset standard image a difference between a standard average value and an average value of pixel values of respective primary color components of the feature pixel;
    所述获取所述原始图像的各图像像素的特征参数值,包括:获取各图像像素的红、绿和蓝三基色分量的像素值,得到各图像像素的特征参数值;And acquiring the feature parameter values of each image pixel of the original image, comprising: acquiring pixel values of three primary color components of red, green, and blue of each image pixel, to obtain feature parameter values of each image pixel;
    所述根据所述特征像素的特征参数值的平均值和各图像像素的特征参数值,计算各图像像素的校正系数,包括:根据所述特征像素的红、绿和蓝三基色分量的像素值的平均值,以及各图像像素的红、绿和蓝三基色分量的像素值,计算各图像像素的红、绿和蓝三基色分量的像素值的校正系数;Calculating, according to an average value of the feature parameter values of the feature pixels and a feature parameter value of each image pixel, a correction coefficient of each image pixel, including: pixel values of three primary color components of red, green, and blue according to the feature pixel The average value, and the pixel values of the three primary color components of the red, green, and blue colors of each image pixel, and the correction coefficients of the pixel values of the three primary color components of the red, green, and blue components of each image pixel are calculated;
    所述根据所述差值以及各图像像素的校正系数,对各图像像素的特征参数值进行校正,包括:根据预设标准图像中标准肤色像素的红、绿和蓝三基色分量的像素值的标准平均值和所述特征像素的相应基色分量的像素值的平均值之间的差值,以及各图像像素的红、绿和蓝三基色分量的像素值的校正系数,对各图像像素的红、绿和蓝三基色分量的像素值进行校正。And correcting, according to the difference value and a correction coefficient of each image pixel, a feature parameter value of each image pixel, including: according to a pixel value of three primary color components of red, green, and blue of a standard skin color pixel in a preset standard image; a difference between a standard average value and an average value of pixel values of respective primary color components of the characteristic pixel, and a correction coefficient of pixel values of three primary color components of red, green, and blue of each image pixel, red for each image pixel The pixel values of the three primary colors of green, blue, and blue are corrected.
  7. 根据权利要求4所述的图像处理方法,其中,所述特征参数值包括亮度值、第一色度值以及第二色度值;The image processing method according to claim 4, wherein the feature parameter value comprises a luminance value, a first chrominance value, and a second chrominance value;
    所述计算所述特征像素的特征参数值的平均值,包括:获取原始图像中各特征像素在红、绿和蓝三基色分量的像素值;根据原始图像中各 特征像素的红、绿和蓝三基色分量的像素值,计算各特征像素在亮度值、第一色度值和第二色度值;计算所有特征像素的亮度值的平均值、第一色度值的平均值以及第二色度值的平均值,得到特征像素的特征参数值的平均值;The calculating an average value of the feature parameter values of the feature pixel includes: acquiring pixel values of the three primary color components of the red, green, and blue color of each feature pixel in the original image; according to the red, green, and blue color of each feature pixel in the original image Calculating a pixel value of the three primary color components, calculating a luminance value, a first chrominance value, and a second chrominance value; calculating an average value of the luminance values of all the characteristic pixels, an average value of the first chromaticity values, and a second color The average value of the degree values, and the average value of the characteristic parameter values of the feature pixels is obtained;
    所述计算预设标准平均值与所述特征像素的特征参数值的平均值之间的差值,包括:计算预设标准图像中标准肤色像素的亮度值、第一色度值和第二色度值的标准平均值和所述特征像素的相应亮度值、第一色度值和第二色度值的平均值之间的差值;Calculating a difference between the preset standard average value and an average value of the feature parameter values of the feature pixel, comprising: calculating a brightness value, a first chromaticity value, and a second color of a standard skin color pixel in the preset standard image a difference between a standard average of the degrees and a corresponding brightness value of the feature pixel, an average of the first chrominance value and the second chrominance value;
    所述获取所述原始图像的图像像素的特征参数值,包括:获取所述原始图像的各图像像素的亮度值、第一色度值以及第二色度值,得到所述原始图像的各图像像素的特征参数值;And acquiring the feature parameter value of the image pixel of the original image, comprising: acquiring a luminance value, a first chrominance value, and a second chrominance value of each image pixel of the original image to obtain each image of the original image The characteristic parameter value of the pixel;
    所述根据所述特征像素的特征参数值的平均值和各图像像素的特征参数值,计算各图像像素的校正系数,包括:根据所述特征像素的亮度值的平均值、第一色度值的平均值以及第二色度值的平均值,以及各图像像素的亮度值、第一色度值以及第二色度值,计算各图像像素的亮度值、第一色度值以及第二色度值的校正系数;And calculating, according to an average value of the feature parameter values of the feature pixels and a feature parameter value of each image pixel, a correction coefficient of each image pixel, including: an average value according to the brightness value of the feature pixel, and a first chromaticity value And an average value of the second chromaticity value, and a luminance value, a first chrominance value, and a second chrominance value of each image pixel, and calculating a luminance value, a first chrominance value, and a second color of each image pixel Correction factor of the degree value;
    所述根据所述差值以及各图像像素的校正系数,对各图像像素的特征参数值进行校正,包括:根据预设标准图像中标准肤色像素的亮度值、第一色度值和第二色度值的标准平均值和所述特征像素的相应亮度值、第一色度值和第二色度值的平均值之间的差值,以及各图像像素的亮度值、第一色度值以及第二色度值的校正系数,对各图像像素的亮度值、第一色度值以及第二色度值进行校正。And correcting, according to the difference value and a correction coefficient of each image pixel, a feature parameter value of each image pixel, comprising: according to a brightness value, a first chromaticity value, and a second color of a standard skin color pixel in a preset standard image a difference between a standard average of the degree values and a corresponding brightness value of the feature pixel, an average of the first chrominance value and the second chrominance value, and a brightness value, a first chromaticity value, and The correction coefficient of the second chrominance value corrects the luminance value, the first chrominance value, and the second chrominance value of each image pixel.
  8. 根据权利要求4所述的图像处理方法,其中,所述特征参数值包括亮度值;The image processing method according to claim 4, wherein said characteristic parameter value comprises a brightness value;
    所述计算所述特征像素的特征参数值的平均值,包括:获取原始图 像中各特征像素在红、绿和蓝三基色分量的像素值;根据原始图像中各特征像素的红、绿和蓝三基色分量的像素值,计算各特征像素在亮度值;计算所有特征像素的亮度值的平均值,得到特征像素的特征参数值的平均值;The calculating an average value of the feature parameter values of the feature pixel includes: acquiring pixel values of the three primary color components of the red, green, and blue color of each feature pixel in the original image; according to the red, green, and blue color of each feature pixel in the original image Calculating the luminance value of each characteristic pixel by calculating the pixel value of the three primary color components; calculating an average value of the luminance values of all the characteristic pixels to obtain an average value of the characteristic parameter values of the characteristic pixel;
    所述计算预设标准平均值与所述特征像素的特征参数值的平均值之间的差值,包括:计算预设标准图像中标准肤色像素的亮度值的标准平均值和所述特征像素的亮度值的平均值之间的差值;Calculating a difference between the preset standard average value and an average value of the feature parameter values of the feature pixels, comprising: calculating a standard average value of the brightness values of the standard skin color pixels in the preset standard image and the feature pixels The difference between the average values of the luminance values;
    所述获取所述原始图像的图像像素的特征参数值,包括:获取所述原始图像的各图像像素的亮度值,得到所述原始图像的各图像像素的特征参数值;And acquiring the feature parameter value of the image pixel of the original image, comprising: acquiring a brightness value of each image pixel of the original image, and obtaining a feature parameter value of each image pixel of the original image;
    所述根据所述特征像素的特征参数值的平均值和各图像像素的特征参数值,计算各图像像素的校正系数,包括:根据所述特征像素的亮度值的平均值以及各图像像素的亮度值,计算各图像像素的亮度值的校正系数;Calculating, according to an average value of the feature parameter values of the feature pixels and a feature parameter value of each image pixel, a correction coefficient of each image pixel, including: an average value according to the brightness value of the feature pixel and a brightness of each image pixel a value, a correction coefficient for calculating a luminance value of each image pixel;
    所述根据所述差值以及各图像像素的校正系数,对各图像像素的特征参数值进行校正,包括:根据预设标准图像中标准肤色像素的亮度值的标准平均值和所述特征像素的亮度值的平均值之间的差值,以及各图像像素的亮度值的校正系数,对各图像像素的亮度值进行校正。And correcting, according to the difference value and the correction coefficient of each image pixel, the feature parameter value of each image pixel, including: a standard average value of the brightness value of the standard skin color pixel in the preset standard image, and the feature pixel The difference between the average values of the luminance values and the correction coefficient of the luminance values of the respective image pixels correct the luminance values of the respective image pixels.
  9. 根据权利要求4所述的图像处理方法,其特征在于,所述特征参数值包括色调值、饱和度值以及明度值;The image processing method according to claim 4, wherein the feature parameter value comprises a tone value, a saturation value, and a brightness value;
    所述计算所述特征像素的特征参数值的平均值,包括:获取原始图像中各特征像素在红、绿和蓝三基色分量的像素值;根据原始图像中各特征像素的红、绿和蓝三基色分量的像素值,计算各特征像素在色调值、饱和度值和明度值;计算所有特征像素的色调值的平均值、饱和度值的平均值以及明度值的平均值,得到特征像素的特征参数值的平均值;The calculating an average value of the feature parameter values of the feature pixel includes: acquiring pixel values of the three primary color components of the red, green, and blue color of each feature pixel in the original image; according to the red, green, and blue color of each feature pixel in the original image Calculating the pixel value of the three primary color components, calculating the hue value, the saturation value, and the brightness value of each feature pixel; calculating the average value of the hue value of all the feature pixels, the average value of the saturation value, and the average value of the brightness value to obtain the feature pixel The average value of the characteristic parameter values;
    所述计算预设标准平均值与所述特征像素的特征参数值的平均值之间的差值,包括:计算预设标准图像中标准肤色像素的色调值、饱和度值和明度值的标准平均值和所述特征像素的相应色调值、饱和度值和明度值的平均值之间的差值;Calculating a difference between an average value of the preset standard and an average value of the feature parameter values of the feature pixel, comprising: calculating a standard average of the hue value, the saturation value, and the brightness value of the standard skin color pixel in the preset standard image a difference between a value and an average of a corresponding tone value, a saturation value, and a brightness value of the feature pixel;
    所述获取所述原始图像的图像像素的特征参数值,包括:获取所述原始图像的各图像像素的色调值、饱和度值以及明度值,得到所述原始图像的各图像像素的特征参数值;And acquiring the feature parameter value of the image pixel of the original image, comprising: acquiring a tone value, a saturation value, and a brightness value of each image pixel of the original image to obtain a feature parameter value of each image pixel of the original image. ;
    所述根据所述特征像素的特征参数值的平均值和各图像像素的特征参数值,计算各图像像素的校正系数,包括:根据所述特征像素的色调值的平均值、饱和度值的平均值以及明度值的平均值,以及各图像像素的色调值、饱和度值以及明度值,计算各图像像素的色调值、饱和度值以及明度值的校正系数;Calculating, according to an average value of the feature parameter values of the feature pixels and a feature parameter value of each image pixel, a correction coefficient of each image pixel, including: an average value of the tone values of the feature pixels, and an average of saturation values a value, an average value of the brightness value, and a tone value, a saturation value, and a brightness value of each image pixel, and a correction coefficient of a tone value, a saturation value, and a brightness value of each image pixel;
    所述根据所述差值以及各图像像素的校正系数,对各图像像素的特征参数值进行校正,包括:根据预设标准图像中标准肤色像素的色调值、饱和度值和明度值的标准平均值和所述特征像素的相应色调值、饱和度值和明度值的平均值之间的差值,以及各图像像素的色调值、饱和度值以及明度值的校正系数,对各图像像素的色调值、饱和度值以及明度值进行校正。And correcting, according to the difference value and a correction coefficient of each image pixel, a feature parameter value of each image pixel, including: a standard average of a tone value, a saturation value, and a brightness value of a standard skin color pixel according to a preset standard image a difference between a value and an average value of a corresponding tone value, a saturation value, and a brightness value of the feature pixel, and a tone value, a saturation value, and a correction coefficient of a brightness value of each image pixel, and a hue for each image pixel The value, saturation value, and brightness value are corrected.
  10. 根据权利要求1至9任一项所述的图像处理方法,其中,所述根据预设标准平均值与所述特征参数值的平均值之间的差值,对所述原始图像的图像像素的特征参数值进行校正之前,还包括:The image processing method according to any one of claims 1 to 9, wherein said image pixel of said original image is based on a difference between a preset standard average value and an average value of said feature parameter values Before the feature parameter values are corrected, it also includes:
    获取至少两个所述标准图像;Obtaining at least two of the standard images;
    对每个所述标准图像中选定区域的图像像素进行特征检测,以确定所述标准图像的标准特征像素;Performing feature detection on image pixels of selected regions in each of the standard images to determine standard feature pixels of the standard image;
    计算每个所述标准图像的标准特征像素的特征参数值的平均值;Calculating an average value of characteristic parameter values of standard feature pixels of each of the standard images;
    对所有所述标准图像的标准特征像素的特征参数值的平均值进行平均计算,得到所述预设标准平均值。The average of the characteristic parameter values of the standard feature pixels of all the standard images is averaged to obtain the preset standard average.
  11. 根据权利要求10所述的图像处理方法,其中,在对每个所述标准图像中选定区域的图像像素进行特征检测,以确定所述标准图像的标准特征像素之前,还包括:对每个所述标准图像进行人脸检测,以确定所述标准图像的人脸区域;The image processing method according to claim 10, wherein before the feature detection is performed on the image pixels of the selected area in each of the standard images to determine the standard feature pixels of the standard image, the method further comprises: Performing face detection on the standard image to determine a face area of the standard image;
    所述对每个所述标准图像中选定区域的图像像素进行特征检测,以确定所述标准图像的标准特征像素,包括:对所述标准图像的人脸区域内的图像像素进行肤色检测,以确定所述标准图像中的标准肤色像素。Performing feature detection on the image pixels of the selected area in each of the standard images to determine standard feature pixels of the standard image includes: performing skin color detection on image pixels in the face region of the standard image, A standard skin tone pixel in the standard image is determined.
  12. 一种图像处理装置,其中,所述装置包括处理器和存储器,所述存储器存储有计算机可读指令,可以使所述处理器:An image processing apparatus, wherein the apparatus includes a processor and a memory, the memory storing computer readable instructions that enable the processor to:
    获取原始图像;Get the original image;
    对所述原始图像中选定区域的图像像素进行肤色检测,以确定所述原始图像中所述选定区域的特征像素;Performing skin color detection on image pixels of selected regions in the original image to determine feature pixels of the selected region in the original image;
    计算所述特征像素的特征参数值的平均值;Calculating an average value of characteristic parameter values of the feature pixels;
    根据预设标准平均值与所述特征参数值的平均值之间的差值,对所述原始图像的各图像像素的特征参数值进行校正,所述预设标准平均值包括根据预设标准图像的标准特征像素的特征参数值计算得到的数值;Correcting a feature parameter value of each image pixel of the original image according to a difference between a preset standard average value and an average value of the feature parameter values, the preset standard average value including an image according to a preset standard The value of the characteristic parameter value of the standard feature pixel;
    输出校正后的原始图像。The corrected original image is output.
  13. 根据权利要求12所述的图像处理装置,其中,所述计算机可读指令可以使所述处理器:The image processing device according to claim 12, wherein said computer readable instructions are to cause said processor to:
    对原始图像中选定区域的图像像素进行肤色检测,以确定所述原始图像中所述选定区域的原始肤色像素;Performing skin color detection on image pixels of selected regions in the original image to determine original skin color pixels of the selected region in the original image;
    其中,所述预设标准平均值包括:根据预设标准图像的标准肤色像素的特征参数值计算得到的数值。The preset standard average value includes: a value calculated according to a characteristic parameter value of a standard skin color pixel of the preset standard image.
  14. 根据权利要求13所述的图像处理装置,其中,所述计算机可读指令可以使所述处理器;The image processing device according to claim 13, wherein said computer readable instructions are to cause said processor;
    对所述原始图像进行人脸检测,以确定所述原始图像的所述人脸区域;Performing face detection on the original image to determine the face region of the original image;
    对所述原始图像的人脸区域内的图像像素进行肤色检测,以确定所述原始图像中人脸区域的原始肤色像素。Skin color detection is performed on image pixels in the face region of the original image to determine original skin color pixels of the face region in the original image.
  15. 根据权利要求13所述的图像处理装置,其中,所述计算机可读指令可以使所述处理器:The image processing device according to claim 13, wherein said computer readable instructions are to cause said processor to:
    计算预设标准平均值与所述特征像素的特征参数值的平均值之间的差值;Calculating a difference between a preset standard average value and an average value of the feature parameter values of the feature pixels;
    获取所述原始图像的各图像像素的特征参数值;Obtaining feature parameter values of each image pixel of the original image;
    根据所述特征像素的特征参数值的平均值和各图像像素的特征参数值,计算各图像像素的校正系数;Calculating a correction coefficient of each image pixel according to an average value of the feature parameter values of the feature pixel and a feature parameter value of each image pixel;
    根据所述差值以及各图像像素的校正系数,对各图像像素的特征参数值进行校正。The feature parameter values of the respective image pixels are corrected based on the difference and the correction coefficient of each image pixel.
  16. 根据权利要求15所述的图像处理装置,其中,所述计算机可读指令可以使所述处理器:The image processing device according to claim 15, wherein said computer readable instructions are to cause said processor to:
    当所述图像像素的特征参数值小于或等于所述特征像素的特征参数值的平均值时,计算所述图像像素的特征参数值与所述特征像素的特征参数值的平均值的比值,得到所述图像像素的校正系数;When a characteristic parameter value of the image pixel is less than or equal to an average value of the feature parameter values of the feature pixel, calculating a ratio of a feature parameter value of the image pixel to an average value of the feature parameter value of the feature pixel, a correction coefficient of the image pixel;
    当所述图像像素的特征参数值大于所述特征像素的特征参数值的平均值时,计算预设常数与所述图像像素的特征参数值之间的第一差值,以及计算所述预设常数与所述特征像素的特征参数值的平均值之间的第二差值,并计算所述第一差值和所述第二差值的比值,得到所述图像像素的校正系数。Calculating a first difference between a preset constant and a feature parameter value of the image pixel, and calculating the preset when a feature parameter value of the image pixel is greater than an average value of a feature parameter value of the feature pixel And a second difference between the constant and the average value of the feature parameter values of the feature pixel, and calculating a ratio of the first difference value to the second difference value to obtain a correction coefficient of the image pixel.
  17. 根据权利要求12-16任一项所述的图像处理装置,其中,所述计算机可读指令可以使所述处理器:The image processing device according to any one of claims 12 to 16, wherein the computer readable instructions are to cause the processor to:
    获取至少两个所述标准图像;Obtaining at least two of the standard images;
    对每个所述标准图像中选定区域的图像像素进行特征检测,以确定所述标准图像的标准特征像素;Performing feature detection on image pixels of selected regions in each of the standard images to determine standard feature pixels of the standard image;
    计算每个所述标准图像的标准特征像素的特征参数值的平均值,并对所有所述标准图像的标准特征像素的特征参数值的平均值进行平均计算,得到标准平均值。An average value of the feature parameter values of the standard feature pixels of each of the standard images is calculated, and an average value of the feature parameter values of the standard feature pixels of all the standard images is averaged to obtain a standard average value.
  18. 根据权利要求17所述的图像处理装置,其中,所述计算机可读指令可以使所述处理器;The image processing device according to claim 17, wherein said computer readable instructions are to cause said processor;
    对每个所述标准图像进行人脸检测,以确定所述标准图像的人脸区域;Performing face detection on each of the standard images to determine a face region of the standard image;
    对所述标准图像的人脸区域内的图像像素进行肤色检测,以确定所述标准图像中的标准肤色像素。Skin color detection is performed on image pixels within the face region of the standard image to determine standard skin color pixels in the standard image.
  19. 一种非易失性计算机可读存储介质,存储有计算机可读指令,可以使至少一个处理器执行如权利要求1至11任一项所述的方法。A non-transitory computer readable storage medium storing computer readable instructions, which may cause at least one processor to perform the method of any one of claims 1 to 11.
PCT/CN2018/079073 2017-03-21 2018-03-15 Image processing method and device, and storage medium WO2018171493A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710171010.5 2017-03-21
CN201710171010.5A CN107038715B (en) 2017-03-21 2017-03-21 Image processing method and device

Publications (1)

Publication Number Publication Date
WO2018171493A1 true WO2018171493A1 (en) 2018-09-27

Family

ID=59534464

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/079073 WO2018171493A1 (en) 2017-03-21 2018-03-15 Image processing method and device, and storage medium

Country Status (2)

Country Link
CN (1) CN107038715B (en)
WO (1) WO2018171493A1 (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109377531A (en) * 2018-09-29 2019-02-22 努比亚技术有限公司 Image color cast method of adjustment, device, mobile terminal and readable storage medium storing program for executing
CN111047517A (en) * 2018-10-11 2020-04-21 展讯通信(上海)有限公司 Skin color adjusting method and device and readable storage medium
CN111583127A (en) * 2020-04-03 2020-08-25 浙江大华技术股份有限公司 Face skin color correction method and device, computer equipment and readable storage medium
CN113077378A (en) * 2021-03-31 2021-07-06 重庆长安汽车股份有限公司 Image processing and target identification method based on vehicle-mounted camera
CN113674225A (en) * 2021-07-30 2021-11-19 南京信息工程大学 Power equipment fault detection method based on convolutional neural network
CN114299069A (en) * 2022-03-08 2022-04-08 南方医科大学南方医院 Colorectal cancer collagen evaluation and prognosis prediction device and storage medium

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107038715B (en) * 2017-03-21 2022-03-08 腾讯科技(深圳)有限公司 Image processing method and device
CN107945107A (en) * 2017-11-30 2018-04-20 广东欧珀移动通信有限公司 Image processing method, device, computer-readable recording medium and electronic equipment
CN108366194B (en) * 2018-01-15 2021-03-05 维沃移动通信有限公司 Photographing method and mobile terminal
CN109167921B (en) * 2018-10-18 2020-10-20 北京小米移动软件有限公司 Shooting method, shooting device, shooting terminal and storage medium
CN110930335B (en) * 2019-11-27 2023-03-31 维沃移动通信有限公司 Image processing method and electronic equipment
CN111582046B (en) * 2020-04-15 2023-09-05 浙江大华技术股份有限公司 License plate image processing method and device
CN111541924B (en) * 2020-04-30 2022-12-23 海信视像科技股份有限公司 Display apparatus and display method
CN111986151A (en) * 2020-07-17 2020-11-24 北京瑞通科悦科技有限公司 Skin color detection method and device
CN116825038B (en) * 2023-07-05 2024-03-12 广州文石信息科技有限公司 Saturation adjusting method and device, storage medium and color ink screen equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080279467A1 (en) * 2007-05-10 2008-11-13 Microsoft Corporation Learning image enhancement
US20120257826A1 (en) * 2011-04-09 2012-10-11 Samsung Electronics Co., Ltd Color conversion apparatus and method thereof
CN104156915A (en) * 2014-07-23 2014-11-19 小米科技有限责任公司 Skin color adjusting method and device
CN105608677A (en) * 2015-12-28 2016-05-25 成都品果科技有限公司 Image skin color beautifying method and system under any lighting conditions
CN106060402A (en) * 2016-07-06 2016-10-26 北京奇虎科技有限公司 Image data processing method and device, and mobile terminal
CN107038715A (en) * 2017-03-21 2017-08-11 腾讯科技(深圳)有限公司 A kind of image processing method and device

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103456032B (en) * 2013-08-19 2015-10-07 北京京东尚科信息技术有限公司 A kind of method and apparatus processing virtual fitting model image
CN105516585B (en) * 2015-11-30 2019-08-16 努比亚技术有限公司 A kind of device and method of the adjust automatically colour of skin
CN106156730B (en) * 2016-06-30 2019-03-15 腾讯科技(深圳)有限公司 A kind of synthetic method and device of facial image
CN106101547A (en) * 2016-07-06 2016-11-09 北京奇虎科技有限公司 The processing method of a kind of view data, device and mobile terminal
CN106296617B (en) * 2016-08-22 2019-03-05 腾讯科技(深圳)有限公司 The processing method and processing device of facial image

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080279467A1 (en) * 2007-05-10 2008-11-13 Microsoft Corporation Learning image enhancement
US20120257826A1 (en) * 2011-04-09 2012-10-11 Samsung Electronics Co., Ltd Color conversion apparatus and method thereof
CN104156915A (en) * 2014-07-23 2014-11-19 小米科技有限责任公司 Skin color adjusting method and device
CN105608677A (en) * 2015-12-28 2016-05-25 成都品果科技有限公司 Image skin color beautifying method and system under any lighting conditions
CN106060402A (en) * 2016-07-06 2016-10-26 北京奇虎科技有限公司 Image data processing method and device, and mobile terminal
CN107038715A (en) * 2017-03-21 2017-08-11 腾讯科技(深圳)有限公司 A kind of image processing method and device

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109377531A (en) * 2018-09-29 2019-02-22 努比亚技术有限公司 Image color cast method of adjustment, device, mobile terminal and readable storage medium storing program for executing
CN111047517A (en) * 2018-10-11 2020-04-21 展讯通信(上海)有限公司 Skin color adjusting method and device and readable storage medium
CN111583127A (en) * 2020-04-03 2020-08-25 浙江大华技术股份有限公司 Face skin color correction method and device, computer equipment and readable storage medium
CN111583127B (en) * 2020-04-03 2023-08-15 浙江大华技术股份有限公司 Face skin color correction method, device, computer equipment and readable storage medium
CN113077378A (en) * 2021-03-31 2021-07-06 重庆长安汽车股份有限公司 Image processing and target identification method based on vehicle-mounted camera
CN113077378B (en) * 2021-03-31 2024-02-09 重庆长安汽车股份有限公司 Image processing and target identification method based on vehicle-mounted camera
CN113674225A (en) * 2021-07-30 2021-11-19 南京信息工程大学 Power equipment fault detection method based on convolutional neural network
CN114299069A (en) * 2022-03-08 2022-04-08 南方医科大学南方医院 Colorectal cancer collagen evaluation and prognosis prediction device and storage medium
CN114299069B (en) * 2022-03-08 2022-05-13 南方医科大学南方医院 Colorectal cancer collagen evaluation and prognosis prediction device and storage medium

Also Published As

Publication number Publication date
CN107038715B (en) 2022-03-08
CN107038715A (en) 2017-08-11

Similar Documents

Publication Publication Date Title
WO2018171493A1 (en) Image processing method and device, and storage medium
TWI658433B (en) Method and device of image blurring, computer reading storage medium and computer equipment
CN109191410B (en) Face image fusion method and device and storage medium
WO2017071219A1 (en) Method for detecting skin region and device for detecting skin region
CN107438163B (en) Photographing method, terminal and computer readable storage medium
CN107093418B (en) Screen display method, computer equipment and storage medium
CN107302663B (en) Image brightness adjusting method, terminal and computer readable storage medium
WO2018137267A1 (en) Image processing method and terminal apparatus
WO2019091486A1 (en) Photographing processing method and device, terminal, and storage medium
TW201903713A (en) Image processing method, device, computer readable storage medium and mobile terminal
CN107580209B (en) Photographing imaging method and device of mobile terminal
CN108111754B (en) Method for determining image acquisition mode and mobile terminal
CN109688322B (en) Method and device for generating high dynamic range image and mobile terminal
CN109462745B (en) White balance processing method and mobile terminal
CN108200352B (en) Method, terminal and storage medium for adjusting picture brightness
CN108280813A (en) A kind of image processing method, terminal and computer readable storage medium
CN107705247B (en) Image saturation adjusting method, terminal and storage medium
WO2020134789A1 (en) Mobile terminal and method for controlling on and off of screen, and computer storage medium
CN111625213B (en) Picture display method, device and storage medium
WO2023240444A1 (en) Image processing method, apparatus and storage medium
CN109819166B (en) Image processing method and electronic equipment
CN109727212B (en) Image processing method and mobile terminal
CN109104578B (en) Image processing method and mobile terminal
CN107817963B (en) Image display method, mobile terminal and computer readable storage medium
CN112330564B (en) Image processing method, device, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18771392

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18771392

Country of ref document: EP

Kind code of ref document: A1