Image processing method and apparatus, storage medium, and electronic device
Through the image analysis model segmentation and correction of the color lookup table curve of the fusion foreground and background images, the problem of poor image processing stability is solved, and stability improvement and user experience improvement is achieved.
Patent Information
- Application Number
- PCT/CN2024/134005
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-01-09
- Filing Date
- 2024-11-22
- Publication Date
- 2025-07-17
AI Technical Summary
The existing image processing methods have poor stability and are prone to mutations in picture processing, which affects the user experience.
The depth of field map of the to-processed image is analyzed by the preset image analysis model, divided into foreground and background images, and the color lookup table curves of the foreground and background scenes are calculated respectively, and the correction and fusion process is performed to generate the processed image.
Improves the stability of image processing, avoids sudden changes in image processing, and improves user experience.
Smart Images

Figure CN2024134005_17072025_PF_FP_ABST
Abstract
Description
Image processing method, device, storage medium and electronic device
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on January 9, 2024, with application number 202410040860.1 and application name “Image processing method, device, storage medium and electronic device”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of image processing technology, and in particular to an image processing method, device, storage medium and electronic device. Background Art
[0003] With the continuous development of technology, users have higher and higher requirements for image presentation in various scenarios, and have an extreme pursuit of image expressiveness such as layering, three-dimensionality, and picture details.
[0004] Currently, artificial intelligence (AI) models are commonly used to optimize images to improve their visual expressiveness. However, due to the randomness of AI model decisions and the stability of data fluctuations, the images obtained after optimization may exhibit sudden changes such as flickering, brightening or darkening of the overall scene, etc. under different optimization directions. Technical issues
[0005] Therefore, the current image processing method has poor image processing stability and is prone to sudden changes in image processing, which affects user experience. Technical Solutions
[0006] The embodiments of the present application provide a solution that can effectively improve image processing stability, avoid sudden changes in image processing, and enhance user experience.
[0007] The embodiments of this application provide the following technical solutions:
[0008] According to one embodiment of the present application, an image processing method includes: analyzing an image to be processed using a preset image analysis model to obtain a depth map of the image to be processed; segmenting the image to be processed into near and far scenes based on the depth map to obtain a foreground image and a background image; respectively calculating a foreground color lookup table curve corresponding to the foreground image and a background color lookup table curve corresponding to the background image; and performing correction and fusion processing on the image data of the foreground image and the background image based on the foreground color lookup table curve and the background color lookup table curve to obtain a processed image.
[0009] In some embodiments of the present application, respectively calculating the foreground color lookup table curve corresponding to the foreground image and the background color lookup table curve corresponding to the background image includes: calculating the picture level mean corresponding to the image to be calculated, the image to be calculated including the foreground image or the background image; calculating the color lookup table curve of the image to be calculated based on the picture level mean and a predetermined picture level interval to obtain a calculation result; obtaining an image color lookup table curve according to the calculation result, the image color lookup table curve including the foreground color lookup table curve or the background color lookup table curve.
[0010] In some embodiments of the present application, the calculation of the picture level mean corresponding to the image to be calculated includes: if the scene corresponding to the image to be calculated is a scene in which a target object exists, selecting one of the first picture level mean and the second picture level mean that meets a predetermined stability condition to obtain a selected picture level mean; based on the selected picture level mean, obtaining the picture level mean corresponding to the image to be calculated, wherein the first picture level mean is the picture level mean of the image to be calculated, and the second picture level mean is the picture level mean of the image to be calculated in the previous frame.
[0011] In some embodiments of the present application, the calculation of the picture level mean corresponding to the image to be calculated includes: if the scene corresponding to the image to be calculated does not have a target object, adjusting the depth of field value of the image to be calculated according to the picture level adjustment table to obtain an adjusted depth of field; and calculating the picture level mean corresponding to the image to be calculated based on the adjusted depth of field.
[0012] In some embodiments of the present application, the color lookup table curve of the image to be calculated is calculated based on the picture level mean and the predetermined picture level interval to obtain a calculation result, including: mapping the predetermined picture level interval by querying a preset lookup table to obtain a first lookup table curve; performing a peak method calculation on the focus sub-interval in the predetermined picture level interval to obtain a second lookup table curve; and performing calculation according to the first lookup table curve, the second lookup table curve and the picture level mean to obtain the calculation result.
[0013] In some embodiments of the present application, before calculating the color lookup table curve of the image to be calculated based on the picture level mean and the predetermined picture level interval and obtaining the calculation result, the method also includes: according to the scene corresponding to the image to be processed, obtaining the predetermined picture level interval and the focus sub-interval corresponding to the scene, wherein the scene includes a first scene and a second scene, the first scene is that there is a target object, and the second scene is that there is no target object, and the number of sub-intervals in the predetermined picture level interval corresponding to the first scene is less than the number of sub-intervals in the predetermined picture level interval corresponding to the second scene.
[0014] In some embodiments of the present application, the calculation based on the first lookup table curve, the second lookup table curve and the picture level mean to obtain the calculation result includes: calculating the difference between the first interval value and the picture level mean to obtain a first difference, and the first interval value is the maximum value of the focus sub-interval; multiplying the first difference by the first curve value to obtain a first product; calculating the difference between the picture level mean and the second interval value to obtain a second difference, and the second interval value is the minimum value of the focus sub-interval; multiplying the second difference by the second curve value to obtain a second product, and the first curve value and the second curve value are the curve values corresponding to the same picture level in the first lookup table curve and the second lookup table curve, respectively; adding the first product and the second product to obtain the fusion curve value corresponding to the same picture level; and obtaining the calculation result according to the fusion curve value corresponding to the same picture level.
[0015] In some embodiments of the present application, obtaining the image color lookup table curve based on the calculation result includes: obtaining the previous frame image color lookup table curve corresponding to a predetermined number of previous frames of images to be calculated before the image to be processed; performing mean calculation on the calculation result and the previous frame image color lookup table curve to obtain the image color lookup table curve.
[0016] In some embodiments of the present application, the correction and fusion processing is performed on the image data of the foreground image and the background image based on the foreground color lookup table curve and the background color lookup table curve to obtain a processed image, including: mapping and correcting the image data of the foreground image based on the foreground color lookup table curve to obtain foreground data; mapping and correcting the image data of the background image based on the background color lookup table curve to obtain background data; and fusing the foreground data and the background data to obtain a processed image corresponding to the image to be processed.
[0017] According to one embodiment of the present application, an image processing device includes: an analysis module for analyzing an image to be processed using a preset image analysis model to obtain a depth map of the image to be processed; a segmentation module for performing near and far scene segmentation on the image to be processed according to the depth map to obtain a foreground image and a background image; a calculation module for respectively calculating a foreground color lookup table curve corresponding to the foreground image and a background color lookup table curve corresponding to the background image; and an output module for performing correction and fusion processing on the image data of the foreground image and the background image based on the foreground color lookup table curve and the background color lookup table curve to obtain a processed image.
[0018] In some embodiments of the present application, the calculation module is used to: calculate the picture level mean corresponding to the image to be calculated, the image to be calculated includes the foreground image or the background image; calculate the color lookup table curve of the image to be calculated based on the picture level mean and a predetermined picture level interval to obtain a calculation result; obtain an image color lookup table curve based on the calculation result, the image color lookup table curve includes the foreground color lookup table curve or the background color lookup table curve.
[0019] In some embodiments of the present application, the calculation module is used to: if the scene corresponding to the image to be calculated contains a target object, select one of the first picture level mean and the second picture level mean that meets the predetermined stability condition to obtain the selected picture level mean; obtain the picture level mean corresponding to the image to be calculated based on the selected picture level mean, wherein the first picture level mean is the picture level mean of the image to be calculated, and the second picture level mean is the picture level mean of the image to be calculated in the previous frame.
[0020] In some embodiments of the present application, the calculation module is used to: if the scene corresponding to the image to be calculated does not have a target object, adjust the depth of field value of the image to be calculated according to the picture level adjustment table to obtain an adjusted depth of field; and calculate the picture level mean corresponding to the image to be calculated based on the adjusted depth of field.
[0021] In some embodiments of the present application, the calculation module is used to: map a predetermined picture level interval by querying a preset query table to obtain a first lookup table curve; perform peak method calculation on a focus sub-interval in the predetermined picture level interval to obtain a second lookup table curve; and perform calculation based on the first lookup table curve, the second lookup table curve and the picture level mean to obtain the calculation result.
[0022] In some embodiments of the present application, before calculating the color lookup table curve of the image to be calculated based on the picture level mean and the predetermined picture level interval and obtaining the calculation result, the device also includes a configuration module for: obtaining the predetermined picture level interval and the focus sub-interval corresponding to the scene according to the scene corresponding to the image to be processed, wherein the scene includes a first scene and a second scene, the first scene is a target object, and the second scene is a target object is not present, and the number of sub-intervals in the predetermined picture level interval corresponding to the first scene is less than the number of sub-intervals in the predetermined picture level interval corresponding to the second scene.
[0023] In some embodiments of the present application, the calculation module is used to: calculate the difference between the first interval value and the picture level mean to obtain a first difference, and the first interval value is the maximum value of the focus sub-interval; multiply the first difference by the first curve value to obtain a first product; calculate the difference between the picture level mean and the second interval value to obtain a second difference, and the second interval value is the minimum value of the focus sub-interval; multiply the second difference by the second curve value to obtain a second product, and the first curve value and the second curve value are curve values corresponding to the same picture level in the first lookup table curve and the second lookup table curve, respectively; add the first product and the second product to obtain the fusion curve value corresponding to the same picture level; and obtain the calculation result according to the fusion curve value corresponding to the same picture level.
[0024] In some embodiments of the present application, the calculation module is used to: obtain a previous frame image color lookup table curve corresponding to a predetermined number of previous frames of images to be calculated before the image to be processed; perform mean calculation on the calculation result and the previous frame image color lookup table curve to obtain the image color lookup table curve.
[0025] In some embodiments of the present application, the output module is used to: perform mapping correction on the image data of the foreground image based on the foreground color lookup table curve to obtain foreground data; perform mapping correction on the image data of the background image based on the background color lookup table curve to obtain background data; and fuse the foreground data and the background data to obtain a processed image corresponding to the image to be processed.
[0026] According to another embodiment of the present application, a storage medium stores a computer program thereon, and when the computer program is executed by a processor of a computer, the computer is caused to execute the method described in the embodiment of the present application.
[0027] According to another embodiment of the present application, an electronic device may include: a memory storing a computer program; and a processor reading the computer program stored in the memory to execute the method described in the embodiment of the present application.
[0028] According to another embodiment of the present application, a computer program product or computer program includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in various optional implementations described in the embodiments of the present application. Beneficial effects
[0029] In an embodiment of the present application, a preset image analysis model is used to analyze an image to be processed to obtain a depth map of the image to be processed; the image to be processed is segmented into near and far scenes based on the depth map to obtain a foreground image and a background image; a foreground color lookup table curve corresponding to the foreground image and a background color lookup table curve corresponding to the background image are calculated respectively; and based on the foreground color lookup table curve and the background color lookup table curve, image data of the foreground image and the background image are corrected and fused to obtain a processed image.
[0030] In this way, the depth map of the image to be processed is obtained through analysis by a preset image analysis model, and the image to be processed is divided into a foreground image and a background image according to the depth map. Then, the corresponding color lookup table curves are calculated separately for correction and fusion processing to obtain the processed image, thereby avoiding the stability problem of relying solely on intelligent models for image optimization processing. The stability of the overall image processing process is effectively improved, and sudden changes in picture processing can be avoided while ensuring the optimization effect of picture expressiveness, thereby improving user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0032] FIG1 shows a flowchart of an image processing method according to an embodiment of the present application.
[0033] FIG2 shows a flow chart of a curve calculation method according to an embodiment of the present application.
[0034] FIG3 shows a flowchart of image processing in which an embodiment of the present application is applied in a scenario.
[0035] FIG4 shows a block diagram of an image processing apparatus according to an embodiment of the present application.
[0036] FIG5 shows a block diagram of an electronic device according to an embodiment of the present application.
[0037] Implementation Methods of the Application
[0038] The present disclosure will be further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the examples provided herein are merely for explaining the present disclosure and are not intended to limit the present disclosure. In addition, the examples provided below are partial examples for implementing the present disclosure, rather than providing all examples for implementing the present disclosure. In the absence of conflict, the technical solutions described in the examples of the present disclosure may be implemented in any combination.
[0039] It should be noted that, in the embodiments of the present disclosure, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a method or apparatus comprising a series of elements includes not only the elements explicitly stated, but also other elements not explicitly listed, or also includes elements inherent to the implementation of the method or apparatus. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other related elements (such as steps in the method or units in the apparatus, for example, a unit may be part of a circuit, part of a processor, part of a program or software, etc.) in the method or apparatus comprising the element.
[0040] For example, the image processing method provided by the embodiment of the present disclosure includes a series of steps, but the image processing method provided by the embodiment of the present disclosure is not limited to the recorded steps. Similarly, the image processing device provided by the embodiment of the present disclosure includes a series of units, but the device provided by the embodiment of the present disclosure is not limited to including the units explicitly recorded, and may also include units that need to be set up to obtain relevant information or perform processing based on information.
[0041] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present disclosure pertains. The terms used herein are for the purpose of describing specific embodiments only and are not intended to limit the present disclosure.
[0042] Figure 1 schematically illustrates a flow chart of an image processing method according to an embodiment of the present application. The image processing method can be executed by any device or server with processing capabilities, such as computers, mobile phones, smart watches, and home appliances, and servers such as cloud servers, physical servers, or server clusters.
[0043] As shown in FIG. 1 , the image processing method may include steps S110 to S140 .
[0044] Step S110, analyzing the image to be processed using a preset image analysis model to obtain a depth map of the image to be processed; Step S120, segmenting the image to be processed into near and far scenes according to the depth map to obtain a foreground image and a background image; Step S130, respectively calculating a foreground color lookup table curve corresponding to the foreground image and a background color lookup table curve corresponding to the background image; Step S140, correcting and fusing the image data of the foreground image and the background image based on the foreground color lookup table curve and the background color lookup table curve to obtain a processed image.
[0045] The preset image analysis model is a pre-trained deep learning model used to analyze the depth map of the output image. The image to be processed is input into the preset analysis model for analysis. The preset image analysis model can output the depth map of the image to be processed.
[0046] A depth map (BitMap) is a map that marks the depth of field corresponding to each element (pixel) in the image to be processed. The depth map (BitMap) includes the depth of field corresponding to each pixel in the image to be processed, and its dimension ranges from 0 to 255. Depth of field (DoF) can be understood as depth.
[0047] According to the depth map, the image to be processed can be segmented into near and far scenes to obtain a foreground image and a background image. Specifically, the depth map can be exported as a histogram. Then, according to the histogram, the pixels belonging to the foreground image and the pixels belonging to the background image in the image to be processed can be accurately segmented to obtain the foreground image and the background image.
[0048] The foreground color lookup table curve is the LUT (Look-Up Table) curve corresponding to the foreground image. Based on this curve, the image data of the foreground image can be mapped to new data to improve the image's expressiveness. The background color lookup table curve is the LUT (Look-Up Table) curve corresponding to the background image. Based on this curve, the image data of the background image can be mapped to new data to improve the image's expressiveness.
[0049] The foreground color lookup table curve corresponding to the foreground image and the background color lookup table curve corresponding to the background image are calculated separately. Based on the foreground color lookup table curve and the background color lookup table curve, the image data of the foreground and background images can be mapped and corrected. A fusion process is then performed to obtain a fully processed image with enhanced visual quality. This is the processed image obtained through the correction and fusion process. The processed image's layering, three-dimensionality, and image details are effectively enhanced without abrupt changes to the overall image.
[0050] In this way, based on steps S110 to S140, the depth map of the image to be processed is obtained by analyzing the preset image analysis model, and the image to be processed is divided into a foreground image and a background image according to the depth map. Then, the corresponding color lookup table curves are calculated respectively for correction and fusion processing to obtain the processed image, thereby avoiding the stability problem of relying solely on the intelligent model for image optimization processing. The stability of the overall image processing process is effectively improved, and sudden changes in picture processing can be avoided while ensuring the optimization effect of picture expressiveness, thereby improving user experience.
[0051] The following describes further optional specific embodiments of each step performed when performing image processing in the embodiment of FIG. 1 .
[0052] In one embodiment, referring to Figure 2, the respectively calculating of the foreground color lookup table curve corresponding to the foreground image and the background color lookup table curve corresponding to the background image may include: step S210, calculating the picture level mean corresponding to the image to be calculated, the image to be calculated including the foreground image or the background image; step S220, calculating the color lookup table curve of the image to be calculated based on the picture level mean and a predetermined picture level interval to obtain a calculation result; step S230, obtaining an image color lookup table curve according to the calculation result, the image color lookup table curve including the foreground color lookup table curve or the background color lookup table curve.
[0053] The foreground image and the background image are respectively used as the images to be calculated, and the corresponding image color lookup table curve can be calculated. For example, the foreground image is first used as the image to be calculated to obtain the foreground color lookup table curve, and then the background image is used as the image to be calculated to obtain the background color lookup table curve.
[0054] First, the picture level mean (Max_rgb_avg) corresponding to the image to be calculated is calculated. The picture level mean (Max_rgb_avg) is the mean of the picture levels included in the image to be calculated. Specifically, according to the depth map (BitMap) of the image to be processed, the pixel data corresponding to the different depths of field of the image to be calculated can be obtained, and the mean of the pixel data corresponding to the different depths of field of the image to be calculated is calculated. The mean is the picture level mean (that is, the first picture level mean described later). In some embodiments, the first picture level mean can be directly used as the picture level mean corresponding to the image to be calculated. Furthermore, as described in some subsequent embodiments, it can also be selected according to predetermined stability conditions to further improve the stability of image processing.
[0055] Then, a color lookup table curve for the image to be calculated is calculated based on the image level mean and the predetermined image level interval, yielding a calculation result. This calculation result is the color lookup table curve for the image to be calculated, obtained by preliminary calculation. Based on this calculation result, the final image color lookup table curve for the image to be calculated can be obtained.
[0056] In one embodiment, the calculation of the picture level mean corresponding to the image to be calculated may include: if the scene corresponding to the image to be calculated is one in which a target object exists, selecting one of the first picture level mean and the second picture level mean that meets a predetermined stability condition to obtain a selected picture level mean; based on the selected picture level mean, obtaining the picture level mean corresponding to the image to be calculated, wherein the first picture level mean is the picture level mean of the image to be calculated, and the second picture level mean is the picture level mean of the image to be calculated in the previous frame.
[0057] In this embodiment, if the scene corresponding to the image to be calculated contains a target object, such as a person (screen_people=1), then the first screen level mean (max_rgb_avg_new) of the image to be calculated in the current frame and the second screen level mean (max_rgb_avg_old) of the image to be calculated in the previous frame are selected to obtain a selected screen level mean. Based on this selected screen level mean, the screen level mean (Max_rgb_avg) corresponding to the image to be calculated is obtained. In this way, when the target object exists in the image to be processed, the screen level mean corresponding to the image to be calculated can be stably obtained, thereby ensuring the stability of image processing.
[0058] In one approach, a first picture level average (max_rgb_avg_new) corresponding to the image to be calculated in the current frame and a second picture level average (max_rgb_avg_old) of the image to be calculated in the previous frame are selected to obtain a selected picture level average. Specifically, the selected picture level average can be selected according to the formula: max_rgb_avg_new-max_rgb_avg_old|>15?max_rgb_avg_new+15:max_rgb_avg_old. That is, when the absolute value difference between the first picture level average (max_rgb_avg_new) and the second picture level average (max_rgb_avg_old) is less than a certain threshold (e.g., 15), the second picture level average (max_rgb_avg_old) of the previous frame is used as the selected picture level average; otherwise, the first picture level average (max_rgb_avg_new) is used as the selected picture level average.
[0059] Furthermore, in one embodiment, the calculation of the picture level mean corresponding to the image to be calculated may include: if the scene corresponding to the image to be calculated does not have a target object, adjusting the depth of field value of the image to be calculated according to the picture level adjustment table to obtain an adjusted depth of field; and calculating the picture level mean corresponding to the image to be calculated based on the adjusted depth of field.
[0060] In this embodiment, if the target object does not exist in the image to be processed, for example, if there are no people (Screen_people=0), the pixel data corresponding to different depths of field of the image to be calculated is adjusted according to the screen level adjustment table (Avg_gamma), and then the average of the adjusted data is calculated as the obtained screen level average value corresponding to the image to be calculated. In scenarios where the target object does not exist, the screen level average value corresponding to the image to be calculated can be stably obtained through screen level adjustment, ensuring the stability of image processing.
[0061] In one embodiment, the color lookup table curve of the image to be calculated is calculated based on the picture level mean and the predetermined picture level interval to obtain the calculation result, which may include: mapping the predetermined picture level interval by querying a preset lookup table to obtain a first lookup table curve; performing a peak method calculation on the focus sub-interval in the predetermined picture level interval to obtain a second lookup table curve; and performing calculation according to the first lookup table curve, the second lookup table curve and the picture level mean to obtain the calculation result.
[0062] First, the predetermined picture level interval is a preset picture level interval for calculating the first lookup table curve (gain_lut1), and the predetermined picture level interval is, for example, (0, 48, 96, 144, 192, 255) or (0, 16, 32, 48, 64, 90, 120, 159, 207, 255).
[0063] The first lookup table curve (gain_lut1) can be obtained by looking up a curve. Specifically, the first lookup table curve (gain_lut1) can be obtained by mapping a predetermined picture level interval by looking up a preset lookup table. For example, the predetermined picture level interval is (0, 48, 96, 144, 192, 255). By looking up the preset lookup table, the mapping value of all pixels in the grayscale subinterval (0, 48) can be obtained as n1, and the mapping value of all pixels in the grayscale subinterval (48, 96) can be obtained as n2. Similarly, the mapping values of all values in the predetermined picture level interval can be mapped, and then, the grayscale of all pixels in the predetermined picture level interval and the corresponding mapping values are obtained to form the first lookup table curve (gain_lut1).
[0064] A focus subinterval is designated in the subintervals of the predetermined screen hierarchy interval for use in calculating a second lookup table curve using a peak method. The second lookup table curve is obtained by performing the peak method calculation on the focus subinterval in the predetermined screen hierarchy interval. For example, if the focus subinterval is (96, 144), then the grayscale level with the largest number of pixels in the focus subinterval (i.e., the peak value) is counted. If the peak value is 100, the score is mapped to 128, the middle value of the LUT curve range (from 0 to 255). Then, the remaining grayscales in the focus subinterval (96, 144) are mapped in sequence, thereby obtaining a second lookup table curve (gain_lut2).
[0065] Then, calculation is performed based on the first lookup table curve, the second lookup table curve and the picture level mean, and a calculation result of the fusion of the first lookup table curve and the second lookup table curve based on the picture level mean can be obtained. This calculation result is the color lookup table curve corresponding to the image to be calculated obtained by preliminary calculation.
[0066] In one embodiment, before calculating the color lookup table curve of the image to be calculated based on the picture level mean and the predetermined picture level interval to obtain the calculation result, the method further includes:
[0067] According to the scene corresponding to the image to be processed, the predetermined picture level interval and the focus sub-interval corresponding to the scene are obtained, wherein the scene includes a first scene and a second scene, the first scene is a scene in which a target object exists, and the second scene is a scene in which no target object exists, and the number of sub-intervals in the predetermined picture level interval corresponding to the first scene is less than the number of sub-intervals in the predetermined picture level interval corresponding to the second scene.
[0068] In this embodiment, the scene corresponding to the image to be processed is determined by obtaining the predetermined image hierarchy interval and subinterval of interest. Furthermore, the color lookup table curve is calculated based on the predetermined image hierarchy interval and subinterval of interest, allowing for scene differentiation and taking into account scene variations. This calculation result is used to generate the final curve for image correction, further improving overall image processing stability.
[0069] The scene may specifically include a first scene and a second scene, wherein the first scene is a scene in which a target object exists (e.g., a person exists: Screen_people=1), and the second scene is a scene in which no target object exists (e.g., a person does not exist: Screen_people=0). The number of subintervals in the predetermined screen hierarchy interval corresponding to the first scene is less than the number of subintervals in the predetermined screen hierarchy interval corresponding to the second scene. For example, the predetermined screen hierarchy interval corresponding to the first scene may specifically be (0, 48, 96, 144, 192, 255), and the corresponding subinterval of interest may be (96, 144). The predetermined screen hierarchy interval corresponding to the second scene may specifically be (0, 16, 32, 48, 64, 90, 120, 159, 207, 255), and the corresponding subinterval of interest may be (64, 120). In this way, a good screen processing effect can be obtained even in scenes in which no target object exists.
[0070] In one embodiment, the calculation based on the first lookup table curve, the second lookup table curve and the picture level mean to obtain the calculation result may specifically include: calculating the difference between the first interval value and the picture level mean to obtain a first difference, the first interval value is the maximum value of the focus sub-interval; multiplying the first difference with the first curve value to obtain a first product; calculating the difference between the picture level mean and the second interval value to obtain a second difference, the second interval value is the minimum value of the focus sub-interval; multiplying the second difference with the second curve value to obtain a second product, the first curve value and the second curve value are the curve values corresponding to the same picture level in the first lookup table curve and the second lookup table curve, respectively; adding the first product and the second product to obtain the fusion curve value corresponding to the same picture level; obtaining the calculation result according to the fusion curve value corresponding to the same picture level.
[0071] Specifically, the calculation result can be obtained by performing calculation according to the formula gain_lut[i]=(L1-max_rgb_avg)*gain lut1[i]+(max_rgb_avg-L2)*gain lut2[i].
[0072] Where L1 is the first interval value, i.e., the maximum value of the subinterval of interest. L2 is the second interval value, i.e., the minimum value of the subinterval of interest. max_rgb_avg is the average value of the image hierarchy.
[0073] Gain lut1 is the first lookup table curve; gain lut2 is the second lookup table curve. Gain lut1[i] is the first curve value, that is, the curve value corresponding to picture level i in the first lookup table curve. Gain lut2[i] is the second curve value, that is, the curve value corresponding to picture level i in the second lookup table curve.
[0074] Add the first product ((L1-max_rgb_avg)*gain lut1[i]) and the second product ((max_rgb_avg-L2)*gain lut2[i]) to obtain the fusion curve value gain_lut[i] corresponding to the same picture level i. Based on the fusion curve value gain_lut[i] corresponding to the same picture level i, the corresponding gain_lut[i] is formed into a curve from i=0 to i=255 to obtain the calculation result Gain lut.
[0075] For example, the focus subinterval corresponding to the first scenario is (96, 144), and the corresponding fusion curve value can be calculated in the first scenario according to the formula gain_lut[i]=(144-max_rgb_avg)*gain lut1[i]+(max_rgb_avg-96)*gain lut2[i].
[0076] For example, if the focus subinterval corresponding to the second scenario is (64, 120), the corresponding fusion curve value can be calculated in the first scenario according to the formula gain_lut[i]=(120-max_rgb_avg)*gain lut1[i]+(max_rgb_avg-64)*gain lut2[i].
[0077] Through the calculation method of this embodiment, an effective calculation result Gain lut can be obtained, and the calculation result Gain lut is used to generate a final curve to correct the image, which can further improve the overall image processing stability and further effectively avoid sudden changes in image processing.
[0078] In one embodiment, obtaining the image color lookup table curve based on the calculation result may include: obtaining the previous frame image color lookup table curve corresponding to a predetermined number of previous frames of to-be-processed images before the image to be processed; performing mean calculation on the calculation result and the previous frame image color lookup table curve to obtain the image color lookup table curve.
[0079] For the current frame of the image to be processed, the calculation result (Gain LUT) corresponding to the image to be processed can be calculated. Similarly, the corresponding previous frame image color lookup table curve (Gain_lut_old, i.e., the previous frame image color lookup table curve) can be obtained for a predetermined number (e.g., 1 or 9) of previous frames of the image to be processed.
[0080] The calculation result (Gain lut) is averaged with the color lookup table curve of the previous frame image (Gain_lut_old). The average curve of the two is used as the image color lookup table curve corresponding to the image to be calculated. A smoothing window of a predetermined number of frames (for example, 1 or 9) is established to make the image processing effect change smoother and more stable.
[0081] It can be understood that in other embodiments, obtaining the image color lookup table curve according to the calculation result may include: directly using the calculation result as the obtained image color lookup table curve.
[0082] In one embodiment, the image data of the foreground image and the background image are corrected and fused based on the foreground color lookup table curve and the background color lookup table curve to obtain a processed image, including: mapping and correcting the image data of the foreground image based on the foreground color lookup table curve to obtain foreground data; mapping and correcting the image data of the background image based on the background color lookup table curve to obtain background data; and fusing the foreground data and the background data to obtain a processed image corresponding to the image to be processed.
[0083] The image data of the foreground image is mapped and corrected based on the foreground color lookup table curve. The image data of the foreground image can be mapped to corresponding curve values according to the foreground color lookup table curve, thereby obtaining mapped and corrected foreground data. The image data of the background image is mapped and corrected based on the background color lookup table curve. The image data of the background image can be mapped to corresponding curve values according to the background color lookup table curve, thereby obtaining mapped and corrected background data. Furthermore, the foreground data and background data are fused into overall image data to obtain a processed image corresponding to the image to be processed.
[0084] To facilitate better implementation of the image processing method provided in the embodiment of the present application, the aforementioned embodiment is further described below in conjunction with the process of performing image processing in a scenario. In this scenario, image processing is performed by applying the aforementioned embodiment of the present application, where the meaning of the nouns is the same as in the above-mentioned image processing method. For specific implementation details, please refer to the description in the method embodiment.
[0085] Figure 3 shows a flowchart of image processing in a scenario in which an embodiment of the present application is applied. As shown in Figure 3 , the image processing process in this scenario may include steps S310 to S360.
[0086] Step S310: obtaining an image to be processed.
[0087] Step S320: depth of field analysis. Specifically, a preset image analysis model is used to analyze the image to be processed to obtain a depth map of the image to be processed.
[0088] Step S330: Scene analysis. Specifically, a preset scene detection model is used to detect the image to be processed to obtain the scene corresponding to the image to be processed. The scene can specifically include a first scene and a second scene. The first scene is when the target object exists (for example, when a person exists: Screen_people=1), and the second scene is when the target object does not exist (for example, when no person exists: Screen_people=0).
[0089] Step S340: Segmenting foreground and background. Specifically, segmenting the image to be processed into near and far scenes according to the depth map to obtain a foreground image and a background image.
[0090] Step S350 , respectively calculating a foreground color lookup table curve corresponding to the foreground image and a background color lookup table curve corresponding to the background image.
[0091] Respectively calculating a foreground color lookup table curve corresponding to the foreground image and a background color lookup table curve corresponding to the background image may include: calculating a picture level mean corresponding to the image to be calculated, the image to be calculated including the foreground image or the background image; calculating a color lookup table curve of the image to be calculated based on the picture level mean and a predetermined picture level interval to obtain a calculation result; and obtaining an image color lookup table curve according to the calculation result, the image color lookup table curve including the foreground color lookup table curve or the background color lookup table curve.
[0092] The calculation of the picture level mean corresponding to the image to be calculated may include: if the scene corresponding to the image to be calculated is one in which a target object exists, selecting one of the first picture level mean and the second picture level mean that meets a predetermined stability condition to obtain a selected picture level mean; obtaining the picture level mean corresponding to the image to be calculated based on the selected picture level mean, wherein the first picture level mean is the picture level mean of the image to be calculated, and the second picture level mean is the picture level mean of the previous frame of the image to be calculated. Alternatively, if the scene corresponding to the image to be calculated is one in which no target object exists, adjusting the depth of field value of the image to be calculated according to a picture level adjustment table to obtain an adjusted depth of field; and calculating the picture level mean corresponding to the image to be calculated based on the adjusted depth of field.
[0093] The method of calculating the color lookup table curve of the image to be calculated based on the picture level mean and the predetermined picture level interval to obtain the calculation result may include: mapping the predetermined picture level interval by querying a preset lookup table to obtain a first lookup table curve; performing a peak method calculation on the focus sub-interval in the predetermined picture level interval to obtain a second lookup table curve; and performing calculation according to the first lookup table curve, the second lookup table curve and the picture level mean to obtain the calculation result.
[0094] Before calculating the color lookup table curve of the image to be calculated based on the picture level mean and the predetermined picture level interval and obtaining the calculation result, it also includes: according to the scene corresponding to the image to be processed, obtaining the predetermined picture level interval and the focus sub-interval corresponding to the scene, wherein the scene includes a first scene and a second scene, the first scene is that there is a target object, and the second scene is that there is no target object, and the number of sub-intervals in the predetermined picture level interval corresponding to the first scene is less than the number of sub-intervals in the predetermined picture level interval corresponding to the second scene.
[0095] The scene may specifically include a first scene and a second scene, wherein the first scene is a scene in which a target object exists (e.g., a person exists: Screen_people=1), and the second scene is a scene in which no target object exists (e.g., a person does not exist: Screen_people=0). The number of subintervals in the predetermined screen hierarchy interval corresponding to the first scene is less than the number of subintervals in the predetermined screen hierarchy interval corresponding to the second scene. For example, the predetermined screen hierarchy interval corresponding to the first scene may specifically be (0, 48, 96, 144, 192, 255), and the corresponding subinterval of interest may be (96, 144). The predetermined screen hierarchy interval corresponding to the second scene may specifically be (0, 16, 32, 48, 64, 90, 120, 159, 207, 255), and the corresponding subinterval of interest may be (64, 120).
[0096] Specifically, the calculation result can be obtained by performing the calculation according to the formula gain_lut[i] = (L1-max_rgb_avg)*gain lut1[i] + (max_rgb_avg-L2)*gain lut2[i]. L1 is the first interval value, i.e., the maximum value of the subinterval of interest. L2 is the second interval value, i.e., the minimum value of the subinterval of interest. max_rgb_avg is the average value of the picture level. gain lut1 is the first lookup table curve; gain lut2 is the second lookup table curve. gain lut1[i] is the first curve value, i.e., the curve value corresponding to picture level i in the first lookup table curve. gain lut2[i] is the second curve value, i.e., the curve value corresponding to picture level i in the second lookup table curve. Add the first product ((L1-max_rgb_avg)*gain lut1[i]) and the second product ((max_rgb_avg-L2)*gain lut2[i]) to obtain the fusion curve value gain_lut[i] corresponding to the same picture level i. Based on the fusion curve value gain_lut[i] corresponding to the same picture level i, the corresponding gain_lut[i] is formed into a curve from i=0 to i=255 to obtain the calculation result Gain lut.
[0097] Obtaining the image color lookup table curve based on the calculation result may include: obtaining the previous frame image color lookup table curve corresponding to a predetermined number of previous frames of to-be-processed images before the image to be processed; performing mean calculation on the calculation result and the previous frame image color lookup table curve to obtain the image color lookup table curve.
[0098] Step S360 : performing correction and fusion processing on the image data of the foreground image and the background image based on the foreground color lookup table curve and the background color lookup table curve to obtain a processed image.
[0099] The method of performing correction and fusion processing on the image data of the foreground image and the background image based on the foreground color lookup table curve and the background color lookup table curve to obtain a processed image includes: performing mapping correction on the image data of the foreground image based on the foreground color lookup table curve to obtain foreground data; performing mapping correction on the image data of the background image based on the background color lookup table curve to obtain background data; and fusing the foreground data with the background data to obtain a processed image corresponding to the image to be processed.
[0100] In this scenario, image processing is performed by applying the embodiments of the present application, and a depth map of the image to be processed is obtained through analysis using a preset image analysis model. The image to be processed is divided into a foreground image and a background image according to the depth map, and then, correction and fusion processing are performed by respectively calculating the corresponding color lookup table curves to obtain the processed image. This avoids the stability problem of relying solely on intelligent models for image optimization processing, effectively improves the stability of the overall image processing process, and avoids sudden changes in picture processing while ensuring the optimization effect of picture expressiveness, thereby improving user experience.
[0101] To facilitate better implementation of the image processing method provided in the embodiments of this application, the embodiments of this application also provide an image processing device based on the aforementioned image processing method. The meanings of the terms herein are the same as those in the aforementioned image processing method. For specific implementation details, please refer to the description in the method embodiments. Figure 4 shows a block diagram of an image processing device according to one embodiment of the present application.
[0102] As shown in Figure 4, the image processing device 400 may include: an analysis module 410 can be used to analyze the image to be processed using a preset image analysis model to obtain a depth map of the image to be processed; a segmentation module 420 can be used to segment the image to be processed into near and far scenes according to the depth map to obtain a foreground image and a background image; a calculation module 430 can be used to respectively calculate a foreground color lookup table curve corresponding to the foreground image and a background color lookup table curve corresponding to the background image; an output module 440 can be used to perform correction and fusion processing on the image data of the foreground image and the background image based on the foreground color lookup table curve and the background color lookup table curve to obtain a processed image.
[0103] In some embodiments of the present application, the calculation module is used to: calculate the picture level mean corresponding to the image to be calculated, the image to be calculated includes the foreground image or the background image; calculate the color lookup table curve of the image to be calculated based on the picture level mean and a predetermined picture level interval to obtain a calculation result; obtain an image color lookup table curve based on the calculation result, the image color lookup table curve includes the foreground color lookup table curve or the background color lookup table curve.
[0104] In some embodiments of the present application, the calculation module is used to: if the scene corresponding to the image to be calculated contains a target object, select one of the first picture level mean and the second picture level mean that meets the predetermined stability condition to obtain the selected picture level mean; obtain the picture level mean corresponding to the image to be calculated based on the selected picture level mean, wherein the first picture level mean is the picture level mean of the image to be calculated, and the second picture level mean is the picture level mean of the image to be calculated in the previous frame.
[0105] In some embodiments of the present application, the calculation module is used to: if the scene corresponding to the image to be calculated does not have a target object, adjust the depth of field value of the image to be calculated according to the picture level adjustment table to obtain an adjusted depth of field; and calculate the picture level mean corresponding to the image to be calculated based on the adjusted depth of field.
[0106] In some embodiments of the present application, the calculation module is used to: map a predetermined picture level interval by querying a preset query table to obtain a first lookup table curve; perform peak method calculation on a focus sub-interval in the predetermined picture level interval to obtain a second lookup table curve; and perform calculation based on the first lookup table curve, the second lookup table curve and the picture level mean to obtain the calculation result.
[0107] In some embodiments of the present application, before calculating the color lookup table curve of the image to be calculated based on the picture level mean and the predetermined picture level interval and obtaining the calculation result, the device also includes a configuration module for: obtaining the predetermined picture level interval and the focus sub-interval corresponding to the scene according to the scene corresponding to the image to be processed, wherein the scene includes a first scene and a second scene, the first scene is a target object, and the second scene is a target object is not present, and the number of sub-intervals in the predetermined picture level interval corresponding to the first scene is less than the number of sub-intervals in the predetermined picture level interval corresponding to the second scene.
[0108] In some embodiments of the present application, the calculation module is used to: calculate the difference between the first interval value and the picture level mean to obtain a first difference, and the first interval value is the maximum value of the focus sub-interval; multiply the first difference by the first curve value to obtain a first product; calculate the difference between the picture level mean and the second interval value to obtain a second difference, and the second interval value is the minimum value of the focus sub-interval; multiply the second difference by the second curve value to obtain a second product, and the first curve value and the second curve value are curve values corresponding to the same picture level in the first lookup table curve and the second lookup table curve, respectively; add the first product and the second product to obtain the fusion curve value corresponding to the same picture level; and obtain the calculation result according to the fusion curve value corresponding to the same picture level.
[0109] In some embodiments of the present application, the calculation module is used to: obtain a previous frame image color lookup table curve corresponding to a predetermined number of previous frames of images to be calculated before the image to be processed; perform mean calculation on the calculation result and the previous frame image color lookup table curve to obtain the image color lookup table curve.
[0110] In some embodiments of the present application, the output module is used to: perform mapping correction on the image data of the foreground image based on the foreground color lookup table curve to obtain foreground data; perform mapping correction on the image data of the background image based on the background color lookup table curve to obtain background data; and fuse the foreground data and the background data to obtain a processed image corresponding to the image to be processed.
[0111] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiment of the application, the features and functions of two or more modules or units described above can be concretized in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be concretized.
[0112] In addition, an embodiment of the present application further provides an electronic device, as shown in FIG5 . FIG5 shows a block diagram of an electronic device according to an embodiment of the present application. Specifically:
[0113] The electronic device may include components such as a processor 501 with one or more processing cores, a memory 502 with one or more computer-readable storage media, a power supply 503, and an input unit 504. Those skilled in the art will appreciate that the electronic device structure shown in FIG5 does not limit the electronic device and may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0114] Processor 501 is the control center of the electronic device. It utilizes various interfaces and circuits to connect the various components of the entire computer device. By running or executing software programs and / or modules stored in memory 502 and accessing data stored in memory 502, it performs various computer device functions and processes data, thereby providing overall monitoring of the electronic device. Optionally, processor 501 may include one or more processing cores; preferably, processor 501 may integrate an application processor and a modem processor, wherein the application processor primarily processes the operating system, user interfaces, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into processor 501.
[0115] The memory 502 can be used to store software programs and modules. The processor 501 executes various functional applications and data processing by running the software programs and modules stored in the memory 502. The memory 502 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.); the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 502 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory 502 may also include a memory controller to provide the processor 501 with access to the memory 502.
[0116] The electronic device also includes a power supply 503 for supplying power to various components. Preferably, the power supply 503 can be logically connected to the processor 501 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The power supply 503 can also include one or more DC or AC power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components.
[0117] The electronic device may further include an input unit 504, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0118] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 501 in the electronic device will load the executable files corresponding to one or more computer program processes into the memory 502 according to the following instructions, and the processor 501 will run the computer program stored in the memory 502, thereby realizing the various functions of the aforementioned embodiments of the present application. For example, the processor 501 may perform the following steps:
[0119] A preset image analysis model is used to analyze an image to be processed to obtain a depth map of the image to be processed; the image to be processed is segmented into near and far scenes according to the depth map to obtain a foreground image and a background image; a foreground color lookup table curve corresponding to the foreground image and a background color lookup table curve corresponding to the background image are calculated respectively; and based on the foreground color lookup table curve and the background color lookup table curve, image data of the foreground image and the background image are corrected and fused to obtain a processed image.
[0120] In some embodiments of the present application, respectively calculating the foreground color lookup table curve corresponding to the foreground image and the background color lookup table curve corresponding to the background image includes: calculating the picture level mean corresponding to the image to be calculated, the image to be calculated including the foreground image or the background image; calculating the color lookup table curve of the image to be calculated based on the picture level mean and a predetermined picture level interval to obtain a calculation result; obtaining an image color lookup table curve according to the calculation result, the image color lookup table curve including the foreground color lookup table curve or the background color lookup table curve.
[0121] In some embodiments of the present application, the calculation of the picture level mean corresponding to the image to be calculated includes: if the scene corresponding to the image to be calculated is a scene in which a target object exists, selecting one of the first picture level mean and the second picture level mean that meets a predetermined stability condition to obtain a selected picture level mean; based on the selected picture level mean, obtaining the picture level mean corresponding to the image to be calculated, wherein the first picture level mean is the picture level mean of the image to be calculated, and the second picture level mean is the picture level mean of the image to be calculated in the previous frame.
[0122] In some embodiments of the present application, the calculation of the picture level mean corresponding to the image to be calculated includes: if the scene corresponding to the image to be calculated does not have a target object, adjusting the depth of field value of the image to be calculated according to the picture level adjustment table to obtain an adjusted depth of field; and calculating the picture level mean corresponding to the image to be calculated based on the adjusted depth of field.
[0123] In some embodiments of the present application, the color lookup table curve of the image to be calculated is calculated based on the picture level mean and the predetermined picture level interval to obtain a calculation result, including: mapping the predetermined picture level interval by querying a preset lookup table to obtain a first lookup table curve; performing a peak method calculation on the focus sub-interval in the predetermined picture level interval to obtain a second lookup table curve; and performing calculation according to the first lookup table curve, the second lookup table curve and the picture level mean to obtain the calculation result.
[0124] In some embodiments of the present application, before calculating the color lookup table curve of the image to be calculated based on the picture level mean and the predetermined picture level interval and obtaining the calculation result, it also includes: according to the scene corresponding to the image to be processed, obtaining the predetermined picture level interval and the focus sub-interval corresponding to the scene, wherein the scene includes a first scene and a second scene, the first scene is that there is a target object, and the second scene is that there is no target object, and the number of sub-intervals in the predetermined picture level interval corresponding to the first scene is less than the number of sub-intervals in the predetermined picture level interval corresponding to the second scene.
[0125] In some embodiments of the present application, the calculation based on the first lookup table curve, the second lookup table curve and the picture level mean to obtain the calculation result includes: calculating the difference between the first interval value and the picture level mean to obtain a first difference, and the first interval value is the maximum value of the focus sub-interval; multiplying the first difference by the first curve value to obtain a first product; calculating the difference between the picture level mean and the second interval value to obtain a second difference, and the second interval value is the minimum value of the focus sub-interval; multiplying the second difference by the second curve value to obtain a second product, and the first curve value and the second curve value are the curve values corresponding to the same picture level in the first lookup table curve and the second lookup table curve, respectively; adding the first product and the second product to obtain the fusion curve value corresponding to the same picture level; and obtaining the calculation result according to the fusion curve value corresponding to the same picture level.
[0126] In some embodiments of the present application, obtaining the image color lookup table curve based on the calculation result includes: obtaining the previous frame image color lookup table curve corresponding to a predetermined number of previous frames of images to be calculated before the image to be processed; performing mean calculation on the calculation result and the previous frame image color lookup table curve to obtain the image color lookup table curve.
[0127] In some embodiments of the present application, the correction and fusion processing is performed on the image data of the foreground image and the background image based on the foreground color lookup table curve and the background color lookup table curve to obtain a processed image, including: mapping and correcting the image data of the foreground image based on the foreground color lookup table curve to obtain foreground data; mapping and correcting the image data of the background image based on the background color lookup table curve to obtain background data; and fusing the foreground data and the background data to obtain a processed image corresponding to the image to be processed.
[0128] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by a computer program, or by controlling related hardware through a computer program. The computer program may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0129] To this end, an embodiment of the present application further provides a storage medium storing a computer program, which can be loaded by a processor to execute the steps of any method provided in the embodiment of the present application.
[0130] The storage medium may be a computer-readable storage medium, and the storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0131] Since the computer program stored in the storage medium can execute the steps of any method provided in the embodiments of the present application, the beneficial effects that can be achieved by the method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0132] Those skilled in the art will readily conceive of other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of this application and include common knowledge or customary techniques in the art that are not disclosed herein.
[0133] It should be understood that the present application is not limited to the embodiments that have been described above and shown in the accompanying drawings, but various modifications and changes may be made without departing from the scope thereof.
Claims
1. An image processing method, wherein, Including: Analyze a to-be-processed image using a preset image analysis model to obtain a depth-of-field map of the to-be-processed image; Perform foreground and background segmentation on the to-be-processed image according to the depth-of-field map to obtain a foreground image and a background image; Calculate a foreground color lookup table curve corresponding to the foreground image and a background color lookup table curve corresponding to the background image respectively; Based on the foreground color lookup table curve and the background color lookup table curve, perform calibration and fusion processing on the image data of the foreground image and the background image to obtain a processed image.
2. The method according to claim 1, wherein The step of calculating a foreground color lookup table curve corresponding to the foreground image and a background color lookup table curve corresponding to the background image respectively includes: Calculate a mean value of the picture level corresponding to the to-be-calculated image, where the to-be-calculated image includes the foreground image or the background image; Calculate a color lookup table curve of the to-be-calculated image based on the mean value of the picture level and a predetermined picture level interval to obtain a calculation result; Obtain an image color lookup table curve according to the calculation result, where the image color lookup table curve includes the foreground color lookup table curve or the background color lookup table curve.
3. The method according to claim 2, wherein The step of calculating a mean value of the picture level corresponding to the to-be-calculated image includes: If the scene corresponding to the to-be-calculated image has a target object, select one of a first mean value of the picture level and a second mean value of the picture level that meets a predetermined stability condition to obtain a selected mean value of the picture level; Obtain the mean value of the picture level corresponding to the to-be-calculated image according to the selected mean value of the picture level, where the first mean value of the picture level is the mean value of the picture level of the to-be-calculated image, and the second mean value of the picture level is the mean value of the picture level of the previous-frame to-be-calculated image.
4. The method according to claim 2, wherein The step of calculating a mean value of the picture level corresponding to the to-be-calculated image includes: If the scene corresponding to the to-be-calculated image has no target object, adjust the depth-of-field value of the to-be-calculated image according to a picture level adjustment table to obtain an adjusted depth of field; Calculate the mean value of the picture level corresponding to the to-be-calculated image according to the adjusted depth of field.
5. The method according to claim 2, wherein The step of calculating a color lookup table curve of the to-be-calculated image based on the mean value of the picture level and a predetermined picture level interval to obtain a calculation result includes: Map a predetermined picture level interval by querying a preset query table to obtain a first lookup table curve; Perform peak value method calculation on a concerned sub-interval in the predetermined picture level interval to obtain a second lookup table curve; Calculate according to the first lookup table curve, the second lookup table curve, and the mean value of the picture level to obtain the calculation result.
6. The method according to claim 5, wherein, Before calculating a color lookup table curve of the to-be-calculated image based on the mean value of the picture level and a predetermined picture level interval to obtain a calculation result, the method further includes: According to the scene corresponding to the image to be processed, obtain the corresponding predetermined picture level interval and the concerned sub-interval of the scene, where the scene includes a first scene and a second scene, the first scene is where there is a target object, the second scene is where there is no target object, and the number of sub-intervals in the predetermined picture level interval corresponding to the first scene is less than the number of sub-intervals in the predetermined picture level interval corresponding to the second scene.
7. The method according to claim 5, wherein The calculating the calculation result according to the first look-up table curve, the second look-up table curve, and the picture level mean value includes: Calculate the difference between the first interval value and the picture level mean value to obtain a first difference, where the first interval value is the maximum value of the concerned sub-interval; Multiply the first difference by the first curve value to obtain a first product; Calculate the difference between the picture level mean value and the second interval value to obtain a second difference, where the second interval value is the minimum value of the concerned sub-interval; Multiply the second difference by the second curve value to obtain a second product, where the first curve value and the second curve value are the curve values corresponding to the same picture level in the first look-up table curve and the second look-up table curve respectively; Add the first product and the second product to obtain the fusion curve value corresponding to the same picture level; Obtain the calculation result according to the fusion curve value corresponding to the same picture level.
8. The method according to claim 2, wherein, The obtaining the image color look-up table curve according to the calculation result includes: Obtain the previous frame image color look-up table curves corresponding to a predetermined number of previous frame images to be calculated before the image to be processed; Perform a mean value calculation on the calculation result and the previous frame image color look-up table curves to obtain the image color look-up table curve.
9. The method according to claim 1, wherein, The performing correction and fusion processing on the image data of the foreground image and the background image based on the foreground color look-up table curve and the background color look-up table curve to obtain a processed image includes: Perform mapping correction on the image data of the foreground image based on the foreground color look-up table curve to obtain foreground data; Perform mapping correction on the image data of the background image based on the background color look-up table curve to obtain background data; Fuse the foreground data and the background data to obtain the processed image corresponding to the image to be processed.
10. The method according to claim 3, wherein, The selecting one of the first picture level mean value and the second picture level mean value that meets the predetermined stability condition to obtain the selected picture level mean value includes: When the absolute value difference between the first picture level mean value and the second picture level mean value is less than a certain threshold, continue to use the second picture level mean value of the previous frame as the selected picture level mean value; otherwise, use the first picture level mean value as the selected picture level mean value.
11. The method according to claim 5, wherein, The obtaining the first look-up table curve by mapping the predetermined picture level interval through querying a preset query table includes: Query the mapping values of all pixels in each sub-interval in the predetermined picture level interval from the preset query table; Form the first look-up table curve according to all pixels in each sub-interval and the mapping values of all pixels in each sub-interval.
12. The method according to claim 5, wherein Performing peak method calculation on the concerned sub - interval in the predetermined picture level interval to obtain the second look - up table curve includes: Counting the gray level with the largest number of pixels in the concerned sub - interval to obtain the peak value; Mapping the peak value to the middle value of the LUT curve range, and sequentially mapping other gray levels in the concerned sub - interval to obtain the second look - up table curve.
13. An image processing apparatus, wherein, Including: An analysis module, configured to analyze the image to be processed by using a preset image analysis model to obtain the depth - of - field map of the image to be processed; A segmentation module, configured to perform foreground - background segmentation on the image to be processed according to the depth - of - field map to obtain a foreground image and a background image; A calculation module, configured to calculate the foreground color look - up table curve corresponding to the foreground image and the background color look - up table curve corresponding to the background image respectively; An output module, configured to perform correction and fusion processing on the image data of the foreground image and the background image based on the foreground color look - up table curve and the background color look - up table curve to obtain a processed image.
14. The device according to claim 13, wherein The calculation module is configured to: calculate the picture level mean value corresponding to the image to be calculated, where the image to be calculated includes the foreground image or the background image; calculate the color look - up table curve of the image to be calculated based on the picture level mean value and the predetermined picture level interval to obtain a calculation result; obtain the image color look - up table curve according to the calculation result, where the image color look - up table curve includes the foreground color look - up table curve or the background color look - up table curve.
15. The apparatus according to claim 14, wherein, The calculation module is configured to: if the scene corresponding to the image to be calculated is a scene with a target object, select one of the first picture level mean value and the second picture level mean value that meets the predetermined stability condition to obtain the selected picture level mean value; obtain the picture level mean value corresponding to the image to be calculated according to the selected picture level mean value, where the first picture level mean value is the picture level mean value of the image to be calculated, and the second picture level mean value is the picture level mean value of the previous frame of the image to be calculated.
16. The apparatus according to claim 14, wherein, The calculation module is configured to: if the scene corresponding to the image to be calculated is a scene without a target object, adjust the depth - of - field value of the image to be calculated according to the picture level adjustment table to obtain an adjusted depth - of - field; calculate the picture level mean value corresponding to the image to be calculated according to the adjusted depth - of - field.
17. The apparatus according to claim 14, wherein, The calculation module is configured to: map the predetermined picture level interval by querying a preset query table to obtain a first look - up table curve; perform peak method calculation on the concerned sub - interval in the predetermined picture level interval to obtain a second look - up table curve; calculate according to the first look - up table curve, the second look - up table curve and the picture level mean value to obtain the calculation result.
18. The device according to claim 17, wherein, Before calculating the color lookup table curve of the image to be calculated based on the screen level mean value and the predetermined screen level interval and obtaining the calculation result, the device further includes a configuration module for: according to the scene corresponding to the image to be processed, obtaining the predetermined screen level interval and the concerned sub-interval corresponding to the scene, where the scene includes a first scene and a second scene, the first scene is where there is a target object, the second scene is where there is no target object, and the number of sub-intervals in the predetermined screen level interval corresponding to the first scene is less than the number of sub-intervals in the predetermined screen level interval corresponding to the second scene.
19. A storage medium, wherein, A computer program is stored thereon, and when the computer program is executed by a processor of a computer, the computer is caused to execute the method according to any one of claims 1 to 12.
20. An electronic device, wherein, Comprising: A memory storing a computer program; A processor for reading the computer program stored in the memory to execute the method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Image dynamic range adjustment method and apparatus
CN105488765A
Image DMA controller and implementation method thereof
CN114168505A
Method and apparatus for saliency-based frame color enhancement
CN116998145A
Image processing method and device, storage medium and electronic equipment
CN118096813A