CN117541525A - Image processing method, apparatus, electronic device, and computer-readable storage medium - Google Patents

Image processing method, apparatus, electronic device, and computer-readable storage medium Download PDF

Info

Publication number
CN117541525A
CN117541525A CN202311794162.2A CN202311794162A CN117541525A CN 117541525 A CN117541525 A CN 117541525A CN 202311794162 A CN202311794162 A CN 202311794162A CN 117541525 A CN117541525 A CN 117541525A
Authority
CN
China
Prior art keywords
image
brightness
area
processing
portrait
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311794162.2A
Other languages
Chinese (zh)
Inventor
何慕威
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN202311794162.2A priority Critical patent/CN117541525A/en
Publication of CN117541525A publication Critical patent/CN117541525A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration using two or more images, e.g. averaging or subtraction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20212Image combination
    • G06T2207/20221Image fusion; Image merging

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)

Abstract

The present application relates to an image processing method, an apparatus, an electronic device, a storage medium, and a computer program product. The method comprises the following steps: performing first brightness processing on the first image based on brightness information of the first image to obtain a second image; performing second brightness processing on the first image based on brightness information of a portrait area in the first image to obtain a third image; and generating a target image based on the background area in the second image and the portrait area in the third image. By adopting the method, the accuracy of image processing can be improved.

Description

Image processing method, apparatus, electronic device, and computer-readable storage medium
Technical Field
The present invention relates to the field of image (Camera Technology) technology, and in particular, to an image processing method, an image processing device, an electronic device, and a computer readable storage medium.
Background
With the development of image technology, the requirements of users on images are higher and higher, and various image processing technologies such as a beautifying technology, an HDR (High Dynamic Range Imaging ) technology and the like are presented; the electronic device adopts various image processing technologies and can generate images meeting the requirements of users.
In a conventional image processing method, the whole image is generally processed by uniformly performing global brightness and contrast, so that the brightness and contrast of the whole image are at a proper level. However, the conventional image processing method has a problem in that the image processing is inaccurate.
Disclosure of Invention
Embodiments of the present application provide an image processing method, apparatus, electronic device, computer readable storage medium, and computer program product, which can improve accuracy of image processing.
In a first aspect, the present application provides an image processing method. The method comprises the following steps:
performing first brightness processing on the first image based on brightness information of the first image to obtain a second image;
performing second brightness processing on the first image based on brightness information of a portrait area in the first image to obtain a third image;
and generating a target image based on the background area in the second image and the portrait area in the third image.
In a second aspect, the present application also provides an image processing apparatus. The device comprises:
the brightness processing module is used for carrying out first brightness processing on the first image based on brightness information of the first image to obtain a second image;
The brightness processing module is further used for performing second brightness processing on the first image based on brightness information of a human image area in the first image to obtain a third image;
and the fusion module is used for generating a target image based on the background area in the second image and the portrait area in the third image.
In a third aspect, the present application also provides an electronic device. The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor executes the computer program to realize the following steps:
performing first brightness processing on the first image based on brightness information of the first image to obtain a second image;
performing second brightness processing on the first image based on brightness information of a portrait area in the first image to obtain a third image;
and generating a target image based on the background area in the second image and the portrait area in the third image.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
Performing first brightness processing on the first image based on brightness information of the first image to obtain a second image;
performing second brightness processing on the first image based on brightness information of a portrait area in the first image to obtain a third image;
and generating a target image based on the background area in the second image and the portrait area in the third image.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, implements the steps of:
performing first brightness processing on the first image based on brightness information of the first image to obtain a second image;
performing second brightness processing on the first image based on brightness information of a portrait area in the first image to obtain a third image;
and generating a target image based on the background area in the second image and the portrait area in the third image.
The image processing method, the image processing device, the electronic equipment, the computer readable storage medium and the computer program product perform first brightness processing on the first image based on brightness information of the first image to obtain a second image; performing second brightness processing on the first image based on brightness information of a portrait area in the first image to obtain a third image; that is, the second image is obtained by performing the first luminance processing based on the luminance information of the entire first image, the background area in the second image comprehensively considers the luminance information of the entire first image, and the third image is obtained by performing the second luminance processing based on the luminance information of the portrait area of the first image, so that the portrait area of the third image more meets the luminance requirement of the portrait, and then the target image can be generated more accurately based on the background area in the second image and the portrait area in the third image.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of an image processing method in one embodiment;
FIG. 2 is a flowchart of a step of performing a first luminance processing on a first image based on a target luminance region to obtain a second image in one embodiment;
FIG. 3 is a flow chart of fusing a second image, a third image, and a fourth image in one embodiment;
FIG. 4 is a flow chart of contrast enhancement of high frequency information in one embodiment;
FIG. 5 is a flow chart of contrast enhancement of a portrait region in one embodiment;
FIG. 6 is a flow chart of luminance processing for a face region and a face region, respectively, in one embodiment;
FIG. 7 is a flowchart of an image processing method in another embodiment;
FIG. 8 is a block diagram showing the structure of an image processing apparatus in one embodiment;
Fig. 9 is an internal structural diagram of an electronic device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
In one embodiment, as shown in fig. 1, an image processing method is provided, and this embodiment is illustrated by applying the method to an electronic device, which may be a terminal or a server; it will be appreciated that the method may also be applied to a system comprising a terminal and a server and implemented by interaction of the terminal and the server. The terminal can be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things equipment and portable wearable equipment, and the internet of things equipment can be smart speakers, smart televisions, smart air conditioners, smart vehicle-mounted equipment, smart automobiles and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server may be implemented as a stand-alone server or as a server cluster composed of a plurality of servers.
In this embodiment, the image processing method includes the steps of:
step S102, based on the brightness information of the first image, performing first brightness processing on the first image to obtain a second image.
The first image may be an original image, an HDR image, a normal photographed image, or the like, but is not limited thereto. The first image includes a foreground region and a background region, the foreground region being a portrait region.
The luminance information of the first image may be luminance information of a target luminance area in the first image, pixel values of respective pixels, or the like, without being limited thereto. The first luminance processing refers to luminance processing of the first image based on luminance information of the first image.
Optionally, the electronic device performs a first brightness process on the background area in the first image based on the brightness information of the first image to obtain a background area after the first brightness process; and generating a second image based on the background area and the portrait area after the first brightness processing.
Optionally, the electronic device determines a first brightness processing mode based on brightness information of the first image, and performs first brightness processing on the first image by using the first brightness processing method to obtain the second image. The first brightness processing mode comprises a brightness increasing processing mode or a brightness decreasing processing mode.
Step S104, based on the brightness information of the image area in the first image, performing second brightness processing on the first image to obtain a third image.
Wherein the portrait area is an area including a portrait. Optionally, the portrait region includes a face region. The second luminance processing refers to luminance processing of the first image based on luminance information of the portrait area.
Optionally, the electronic device determines a portrait area in the first image; and acquiring brightness information of a portrait area in the first image.
Optionally, the electronic device determines the portrait region from the first image through a portrait mask drawing. Wherein, the portrait mask drawing is obtained by an image obtaining device.
Optionally, the electronic device multiplies the first image and the portrait mask drawing to obtain a portrait area in the first image.
Optionally, the electronic device obtains each pixel value of the portrait area in the first image; luminance information of the portrait region is determined based on the respective pixel values. It will be appreciated that the pixel value of a pixel characterizes the luminance of that pixel, and that pixel value and luminance of the pixel are positively correlated.
In an alternative embodiment, the electronic device calculates an average value of the values of the pixels in the portrait area, and takes the average value as the brightness of the portrait area. In another alternative embodiment, the electronic device counts pixel values of each pixel in the portrait area, determines a median, and uses the median as the brightness of the portrait area. In other alternative embodiments, the electronic device may determine the brightness of the portrait area in other ways, which are not limited herein.
Optionally, the electronic device performs brightness enhancement processing on the first image based on brightness information of the image area in the first image, so as to obtain a third image. It can be appreciated that, in the image including the portrait area, the brightness of the portrait area is improved, so that the portrait area better meets the requirements of users.
Step S106, generating a target image based on the background area in the second image and the portrait area in the third image.
It will be appreciated that the second image includes a background region and a portrait region and the third image includes a background region and a portrait region.
Optionally, the electronic device acquires a background area in the second image and a portrait area in the third image, and splices the background area in the second image and the portrait area in the third image to generate the target image.
Optionally, the electronic device acquires a background mask map, and acquires a background region in the second image based on the background mask map and the second image. Optionally, the electronic device multiplies the background mask map and the second image to obtain a background region in the second image.
Optionally, the electronic device acquires a portrait mask drawing, and acquires a portrait region in the third image based on the portrait mask drawing and the third image. Optionally, the electronic device multiplies the portrait mask drawing and the third image to obtain a portrait area in the third image.
The image processing method comprises the steps of performing first brightness processing on a first image based on brightness information of the first image to obtain a second image; performing second brightness processing on the first image based on brightness information of a portrait area in the first image to obtain a third image; that is, the second image is obtained by performing the first luminance processing based on the luminance information of the entire first image, the background area in the second image comprehensively considers the luminance information of the entire first image, and the third image is obtained by performing the second luminance processing based on the luminance information of the portrait area of the first image, so that the portrait area of the third image more meets the luminance requirement of the portrait, and then the target image can be generated more accurately based on the background area in the second image and the portrait area in the third image.
In one embodiment, performing a first luminance process on a first image based on luminance information of the first image to obtain a second image includes: acquiring pixel values of pixels in a first image; determining a target luminance region of the first image based on pixel values of the respective pixels; the pixel values of the pixels in the target brightness region are all smaller than the pixel threshold value; and carrying out first brightness processing on the first image based on the target brightness area to obtain a second image.
The pixel threshold may be set as needed. The pixel values of the pixels in the target luminance area are all smaller than the pixel threshold, i.e. the target luminance area may be a dark area.
Optionally, the electronic device determines a size of the target luminance region; and performing first brightness processing on the first image based on the size of the target brightness area to obtain a second image.
Optionally, as shown in fig. 2, performing a first brightness process on the first image based on the target brightness region to obtain a second image, including: if the size of the target brightness area is smaller than the size threshold, performing brightness reduction processing on the first image to obtain a second image; and if the size of the target brightness area is larger than or equal to the size threshold value, performing brightness improvement processing on the first image to obtain a second image.
Wherein the size threshold may be set as desired. The size threshold may be an area threshold, a pixel number threshold, an area ratio threshold, or a pixel number ratio threshold, etc. The size of the target luminance region may include the area of the target luminance region, the number of pixels within the target luminance region, and the like.
Optionally, the electronic device traverses pixel values of each pixel of the first image, counts a histogram of each pixel, and determines a number of pixels from each pixel value for which the pixel value is less than a pixel threshold.
Alternatively, the electronic device may perform normalization processing on the pixel values of the pixels in the first image, and determine the number of pixels whose pixel values are smaller than the pixel threshold value from the pixel values after the normalization processing. Wherein the range of pixel values is in (0-1), the pixel threshold may be 0.3.
The electronic device determines the size of the target luminance area using the following formula:
wherein,in order to be a value of a pixel,for the width of the first image, height is the height of the first image,is the size of the target luminance area.
Optionally, if the area of the target brightness area is smaller than the area threshold, performing brightness reduction processing on the first image to obtain a second image; and if the area of the target brightness area is larger than or equal to the area threshold value, performing brightness improvement processing on the first image to obtain a second image.
Optionally, if the area ratio corresponding to the target brightness area is smaller than the area threshold ratio, performing brightness reduction processing on the first image to obtain a second image; and if the area ratio corresponding to the target brightness area is greater than or equal to the area threshold ratio, performing brightness improvement processing on the first image to obtain a second image. Wherein the area ratio corresponding to the target luminance area is the ratio of the area of the target luminance area to the area of the first image.
Optionally, if the number of pixels in the target brightness area is smaller than the threshold value of the number of pixels, performing brightness reduction processing on the first image to obtain a second image; and if the pixel number of the target brightness area is greater than or equal to the pixel number threshold value, performing brightness improvement processing on the first image to obtain a second image.
Optionally, if the pixel number proportion corresponding to the target brightness region is smaller than the pixel number proportion threshold, performing brightness reduction processing on the first image to obtain a second image; and if the pixel quantity proportion corresponding to the target brightness region is greater than or equal to the pixel quantity proportion threshold value, performing brightness improvement processing on the first image to obtain a second image. The proportion of the number of pixels corresponding to the target brightness region is the proportion of the number of pixels of the target brightness region to the number of pixels of the first image.
Optionally, the electronic device performs the brightness reduction processing on the first image using the following formula:
wherein,is the pixel value of the pixel of the second image,is the pixel value of the pixel of the first image,is a luminance reduction parameter, and can be obtained through experiments.
Optionally, the electronic device performs brightness enhancement processing on the first image using the following formula:
Wherein,is the pixel value of the pixel of the second image,is the pixel value of the pixel of the first image,is a brightness improvement parameter, and can be obtained through experiments.
In this embodiment, the electronic device determines, based on pixel values of pixels in the first image, a target luminance area of the first image, where pixel values of pixels in the target luminance area are all less than a pixel threshold; then, based on the target luminance region, the first luminance processing can be accurately performed on the first image, resulting in the second image. Further, if the size of the target brightness area is smaller than the size threshold, performing brightness reduction processing on the first image to obtain a second image; if the size of the target brightness region is greater than or equal to the size threshold, brightness enhancement processing is performed on the first image to obtain a second image, that is, according to the size of the target brightness region, brightness enhancement processing or brightness reduction processing can be performed on the first image more accurately.
In one embodiment, performing a second luminance process on the first image based on luminance information of a portrait area in the first image to obtain a third image includes: if the brightness of the portrait area in the first image is smaller than the brightness threshold value, brightness improvement processing is carried out on the first image, and a third image is obtained; and if the brightness of the portrait area in the first image is greater than or equal to the brightness threshold value, the first image is taken as a third image.
Wherein the brightness threshold may be set as desired.
Optionally, if the brightness of the portrait area in the first image is less than the brightness threshold, which indicates that the brightness of the portrait area is darker, performing brightness enhancement processing (Global Tonemmaping, global tone mapping) on the first image to obtain a third image; if the brightness of the portrait area in the first image is greater than or equal to the brightness threshold, which indicates that the brightness of the portrait area is brighter, and the user requirement is met, the first image or the portrait area is not required to be subjected to the brightness enhancement treatment, and the first image is directly used as the third image.
Optionally, the electronic device performs the second brightness processing on the first image using the following formula:
wherein,is the pixel value of the pixel in the third image,is the pixel value of a pixel in the first image,is a parameter of the lifting and lightening of the glass,is the brightness of the portrait area.
In this embodiment, if the brightness of the portrait area in the first image is less than the brightness threshold, the brightness enhancement processing is performed on the first image to obtain the third image, and if the brightness of the portrait area in the first image is greater than or equal to the brightness threshold, the first image is used as the third image, that is, based on the brightness of the portrait area, the brightness enhancement processing can be performed on the first image more accurately or the first image can be directly used as the third image.
In one embodiment, after performing the second brightness processing on the first image based on the brightness information of the image area in the first image to obtain the third image, the method further includes: performing third brightness processing on the third image based on the brightness information of the face area in the third image to obtain a fourth image; generating a target image based on the background region in the second image and the portrait region in the third image, comprising: the target image is generated based on the background region in the second image, the portrait region in the third image, and the face region in the fourth image.
The third brightness processing refers to brightness processing of the third image based on brightness information of a face region in the third image. The brightness of the face area in the fourth image is higher than the brightness of the face area in the third image.
Optionally, the electronic device performs a third brightness process on the third image using the following formula:
wherein,is the pixel value of the pixel in the fourth image,is the pixel value of the pixel in the third image,is the brightness processing parameter of the face area and is realized by realityAnd (5) checking to obtain the product. By way of example only, and not by way of limitation,
optionally, the electronic device acquires a background area in the second image, a portrait area in the third image and a face area in the fourth image, and splices the background area in the second image, the portrait area in the third image and the face area in the fourth image to generate the target image.
Optionally, the electronic device acquires a face mask map, and acquires a face region in the fourth image based on the face mask map and the fourth image. Optionally, the electronic device multiplies the face mask map and the fourth image to obtain a face region in the fourth image.
As shown in fig. 3, the electronic device generates a fused image based on the second image, the third image, and the portrait mask drawing; and generating a target image based on the fusion image, the fourth image and the face mask image.
Optionally, the electronic device performs guide filtering on the portrait mask drawing and the face mask drawing respectively to obtain a portrait mask drawing after guide filtering and a face mask drawing after guide filtering; generating a fusion image based on the second image, the third image and the guided and filtered portrait mask drawing; and generating a target image based on the fusion image, the fourth image and the face mask image after the guide filtering. . Wherein, the guide image adopted by the guide filtering is an input image.
Optionally, the electronic device multiplies the third image and the portrait mask drawing to obtain a portrait area; multiplying the second image with the non-portrait mask drawing to obtain a background area; and splicing the portrait area and the background area to obtain a fusion image.
The electronic device generates a fused image using the following formula:
wherein,is a fused image of the two images,is a second image of the object to be imaged,is a third image of the object,is a portrait mask drawing.
Optionally, the electronic device multiplies the fourth image and the face mask map to obtain a face region; multiplying the fusion image with the non-face mask image to obtain a non-face region; and splicing the face area and the non-face area to obtain a target image.
The electronic device generates a target image using the following formula:
wherein,is an image of the object to be imaged,is a fused image of the two images,is a fourth image of the object,is a mask image of the human face.
In this embodiment, the electronic device performs the third luminance processing on the third image based on the luminance information of the face region in the third image to obtain the fourth image, and then, based on the background region in the second image, the portrait region in the third image, and the face region in the fourth image, the target image may be generated more accurately.
In one embodiment, the method further comprises: contrast enhancement is carried out on the high-frequency information in the input image, and the enhanced high-frequency information is obtained; a first image is generated based on the enhanced high frequency information and the low frequency information of the input image.
The input image may be an original image, an HDR image, a normal photographed image, or the like, but is not limited thereto. The input image includes a foreground region and a background region, the foreground region being a portrait region.
Optionally, as shown in fig. 4, the electronic device performs guided filtering on the input image to obtain low-frequency information of the input image; obtaining high-frequency information of the input image based on the input image and the low-frequency information; a first image is generated based on the enhanced high frequency information and the low frequency information of the input image.
The high-frequency information refers to a portion where the image changes drastically, that is, an edge (contour) of the image or noise and detail portion. The low frequency information refers to the area of the image where the brightness or gray value changes slowly, i.e. the area of the image where the large piece is flat, describes the main part of the image and is a comprehensive measure of the intensity of the whole image. Guided Filter (Guided Filter) is an image filtering technique that filters an input image P with a guide map G so that the final output image is substantially similar to the input image P, but the texture portion is similar to the guide map G. The result of the guided filtering is low frequency information of the input image.
Optionally, the electronic device subtracts the low frequency information from the input image to obtain high frequency information of the input image:
wherein,is an input image of the person,is the information of the low frequency of the signal,is high frequency information.
Optionally, the electronic device multiplies the high-frequency information in the input image by a first contrast enhancement coefficient to obtain enhanced high-frequency information; and adding the enhanced high-frequency information and the enhanced low-frequency information to obtain a first image. Wherein the contrast enhancement factor may be set as desired.
Wherein,is a first image of the object to be imaged,is the information of the high frequency of the signal,is the first contrast enhancement factor and,is low frequency information.
In this embodiment, the electronic device performs contrast enhancement on the high-frequency information in the input image, so that the contrast of the image can be more accurately adjusted, and a more accurate first image with adjusted contrast is obtained. The contrast enhancement is performed on the high-frequency information in the input image, so that the first image has better contrast effect, and the contrast enhancement is better while the overall brightness of the first image is not changed.
In one embodiment, the method further comprises: carrying out contrast enhancement on a portrait area in the first image to obtain an enhanced first image; generating an intermediate image based on the enhanced first image and the input image; based on the brightness information of the portrait area in the first image, performing second brightness processing on the first image to obtain a third image, including: and carrying out second brightness processing on the intermediate image based on the brightness information of the image area in the intermediate image to obtain a third image.
Optionally, as shown in fig. 5, the electronic device sets a second contrast enhancement coefficient k, and multiplies the first image by the second contrast enhancement coefficient k to obtain an enhanced first image; multiplying the input image by (1-k) to obtain a processed input image, and fusing the enhanced first image and the processed input image to generate an intermediate image.
The electronic device generates an intermediate image using the following formula:
wherein,is an intermediate image of the object,is the first image after enhancement and is then displayed,is an input image of the person,is a second contrast enhancement factor.
Optionally, the electronic device determines a portrait area in the intermediate image; and acquiring brightness information of a portrait area in the intermediate image.
Optionally, the electronic device determines the portrait area from the intermediate image through a portrait mask drawing. Wherein, the portrait mask drawing is obtained by an image obtaining device.
Optionally, the electronic device multiplies the intermediate image and the portrait mask drawing to obtain a portrait area in the intermediate image.
Optionally, the electronic device acquires each pixel value of the portrait area in the intermediate image; luminance information of the portrait region is determined based on the respective pixel values. It will be appreciated that the pixel value of a pixel characterizes the luminance of that pixel, and that pixel value and luminance of the pixel are positively correlated.
In an alternative embodiment, the electronic device calculates an average value of the values of the pixels in the portrait area, and takes the average value as the brightness of the portrait area. In another alternative embodiment, the electronic device counts pixel values of each pixel in the portrait area, determines a median, and uses the median as the brightness of the portrait area. In other alternative embodiments, the electronic device may determine the brightness of the portrait area in other ways, which are not limited herein.
As shown in fig. 6, the electronic device multiplies the intermediate image and the portrait mask drawing to obtain a portrait area in the intermediate image, and calculates the average brightness of the portrait area; calculating a brightness processing curve of the portrait area based on the average brightness of the portrait area, and performing second brightness processing on the intermediate image based on the brightness processing curve of the portrait area to obtain a third image; and calculating a brightness processing curve of the face region based on the brightness information of the face region in the third image, and performing third brightness processing on the third image based on the brightness processing curve of the face region to obtain a fourth image.
In this embodiment, the electronic device performs contrast enhancement on the portrait area in the first image, so as to obtain a more accurate first image with enhanced contrast, and further obtain a more accurate intermediate image and a more accurate third image with enhanced contrast.
In one embodiment, as shown in fig. 7, there is also provided another image processing method applied to an electronic device, the image processing method including the steps of:
and A1, performing high-low frequency separation on the input image to obtain high-frequency information and low-frequency information of the input image.
Step A2, carrying out contrast enhancement on the high-frequency information in the input image to obtain enhanced high-frequency information; a first image is generated based on the enhanced high frequency information and the low frequency information of the input image.
The electronic apparatus executes steps A3 to A4, and executes steps A5 to A7 in parallel.
Step A3, obtaining pixel values of all pixels in the first image; determining a target luminance region of the first image based on pixel values of the respective pixels; the pixel values of the pixels in the target brightness region are all smaller than the pixel threshold value; the size of the target luminance area is calculated.
Step A4, if the size of the target brightness area is smaller than the size threshold, performing brightness reduction processing on the first image to obtain a second image; and if the size of the target brightness area is larger than or equal to the size threshold value, performing brightness improvement processing on the first image to obtain a second image.
Step A5, carrying out contrast enhancement on a portrait area in the first image to obtain an enhanced first image; an intermediate image is generated based on the enhanced first image and the input image.
Step A6, calculating a brightness processing curve of the portrait area based on the brightness information of the portrait area of the intermediate image; specifically, if the brightness of the portrait area in the intermediate image is smaller than a brightness threshold value, performing brightness improvement processing on the first image to obtain a third image; and if the brightness of the portrait area in the first image is greater than or equal to the brightness threshold value, the first image is taken as a third image. And carrying out second brightness processing on the intermediate image based on the brightness information of the image area in the intermediate image to obtain a third image.
Step A7: calculating a brightness processing curve of the face area; specifically, based on the brightness information of the face region in the third image, third brightness processing is performed on the third image, and a fourth image is obtained.
The electronic device continues to step A8.
Step A8: the target image is generated based on the background region in the second image, the portrait region in the third image, and the face region in the fourth image.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiments of the present application also provide an image processing apparatus for implementing the above-mentioned image processing method. The implementation of the solution provided by the apparatus is similar to the implementation described in the above method, so the specific limitation of one or more embodiments of the image processing apparatus provided below may refer to the limitation of the image processing method hereinabove, and will not be repeated herein.
In one embodiment, as shown in fig. 8, there is provided an image processing apparatus including: a luminance processing module 802 and a fusion module 804, wherein:
a brightness processing module 802, configured to perform first brightness processing on a first image based on brightness information of the first image, to obtain a second image;
the brightness processing module 802 is further configured to perform a second brightness process on the first image based on brightness information of a portrait area in the first image, so as to obtain a third image;
a fusion module 804, configured to generate a target image based on the background area in the second image and the portrait area in the third image.
The image processing device performs first brightness processing on the first image based on brightness information of the first image to obtain a second image; performing second brightness processing on the first image based on brightness information of a portrait area in the first image to obtain a third image; that is, the second image is obtained by performing the first luminance processing based on the luminance information of the entire first image, the background area in the second image comprehensively considers the luminance information of the entire first image, and the third image is obtained by performing the second luminance processing based on the luminance information of the portrait area of the first image, so that the portrait area of the third image more meets the luminance requirement of the portrait, and then the target image can be generated more accurately based on the background area in the second image and the portrait area in the third image.
In one embodiment, the brightness processing module 802 is further configured to obtain pixel values of pixels in the first image; determining a target brightness region of the first image based on the pixel values of the respective pixels; the pixel values of the pixels in the target brightness area are smaller than a pixel threshold value; and carrying out first brightness processing on the first image based on the target brightness region to obtain a second image.
In one embodiment, the above-mentioned brightness processing module 802 is further configured to perform brightness reduction processing on the first image to obtain a second image if the size of the target brightness area is smaller than a size threshold; and if the size of the target brightness area is larger than or equal to a size threshold value, performing brightness improvement processing on the first image to obtain a second image.
In one embodiment, the above-mentioned brightness processing module 802 is further configured to perform brightness enhancement processing on the first image to obtain a third image if the brightness of the portrait area in the first image is less than a brightness threshold; and if the brightness of the portrait area in the first image is greater than or equal to a brightness threshold value, taking the first image as a third image.
In one embodiment, the above-mentioned brightness processing module 802 is further configured to perform a third brightness process on the third image based on the brightness information of the face area in the third image, to obtain a fourth image; the above fusion module 804 is further configured to generate a target image based on the background area in the second image, the portrait area in the third image, and the face area in the fourth image.
In one embodiment, the apparatus further includes a contrast enhancement module, where the contrast enhancement module is configured to contrast-enhance the high-frequency information in the input image to obtain enhanced high-frequency information; a first image is generated based on the enhanced high frequency information and the low frequency information of the input image.
In an embodiment, the contrast enhancement module is further configured to perform contrast enhancement on a portrait area in the first image, so as to obtain an enhanced first image; generating an intermediate image based on the enhanced first image and the input image; the above-mentioned brightness processing module 802 is further configured to perform a second brightness process on the intermediate image based on the brightness information of the portrait area in the intermediate image, so as to obtain a third image.
The respective modules in the above-described image processing apparatus may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or independent of a processor in the electronic device, or may be stored in software in a memory in the electronic device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, an electronic device is provided, which may be a terminal, and an internal structure diagram thereof may be as shown in fig. 9. The electronic device includes a processor, a memory, an input/output interface, a communication interface, a display unit, and an input device. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input/output interface. Wherein the processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input/output interface of the electronic device is used to exchange information between the processor and the external device. The communication interface of the electronic device is used for conducting wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement an image processing method. The display unit of the electronic device is used for forming a visual picture, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic equipment can be a touch layer covered on the display screen, can also be keys, a track ball or a touch pad arranged on the shell of the electronic equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structure shown in fig. 9 is merely a block diagram of a portion of the structure associated with the present application and is not limiting of the electronic device to which the present application is applied, and that a particular electronic device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
Embodiments of the present application also provide a computer-readable storage medium. One or more non-transitory computer-readable storage media containing computer-executable instructions that, when executed by one or more processors, cause the processors to perform steps of an image processing method.
Embodiments of the present application also provide a computer program product containing instructions that, when run on a computer, cause the computer to perform an image processing method.
It should be noted that, the user information (including, but not limited to, user equipment information, user personal information, etc.) and the data (including, but not limited to, data for analysis, stored data, presented data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use, and processing of the related data are required to meet the related regulations.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the various embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided herein may include at least one of relational databases and non-relational databases. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic units, quantum computing-based data processing logic units, etc., without being limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples only represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the present application. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.

Claims (10)

1. An image processing method, comprising:
performing first brightness processing on the first image based on brightness information of the first image to obtain a second image;
performing second brightness processing on the first image based on brightness information of a portrait area in the first image to obtain a third image;
and generating a target image based on the background area in the second image and the portrait area in the third image.
2. The method according to claim 1, wherein the performing a first luminance processing on the first image based on luminance information of the first image to obtain a second image includes:
acquiring pixel values of pixels in a first image;
determining a target brightness region of the first image based on the pixel values of the respective pixels; the pixel values of the pixels in the target brightness area are smaller than a pixel threshold value;
and carrying out first brightness processing on the first image based on the target brightness region to obtain a second image.
3. The method of claim 2, wherein performing a first luminance process on the first image based on the target luminance region to obtain a second image comprises:
if the size of the target brightness area is smaller than a size threshold, performing brightness reduction processing on the first image to obtain a second image;
and if the size of the target brightness area is larger than or equal to a size threshold value, performing brightness improvement processing on the first image to obtain a second image.
4. The method according to claim 1, wherein the performing a second luminance process on the first image based on the luminance information of the image area in the first image to obtain a third image includes:
If the brightness of the portrait area in the first image is smaller than a brightness threshold value, brightness improvement processing is carried out on the first image, and a third image is obtained;
and if the brightness of the portrait area in the first image is greater than or equal to a brightness threshold value, taking the first image as a third image.
5. The method according to claim 1, wherein after performing the second luminance processing on the first image based on the luminance information of the image area in the first image, obtaining a third image, further comprising:
performing third brightness processing on the third image based on the brightness information of the face area in the third image to obtain a fourth image;
the generating a target image based on the background area in the second image and the portrait area in the third image includes:
and generating a target image based on the background area in the second image, the portrait area in the third image and the face area in the fourth image.
6. The method according to claim 1, wherein the method further comprises:
contrast enhancement is carried out on the high-frequency information in the input image, and the enhanced high-frequency information is obtained;
A first image is generated based on the enhanced high frequency information and the low frequency information of the input image.
7. The method of claim 6, wherein the method further comprises:
carrying out contrast enhancement on the portrait area in the first image to obtain an enhanced first image;
generating an intermediate image based on the enhanced first image and the input image;
the step of performing second brightness processing on the first image based on the brightness information of the image area in the first image to obtain a third image includes:
and carrying out second brightness processing on the intermediate image based on the brightness information of the portrait area in the intermediate image to obtain a third image.
8. An image processing apparatus, comprising:
the brightness processing module is used for carrying out first brightness processing on the first image based on brightness information of the first image to obtain a second image;
the brightness processing module is further used for performing second brightness processing on the first image based on brightness information of a human image area in the first image to obtain a third image;
and the fusion module is used for generating a target image based on the background area in the second image and the portrait area in the third image.
9. An electronic device comprising a memory and a processor, the memory having stored therein a computer program which, when executed by the processor, causes the processor to perform the steps of the image processing method according to any of claims 1 to 7.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method according to any one of claims 1 to 7.
CN202311794162.2A 2023-12-22 2023-12-22 Image processing method, apparatus, electronic device, and computer-readable storage medium Pending CN117541525A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311794162.2A CN117541525A (en) 2023-12-22 2023-12-22 Image processing method, apparatus, electronic device, and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311794162.2A CN117541525A (en) 2023-12-22 2023-12-22 Image processing method, apparatus, electronic device, and computer-readable storage medium

Publications (1)

Publication Number Publication Date
CN117541525A true CN117541525A (en) 2024-02-09

Family

ID=89788288

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311794162.2A Pending CN117541525A (en) 2023-12-22 2023-12-22 Image processing method, apparatus, electronic device, and computer-readable storage medium

Country Status (1)

Country Link
CN (1) CN117541525A (en)

Similar Documents

Publication Publication Date Title
Xiao et al. Brightness and contrast controllable image enhancement based on histogram specification
CN110363753B (en) Image quality evaluation method and device and electronic equipment
WO2024045821A1 (en) Image processing method and apparatus, computer device, and storage medium
WO2020087729A1 (en) Image processing method and apparatus, electronic device and storage medium
CN112560864B (en) Image semantic segmentation method and device and training method of image semantic segmentation model
CN116580028B (en) Object surface defect detection method, device, equipment and storage medium
CN110689478B (en) Image stylization processing method and device, electronic equipment and readable medium
CN117408886A (en) Gas image enhancement method, gas image enhancement device, electronic device and storage medium
CN115049572A (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
CN111784726A (en) Image matting method and device
CN117541525A (en) Image processing method, apparatus, electronic device, and computer-readable storage medium
US20230054283A1 (en) Methods and apparatuses for generating style pictures
CN115082345A (en) Image shadow removing method and device, computer equipment and storage medium
US9058667B2 (en) Detail preserving image transfer operations
Sun et al. Explore unsupervised exposure correction via illumination component divided guidance
CN111784607A (en) Image tone mapping method, device, terminal equipment and storage medium
CN106651815B (en) Method and device for processing Bayer format video image
CN116188332B (en) Image processing method, device, equipment and storage medium
CN118015102A (en) Image processing method, apparatus, electronic device, and computer-readable storage medium
JP2020191030A (en) Image processing device
CN117689989A (en) Image processing method, apparatus, electronic device, and computer-readable storage medium
CN116977154B (en) Visible light image and infrared image fusion storage method, device, equipment and medium
CN117522749B (en) Image correction method, apparatus, computer device, and storage medium
EP4379651A1 (en) Image processing apparatus and method of operating the same
CN114372974B (en) Image detection method, device, equipment and storage medium

Legal Events

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