Image processing method and device
By performing area division and transformation matrix calculation on the image, the problem of poor tone matching of the existing filter migration method is solved, and a more natural tone uniform effect is achieved.
Patent Information
- Application Number
- CN202110389102.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-12
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2041-04-12
AI Technical Summary
The existing filter migration method is not effective when adjusting the tone style of the original image, and cannot effectively match the tone style of the reference image, resulting in unnatural filter migration effect.
By dividing the original image and the reference image into multiple regions according to the brightness value of the pixel points, the transformation matrix of each region is calculated separately, and color mapped on the original image according to these matrices, the target image is obtained so that the colors in each region are colored. Values are processed separately for a more natural tone matching.
The filter migration effect is improved, making the tone of the target image closer to the reference image, achieving a more natural tone unity.
Smart Images

Figure CN115205167B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer vision technology, and in particular to an image processing method and device. Background Art
[0002] In many scenarios, it is necessary to perform a filter migration operation on an image or video, that is, to adjust the tone style of the original image / video according to the tone style of the reference image / video so that the tone of the original image / video is consistent with that of the reference image / video.
[0003] The existing filter migration method matches the histogram of each channel of the original image with the histogram of each channel of the reference image, so that the histogram of each channel of the original image is close to the reference image.
[0004] However, the filter migration effect obtained in this way is not good. Summary of the invention
[0005] In order to solve the above technical problems, the present disclosure provides an image processing method and device.
[0006] In a first aspect, the present disclosure provides an image processing method, comprising:
[0007] Dividing the original image into a plurality of original regions; the plurality of original regions at least include a first region and a second region, and the brightness value of the pixel points in the first region is greater than the brightness value of the pixel points in the second region;
[0008] Dividing the reference image into a plurality of reference areas; the reference areas at least include a third area and a fourth area, wherein the brightness value of the pixel points in the third area is greater than the brightness value of the pixel points in the fourth area;
[0009] Obtain a transformation matrix for the first region according to the color values of the pixels in the first region and the color values of the pixels in the third region, and obtain a transformation matrix for the second region according to the color values of the pixels in the second region and the color values of the pixels in the fourth region;
[0010] The original image is color mapped according to the transformation matrix of the first region and the change matrix of the second region to obtain a target image.
[0011] Optionally, obtaining a transformation matrix of the first region according to the color values of the pixels in the first region and the color values of the pixels in the third region, and obtaining a transformation matrix of the second region according to the color values of the pixels in the second region and the color values of the pixels in the fourth region, includes:
[0012] According to the color values of the pixels in the multiple original regions, the covariance matrices of the color channel dimensions corresponding to the multiple original regions are calculated;
[0013] Calculate the covariance matrix of the color channel dimensions corresponding to the multiple reference areas according to the color values of the pixels in the multiple reference areas;
[0014] Determine a transformation matrix of the first region based on a covariance matrix of a color channel dimension corresponding to the first region and a covariance matrix of a color channel dimension corresponding to the third region;
[0015] A transformation matrix of the second region is determined based on a covariance matrix of a color channel dimension corresponding to the second region and a covariance matrix of a color channel dimension corresponding to the fourth region.
[0016] Optionally, color mapping is performed on the original image according to the transformation matrix of the first region and the change matrix of the second region to obtain the target image, including:
[0017] Processing the color values of the pixels in the original image according to the transformation matrix of the first region to obtain a first corrected image corresponding to the transformation matrix of the first region;
[0018] Processing the color values of the pixels in the original image according to the transformation matrix of the second region to obtain a second corrected image corresponding to the transformation matrix of the second region;
[0019] The first corrected image and the second corrected image are fused to obtain the target image.
[0020] Optionally, color mapping is performed on the original image according to the transformation matrix of the first region and the change matrix of the second region to obtain the target image, including:
[0021] Processing the color values of the pixels in the first region according to the transformation matrix of the first region to obtain a first correction region corresponding to the first region;
[0022] Processing the color values of the pixels in the second region according to the transformation matrix of the second region to obtain a second correction region corresponding to the second region;
[0023] The first corrected area and the second corrected area are spliced to obtain a target image.
[0024] Optionally, the original image is divided into a plurality of original regions, including:
[0025] Arrange the pixels in the original image from low to high according to the brightness value, and determine at least one first dividing value;
[0026] Dividing pixels in the original image into a plurality of original regions based on at least one first dividing value;
[0027] The reference image is divided into multiple reference regions, including:
[0028] Arrange the pixels in the reference image from low to high according to brightness values, and determine at least one second dividing value;
[0029] The pixels in the reference image are divided into a plurality of reference areas based on at least one second dividing value.
[0030] Optionally, the multiple original regions further include a fifth region, and the brightness value of the pixel points in the fifth region is greater than the brightness value of the pixel points in the first region, or the brightness value of the pixel points in the fifth region is less than the brightness value of the pixel points in the second region;
[0031] The reference area further includes a sixth area, wherein the brightness value of the pixel points in the sixth area is greater than the brightness value of the pixel points in the third area, or the brightness value of the pixel points in the sixth area is less than the brightness value of the pixel points in the fourth area;
[0032] The method also includes:
[0033] Obtaining a transformation matrix for the fifth region according to color values of pixels in the fifth region and color values of pixels in the sixth region;
[0034] Performing color mapping on the original image according to the transformation matrix of the first region and the change matrix of the second region to obtain a target image includes:
[0035] According to the transformation matrix of the first region, the change matrix of the second region and the transformation matrix of the fifth region, color mapping is performed on the original image to obtain a target image.
[0036] In a second aspect, the present disclosure provides an image processing device, comprising:
[0037] A region division module is used to divide an original image into a plurality of original regions; the plurality of original regions include at least a first region and a second region, and the brightness value of a pixel in the first region is greater than the brightness value of a pixel in the second region; divide a reference image into a plurality of reference regions; the reference regions include at least a third region and a fourth region, and the brightness value of a pixel in the third region is greater than the brightness value of a pixel in the fourth region;
[0038] A transformation matrix generation module, used to obtain a transformation matrix of the first area according to the color values of the pixels in the first area and the color values of the pixels in the third area, and to obtain a transformation matrix of the second area according to the color values of the pixels in the second area and the color values of the pixels in the fourth area;
[0039] The processing module is used to perform color mapping on the original image according to the transformation matrix of the first area and the change matrix of the second area to obtain a target image.
[0040] Optionally, the transformation matrix generation module is specifically used for:
[0041] According to the color values of the pixels in the multiple original areas, the covariance matrices of the color channel dimensions corresponding to the multiple original areas are calculated; according to the color values of the pixels in the multiple reference areas, the covariance matrices of the color channel dimensions corresponding to the multiple reference areas are calculated; based on the covariance matrix of the color channel dimension corresponding to the first area and the covariance matrix of the color channel dimension corresponding to the third area, the transformation matrix of the first area is determined; based on the covariance matrix of the color channel dimension corresponding to the second area and the covariance matrix of the color channel dimension corresponding to the fourth area, the transformation matrix of the second area is determined.
[0042] Optionally, the processing module is specifically used for:
[0043] According to the transformation matrix of the first area, the color values of the pixels in the original image are processed to obtain a first corrected image corresponding to the transformation matrix of the first area; according to the transformation matrix of the second area, the color values of the pixels in the original image are processed to obtain a second corrected image corresponding to the transformation matrix of the second area; the first corrected image and the second corrected image are fused to obtain the target image.
[0044] Optionally, the processing module is specifically used for:
[0045] According to the transformation matrix of the first area, the color values of the pixels in the first area are processed to obtain a first correction area corresponding to the first area; according to the transformation matrix of the second area, the color values of the pixels in the second area are processed to obtain a second correction area corresponding to the second area; the first correction area and the second correction area are spliced to obtain a target image.
[0046] Optionally, the region division module is specifically used for:
[0047] Arrange the pixels in the original image from low to high according to the brightness value, and determine at least one first dividing value; divide the pixels in the original image into multiple original areas based on the at least one first dividing value; arrange the pixels in the reference image from low to high according to the brightness value, and determine at least one second dividing value; divide the pixels in the reference image into multiple reference areas based on the at least one second dividing value.
[0048] Optionally, the multiple original regions further include a fifth region, and the brightness value of the pixel points in the fifth region is greater than the brightness value of the pixel points in the first region, or the brightness value of the pixel points in the fifth region is less than the brightness value of the pixel points in the second region;
[0049] The reference area further includes a sixth area, wherein the brightness value of the pixel points in the sixth area is greater than the brightness value of the pixel points in the third area, or the brightness value of the pixel points in the sixth area is less than the brightness value of the pixel points in the fourth area;
[0050] The transformation matrix generation module is also used to:
[0051] Obtaining a transformation matrix for the fifth region according to color values of pixels in the fifth region and color values of pixels in the sixth region;
[0052] The processing module is specifically used for:
[0053] According to the transformation matrix of the first region, the change matrix of the second region and the transformation matrix of the fifth region, color mapping is performed on the original image to obtain a target image.
[0054] In a third aspect, the present disclosure provides an electronic device, comprising: one or more processors; a memory; and one or more computer programs; wherein the one or more computer programs are stored in the memory; when the one or more processors execute the one or more computer programs, the electronic device implements the image processing method as described in the first aspect above.
[0055] In a fourth aspect, the present disclosure provides a computer storage medium, comprising computer instructions, which, when executed on an electronic device, enables the electronic device to execute the image processing method of the first aspect.
[0056] In a fifth aspect, the present disclosure provides a computer program product. When the computer program product is run on a computer, the computer executes the image processing method of the first aspect.
[0057] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has the following advantages:
[0058] The original image is divided into a plurality of original regions, the plurality of original regions at least include a first region and a second region, the brightness value of the pixel in the first region is greater than the brightness value of the pixel in the second region, and the reference image is divided into at least two reference regions, thereby, according to the brightness values of the original image and the reference image, the original image and the reference image are respectively divided into one-to-one corresponding regions. According to the color values of the pixel in the first region and the color values of the pixel in the third region, the transformation matrix of the first region is obtained, and according to the color values of the pixel in the second region and the color values of the pixel in the fourth region, the transformation matrix of the second region is obtained, that is, according to different regions, separate processing is performed, and the transformation matrix corresponding to each region is obtained according to the color value, and then the original image is color mapped according to the transformation matrix of the first region and the change matrix of the second region to obtain the target image. The pixels in the image are divided into regions according to the brightness value, and the color values in each region are separately processed to obtain the transformation matrix, and the filter migration process is performed according to the at least two obtained transformation matrices, so that the obtained target image is more natural, and the target image is closer to the reference image in terms of hue, so that the filter migration effect is better. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0060] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0061] Figure 1A is a schematic diagram of an original image;
[0062] Figure 1B is a schematic diagram of a reference image;
[0063] Figure 1C A schematic diagram of filter migration results;
[0064] Figure 2 A flowchart of an image processing method provided by an embodiment of the present disclosure;
[0065] Figure 3 A flowchart of another image processing method provided by an embodiment of the present disclosure;
[0066] Figure 4 A flowchart of another image processing method provided by an embodiment of the present disclosure;
[0067] Figure 5 A flowchart of another image processing method provided by an embodiment of the present disclosure;
[0068] Figure 6 A flowchart of another image processing method provided by an embodiment of the present disclosure;
[0069] Figure 7 A schematic diagram of the structure of an image processing device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0070] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0071] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0072] In many scenarios, it is necessary to perform filter migration operations on images or videos through electronic devices. Filter migration refers to adjusting the tone style of the original image / video according to the tone style of the reference image / video so that the tone of the original image / video is consistent with that of the reference image / video.
[0073] For image filter migration, the original image's tone style needs to be adjusted according to the reference image's tone style, so that the original image and the reference image have the same tone. For example, to create a certain atmosphere, the original image's tone will be adjusted according to actual needs, or, when the tones of multiple images are inconsistent, the image filter migration is performed to unify the tones of multiple images. Please refer to Figure 1A , Figure 1B and Figure 1C , Figure 1A is a schematic diagram of an original image. Figure 1B is a schematic diagram of a reference image. Figure 1C A schematic diagram of filter migration results.
[0074] Video images are composed of multiple frames. The filter migration of videos is similar to the filter migration of images. The tone style of each frame of the original image in the video is adjusted according to the tone style of the reference image so that the tone of each frame of the original image is consistent with that of the reference image. For example, in the process of film production or video editing, due to the different shooting environments, shooting times and / or shooting ambient light of each video clip, there are differences in tone between each video clip. It is necessary to unify the tones of these clips so that they appear more natural after being spliced together. In these cases, it is necessary to quickly unify the tones of multiple video clips.
[0075] The existing filter migration method matches the histogram of each channel of the original image with the histogram of each channel of the reference image respectively, so that the histogram of each channel of the original image is close to the reference image.
[0076] However, the filter migration effect obtained in this way is not good.
[0077] The present disclosure provides an image processing method, which divides an original image and a reference image into regions according to the brightness values of pixels, and for each corresponding region, obtains a transformation matrix from the original image to a target image in the region based on the color values of the pixels in the original image and the reference image, thereby obtaining at least two transformation matrices according to regions with different brightness values, and obtains a target image according to the at least two transformation matrices, so that the obtained target image is more natural and has a good filter migration effect.
[0078] Figure 2 A flowchart of an image processing method provided by an embodiment of the present disclosure is shown in FIG. Figure 2As shown, the method of this embodiment is executed by an electronic device, which may be a computer, a mobile phone, a tablet device, etc., and the present disclosure does not limit this. The method of this embodiment is as follows:
[0079] S201, dividing an original image into a plurality of original regions.
[0080] The multiple original areas include at least a first area and a second area, and the brightness value of the pixel points in the first area is greater than the brightness value of the pixel points in the second area.
[0081] S202: Divide the reference image into multiple reference areas.
[0082] The reference area at least includes a third area and a fourth area, wherein the brightness value of the pixel points in the third area is greater than the brightness value of the pixel points in the fourth area.
[0083] The original image and the reference image are obtained, wherein the filter of the reference image needs to be transferred to the original image.
[0084] The color spaces of the original image and the reference image respectively include a brightness value channel and a color value channel. For example, the color space can be Lab, brightness-color difference (YUV) or brightness-hue (Lαβ) color space, etc., wherein, in the Lab color space, L represents brightness; a represents the first parameter, and the value range of a is +127 to -128, wherein a positive number represents red and a negative number represents green; b represents the second parameter, and the value range of b is +127 to -128, wherein a positive number represents yellow and a negative number represents blue. The present disclosure does not limit this. In this embodiment, the YUV color space is taken as an example for explanation. The YUV color space includes three channels, namely, the Y channel, the U channel and the V channel, wherein the Y channel is the brightness value channel, and the U channel and the V channel are the color value channels.
[0085] The color space of the reference image is the same as the color space of the original image. If the color space of the reference image is different from that of the original image, conversion is required so that the reference image and the original image are in the same color space.
[0086] Optionally, when the original image is obtained in a color space without a brightness value channel, for example, the color space of the original image may be a color space such as Red Green Blue (RGB) or Cyan Magenta Yellow Black (CMYK), and the present disclosure does not limit this. The original image may be first converted into a color space including a brightness value channel and a color value channel. For example, if processing is required in a YUV color space, the original image may be converted from an RGB color space to a YUV color space, and then subsequent processing may be performed.
[0087] In the case where the reference image is obtained in a color space without a brightness value channel, for example, the color space of the reference image may be a color space such as RGB or CMYK, which is not limited in the present disclosure. The reference image may be first converted into a color space including a brightness value channel and a color value channel. For example, if processing is required in a YUV color space, the reference image may be converted from an RGB color space to a YUV color space, and then subsequent processing may be performed.
[0088] The pixels in the original image may be divided into regions according to the brightness values of the pixels in the original image to obtain multiple original regions. For example, in the YUV color space, the pixels in the original image may be divided into regions according to the brightness values of the Y channel of the original image to divide all the pixels into multiple original regions.
[0089] Accordingly, the pixels in the reference image may be divided into regions according to the brightness values of the pixels in the reference image to obtain multiple reference regions. For example, the pixels in the original image may be divided into regions according to the brightness values of the Y channel of the reference image to divide all the pixels into multiple reference regions.
[0090] The number of original regions obtained is the same as the number of reference regions, and the original regions correspond one-to-one to the reference regions. Subsequently, the divided original regions and the corresponding reference regions are processed separately. That is, for the original image, multiple original regions are obtained according to the brightness values of the pixels and the preset rules. For the reference image, multiple reference regions are obtained according to the brightness values of the pixels and the preset rules. If the above preset rules are the same, the obtained original regions correspond one-to-one to the reference regions. For example, the preset rule may be to arrange the pixels in the image from high to low, or from low to high according to the brightness value, and then divide the regions according to the order of arrangement. Therefore, the obtained original regions correspond one-to-one to the reference regions, that is, the first region corresponds to the third region, and the second region corresponds to the fourth region.
[0091] Assume that the preset rule is to divide an image into two areas according to the brightness value from high to low, and the pixels corresponding to the brightness value of the first half are divided into the first area, and the pixels corresponding to the brightness value of the second half are divided into the second area. Then the closer the divided area is to the front, the larger the brightness value of the pixels in the area. The original image and the reference image are processed according to the preset rules below. The pixels in the original image are arranged from high to low according to the brightness value, and the pixels corresponding to the brightness value of the first half are divided into the first area, and the pixels corresponding to the brightness value of the second half are divided into the second area. Correspondingly, the pixels in the reference image are arranged from high to low according to the brightness value, and the pixels corresponding to the brightness value of the first half are divided into the third area, and the pixels corresponding to the brightness value of the second half are divided into the fourth area. Then the first area 1 corresponds to the third area, and the second area 2 corresponds to the fourth area.
[0092] It can be understood that there is no order for executing steps S201 and S202. S201 can be executed first and then S202, or S202 can be executed first and then S201, or S201 and S202 can be executed simultaneously. The present disclosure does not limit this.
[0093] S203, obtaining a transformation matrix of the first region according to the color values of the pixels in the first region and the color values of the pixels in the third region, and obtaining a transformation matrix of the second region according to the color values of the pixels in the second region and the color values of the pixels in the fourth region.
[0094] Filter migration is a color mapping process, that is, the color of the original image is mapped to obtain the color of the mapped target image. The color of the target image can be obtained through the color mapping function and the color of the original image, that is, v = T (u), where v is the color of the target image, u is the color of the original image, and T is the color mapping function. The colors of the reference image and the target image to be obtained are similar. Therefore, the mapping function can be determined based on the colors of the original image and the reference image, and the target image can be obtained to realize filter migration. In order to obtain the target image, it is necessary to determine the mapping function first.
[0095] For each original region and the reference region corresponding to the original region, the transformation matrix of the original region is obtained according to the color value of the pixel in the original region and the color value of the pixel in the reference region, wherein the color value of the pixel in the original region is the value of the pixel in the color channel in the original region, and the color value of the pixel in the reference region is the value of the pixel in the color channel in the reference region.
[0096] Since the first area corresponds to the third area, and the second area corresponds to the fourth area, the transformation matrix of the first area is obtained according to the color values of the pixels in the first area and the color values of the pixels in the third area, and the transformation matrix of the second area is obtained according to the color values of the pixels in the second area and the color values of the pixels in the fourth area. Among them, the color value of the pixel in the first area is the value of the pixel in the color channel in the first area. The color value of the pixel in the second area is the value of the pixel in the color channel in the second area. The color value of the pixel in the third area is the value of the pixel in the color channel in the third area. The color value of the pixel in the fourth area is the value of the pixel in the color channel in the fourth area.
[0097] Taking the original image and the reference image as YUV color space as an example, the color value of the pixel in a certain area is the value of the U channel and the value of the V channel of all the pixels in the area. For example, the color value of the pixel in the first area is the value of the U channel and the value of the V channel of all the pixels in the first area.
[0098] In the color space to which the original image and the reference image belong, when there are two or more color channels, in a possible implementation, the transformation matrix obtained for each original region may be one. For example, the covariance transformation matrix of at least two color channels corresponding to the pixels of the original region may be obtained.
[0099] In another possible implementation, for each color channel in each original region, a transformation matrix corresponding to each color channel may be obtained, and the number of transformation matrices of the original region is the same as the number of color channels. For example, a standard deviation is obtained for each color channel.
[0100] S204 , performing color mapping on the original image according to the transformation matrix of the first region and the change matrix of the second region to obtain a target image.
[0101] According to the transformation matrix of each original region, the color channels of the original image are color mapped to obtain each color mapping result, and each color mapping result is merged with the brightness value of the original image to obtain the target image. That is, according to the transformation matrix of the first region and the change matrix of the second region, the original image is color mapped to obtain two color mapping results, and the two color mapping results are merged with the brightness value of the original image to obtain the target image.
[0102] Furthermore, in a possible implementation method of obtaining each color transformation result, each color transformation result can be obtained according to the transformation matrix of each original area, the color mean of each original area and the color mean of each reference area. Among them, the color mean of the original area is the average value of the color values of all pixels in the original area. The color mean of the reference area is the average value of the color values of all pixels in the reference area. The color mean is the average value calculated separately for each color channel. Taking the YUV color space as an example, the color mean is the average value of the value of the U channel and the average value of the value of the V channel.
[0103] Furthermore, in a possible implementation method of fusing each color transformation result with the brightness value of the original image to obtain the target image, the color value of the target image can be obtained based on all the color transformation results obtained, and the color value of each pixel point is fused with the corresponding brightness value of the original image to obtain the target image.
[0104] Optionally, if before performing the above-mentioned image processing steps, if the original image is in a color space without a brightness value channel, then before processing the original image, the original image needs to be converted into a color space containing a brightness value channel and a color channel, and then the original image is processed. In this case, the color space to which the obtained target image belongs is different from the color space to which the original image belongs, and the color space to which the target image belongs needs to be converted into the color space of the original image before performing the above-mentioned image processing steps.
[0105] For example, the original image is in RGB color space. Before performing the above image processing steps, the original image is converted from RGB color space to YUV color space. Thus, through the above image processing steps, the target image obtained is in YUV color space. The target image is converted from YUV color space to RGB color space to obtain the final target image.
[0106] In this embodiment, the original image is divided into a plurality of original regions, the plurality of original regions at least include a first region and a second region, the brightness value of the pixel in the first region is greater than the brightness value of the pixel in the second region, and the reference image is divided into at least two reference regions, thereby, according to the brightness values of the original image and the reference image, the original image and the reference image are respectively divided into one-to-one corresponding regions. According to the color values of the pixels in the first region and the color values of the pixels in the third region, the transformation matrix of the first region is obtained, and according to the color values of the pixels in the second region and the color values of the pixels in the fourth region, the transformation matrix of the second region is obtained, that is, according to different regions, separate processing is performed, and the transformation matrix corresponding to each region is obtained according to the color value, and then the original image is color mapped according to the transformation matrix of the first region and the change matrix of the second region to obtain the target image. The pixels in the image are divided into regions according to the brightness value, and the color values in each region are separately processed to obtain the transformation matrix, and the filter migration process is performed according to the at least two obtained transformation matrices, so that the obtained target image is more natural, and the target image is closer to the reference image in terms of hue, so that the filter migration effect is better.
[0107] Further, in Figure 2 Based on the embodiment shown, a possible implementation of S201 and S202 is to arrange the pixels from low to high according to the brightness value, determine the boundary value of the region division, and then divide the region according to the boundary value, see Figure 3 , Figure 3 A flowchart of another image processing method provided by an embodiment of the present disclosure is shown in FIG. Figure 3 is Figure 2 On the basis of the embodiment shown, S2011 and S2012 are a specific implementation of S201, and correspondingly, S2021 and S2022 are a specific implementation of S202:
[0108] S2011. Arrange the pixels in the original image from low to high according to the brightness values, and determine at least one first dividing value.
[0109] S2012. Divide the pixels in the original image into a plurality of original regions based on at least one first boundary value.
[0110] Each pixel in the original image corresponds to a brightness value. These brightness values can be obtained and arranged in order from low to high to form a brightness value sequence. At least one first boundary value is determined according to a preset value selection rule.
[0111] The preset value-taking rule is to obtain a first delimiting value for every preset number of brightness values. Exemplarily, the preset value-taking rule may be to obtain a first delimiting value for every same number of brightness values, and the first delimiting value divides the brightness value sequence equally. If the total number of pixels cannot be completely evenly divided, the pixels corresponding to the first delimiting value may be divided into two adjacent original areas, or divided into one of the two adjacent original areas, and the present disclosure does not limit this.
[0112] For example, the brightness values of the pixels in the acquired original image are 20, 30, 50, 200, 50, 150, 150, 210 and 160 respectively. They are first arranged from low to high to obtain a brightness value sequence of 20, 30, 50, 50, 150, 150, 160, 200, 210. Assuming that the pixels are divided into two original areas according to the brightness values, the first dividing value can be 150. Since the total number of pixels is 9, it is impossible to achieve a complete equal division by dividing them into two original areas. Therefore, the original areas divided according to the first dividing value can be the second area containing 20, 30, 50, 50 pixels and the first area containing 150, 150, 160, 200, 210 pixels. The second area may also include 20, 30, 50, 50, 150 pixels and the first area may include 150, 160, 200, 210 pixels, wherein the two pixels with a brightness value of 150 are respectively divided into the first area and the second area, and which one is divided into the first area is not disclosed and not limited.
[0113] S2021. Arrange the pixels in the reference image from low to high according to brightness values, and determine at least one second dividing value.
[0114] S2022. Divide the pixels in the reference image into a plurality of reference areas based on at least one second dividing value.
[0115] Steps S2021-S2022 are similar to the above-mentioned steps S2011-S2012 and will not be repeated here.
[0116] It should be noted that the number of the first delimiting values is equal to the number of the second delimiting values, and the preset value selection rules for obtaining the first delimiting values and the second delimiting values are the same.
[0117] In this embodiment, when the original image and the reference image are divided into regions, the same number of demarcation values are determined according to the brightness values of the respective pixels arranged from low to high, and then the regions are divided according to the demarcation values. Since the number of the first demarcation value is equal to the number of the second demarcation value, the number of the original region and the reference region is equal, and the region division is performed according to the demarcation value obtained by arranging the brightness values from low to high, so that the original region of the original image corresponds to the reference region of the reference image one by one. It is convenient to perform subsequent processing, so that the target image is more natural and closer to the reference image in terms of color tone, so that the filter migration effect is better.
[0118] exist Figure 3 On the basis of the embodiment, further, this embodiment is further explained by taking the case where the number of the first demarcation value and the second demarcation value are both two, that is, the original image and the reference image are both divided into three regions as an example.
[0119] A specific implementation method of step S2011 is: arrange the pixels in the original image from low to high according to the brightness value, and determine two first dividing values.
[0120] Correspondingly, a specific implementation method of S2012 is: dividing the pixel points into three original areas based on the two first boundary values.
[0121] That is, in addition to the first area and the second area, the original area also includes a fifth area, wherein the brightness value of the pixel points in the fifth area is greater than the brightness value of the pixel points in the first area, or the brightness value of the pixel points in the fifth area is less than the brightness value of the pixel points in the second area.
[0122] Taking the YUV color space as an example, the Y channel is a brightness value channel, and the cumulative distribution of the brightness values of the pixels of the original image on the Y channel can be counted to determine the two first dividing values, and the three original areas can be obtained.
[0123] For example, the brightness values corresponding to the first 1 / 3 of the cumulative distribution of the brightness values of the pixels are used as the first dividing point between the dark part and the mid-tone, and the brightness values corresponding to the first 2 / 3 are used as the first dividing point between the mid-tone and the highlight. According to the above two first dividing points, the pixels in the original image are divided into three original areas. The first original area of the three original areas has the lowest brightness of the pixels, which can be called the original dark area; the second original area has a higher brightness of the pixels than the first original area, which can be called the original mid-tone area; the third original area has the highest brightness of the pixels, which can be called the original highlight area.
[0124] A specific implementation method of S2021 may be: arranging the pixel points in the reference image from low to high according to the brightness value, and determining two second dividing values.
[0125] Accordingly, a specific implementation manner of S2022 may be: dividing the pixel points into three reference areas based on the two second dividing values.
[0126] That is, in addition to the third area and the fourth area, the reference area also includes the sixth area, wherein the brightness value of the pixel points in the sixth area is greater than the brightness value of the pixel points in the third area, or the brightness value of the pixel points in the sixth area is less than the brightness value of the pixel points in the fourth area.
[0127] It should be noted that the sixth region corresponds to the fifth region. If the brightness value of the pixel in the fifth region is greater than the brightness value of the pixel in the first region, the brightness value of the pixel in the sixth region is greater than the brightness value of the pixel in the third region. If the brightness value of the pixel in the fifth region is less than the brightness value of the pixel in the second region, the brightness value of the pixel in the sixth region is less than the brightness value of the pixel in the fourth region.
[0128] Taking the YUV color space as an example, the cumulative distribution of the brightness values of the pixels of the reference image on the Y channel can be statistically analyzed to determine two second dividing values. Based on the two second dividing values, three reference areas can be obtained.
[0129] For example, the brightness values corresponding to the first 1 / 3 of the cumulative distribution of the brightness values of the pixels are used as the second dividing point between the dark part and the mid-tone, and the brightness values corresponding to the first 2 / 3 are used as the second dividing point between the mid-tone and the highlight. According to the above two second dividing points, the pixels are divided into three reference areas. The first reference area among the three reference areas has the lowest brightness of the pixels, which can be called the reference dark area; the second reference area has a higher brightness of the pixels than the first reference area, which can be called the reference mid-tone area; the third reference area has the highest brightness of the pixels, which can be called the reference highlight area.
[0130] Then the original dark area corresponds to the reference dark area, the original midtone area corresponds to the reference midtone area, and the original highlight area corresponds to the reference highlight area.
[0131] Therefore, the method of this embodiment further includes the following steps based on the method of the above embodiment:
[0132] A transformation matrix of the fifth region is obtained according to the color values of the pixels in the fifth region and the color values of the pixels in the sixth region.
[0133] Since the fifth region corresponds to the sixth region, the transformation matrix of the fifth region is obtained using a method similar to that of obtaining the transformation matrix of the first region.
[0134] Accordingly, a specific method of S204 is:
[0135] According to the transformation matrix of the first region, the change matrix of the second region and the transformation matrix of the fifth region, color mapping is performed on the original image to obtain a target image.
[0136] Thus, according to the transformation matrices corresponding to the first region, the second region and the fifth region respectively, the original image is color mapped to obtain a target image.
[0137] In this embodiment, the original image is divided into three regions, and the reference image is divided into three regions, so that when divided into three regions, the transformation matrix corresponding to each region is obtained respectively, thereby obtaining the target image. The more regions are divided, the better the filter migration effect of the target image is obtained, but the corresponding amount of calculation will also increase. Therefore, dividing into three regions can make the amount of calculation moderate and achieve a better filter migration effect.
[0138] Based on the above embodiment, in one implementation of S203, the transformation matrix can be determined by calculating the covariance matrix, see Figure 4 , Figure 4 A flowchart of another image processing method provided by an embodiment of the present disclosure is shown in FIG. Figure 4 is Figure 2 or Figure 3 Based on the embodiment shown, S2031-S2034 is a specific implementation of S203:
[0139] S2031. Calculate the covariance matrix of the color channel dimensions corresponding to the multiple original regions respectively according to the color values of the pixel points in the multiple original regions.
[0140] S2032. Calculate the covariance matrices of the color channel dimensions corresponding to the multiple reference areas respectively according to the color values of the pixels in the multiple reference areas.
[0141] In the color space to which the original image and the reference image belong, there are two or more color channels, and covariance matrices of the color channel dimensions corresponding to the multiple original regions are calculated, wherein the covariance matrix of the color channel dimension is a covariance transformation matrix calculated with the color channels contained in the color space as the dimension.
[0142] Exemplarily, taking the YUV color space as an example, the U channel value and the V channel value of each pixel in the first area are taken as a two-dimensional variable, and the color values of all pixels in the first area can be regarded as a series of two-dimensional variables. The covariance matrix corresponding to the first area can be calculated. It can be understood that the two dimensions of its two-dimensional variables are the U channel and the V channel, and the covariance matrix is a 2×2 matrix. Then a 2×2 covariance matrix can be obtained for each original area. Correspondingly, the U channel value and the V channel value of the pixel in the third area are taken as a series of two-dimensional variables, and the covariance matrix corresponding to the third area is calculated. It can be understood that the two dimensions of its two-dimensional variables are the U channel and the V channel, and the covariance matrix is a 2×2 matrix. Then a 2×2 covariance matrix can be obtained for each reference area.
[0143] It should be noted that there is no order for the execution of steps S2031 and S2032. S2031 may be executed first and then S2032, or S2032 may be executed first and then S2031, or S2031 and S2032 may be executed simultaneously. The present disclosure does not limit this.
[0144] S2033. Determine a transformation matrix for the first region based on a covariance matrix of a color channel dimension corresponding to the first region and a covariance matrix of a color channel dimension corresponding to the third region.
[0145] S2034. Determine a transformation matrix for the second region based on the covariance matrix of the color channel dimension corresponding to the second region and the covariance matrix of the color channel dimension corresponding to the fourth region.
[0146] Depend on Figure 2 It can be seen from the illustrated embodiment that the color v of the target image can be obtained through the color mapping function T and the color u of the original image, that is, v=T(u). Here, the mapping function T needs to be determined, and then the color v of the target image can be obtained. Since a linear function is sufficient to fit the color mapping situation, and the solution of the linear function is relatively simple, the computational complexity is low, and the mapping function T can be a linear function, that is, the color v of the target image can be expressed as v=a*u+b, where a and b are parameters, and the color u of the original image can be converted into the color v of the target image through the linear transformation T. According to the mathematical theory of linear transformation, if there is a linear transformation between two variables, the linear transformation has a covariance matrix applicable to the two variables. Since the color style of the target image is similar to the color style of the reference image, the covariance matrix of the original image is equal to the covariance matrix of the reference image after the linear transformation T. The mapping function can be obtained through the covariance matrix of the original image and the covariance matrix of the reference image.
[0147] Therefore, for each original area obtained above and its corresponding reference area, a transformation matrix can be obtained. That is, for the covariance matrix of the color channel dimension of each original area and the covariance matrix of the color channel dimension of the reference area corresponding to the original area, the transformation matrix of the original area can be obtained. It can be understood that since the first area corresponds to the third area and the second area corresponds to the fourth area, the transformation matrix of the first area is determined based on the covariance matrix of the color channel dimension corresponding to the first area and the covariance matrix of the color channel dimension corresponding to the third area. Based on the covariance matrix of the color channel dimension corresponding to the second area and the covariance matrix of the color channel dimension corresponding to the fourth area, the transformation matrix of the second area is determined.
[0148] Taking the YUV color space as an example, the transformation matrix for the corresponding areas of the original image and the reference image is the transformation matrix of the color channel dimension (that is, the U channel and V channel dimension). For each original area and its corresponding reference area, the transformation matrices of the U channel and V channel between them are calculated respectively, that is, the color mapping function is obtained.
[0149] For example, Monge-Kantorovitch can be used as a solution method, the covariance matrix of the original area is ∑_u, the covariance matrix of the reference area corresponding to the original area is ∑_v, and the transformation matrix T can be obtained by the following formula (1):
[0150]
[0151] Among them, u is the covariance matrix of the original area, and v is the covariance matrix of the reference area.
[0152] In this embodiment, covariance matrices of color channel dimensions corresponding to the multiple original areas are calculated according to the color values of the pixels in the multiple original areas, and covariance matrices of color channel dimensions corresponding to the multiple reference areas are calculated according to the color values of the pixels in the multiple reference areas. The transformation matrix of the first area is determined based on the covariance matrix of the color channel dimension corresponding to the first area and the covariance matrix of the color channel dimension corresponding to the third area. The transformation matrix of the second area is determined based on the covariance matrix of the color channel dimension corresponding to the second area and the covariance matrix of the color channel dimension corresponding to the fourth area. That is, the transformation matrix is obtained for the covariance matrices corresponding to each original area and its corresponding reference area. Since the covariance matrix can reflect the correlation between color channels, the transition between the color channels of the target image finally obtained according to the covariance matrix is more natural, and the hue of the target image is close to that of the reference image, thereby realizing filter migration.
[0153] On the basis of the above embodiment, in a possible implementation of step S204, each original region may be processed separately, and the pixel points in the original region may be processed according to the transformation matrix of the original region to obtain the correction region corresponding to the original region, and then the correction regions corresponding to the original regions may be spliced to obtain the target image, see Figure 5 , Figure 5 This is a flowchart of another image processing method provided in an embodiment of the present disclosure. S2041-S2043 is a specific implementation of S204, which is described in detail below.
[0154] S2041. Process the color values of the pixels in the original area according to the transformation matrix of the first area to obtain a first corrected area corresponding to the first area.
[0155] S2042: Process the color values of the pixels in the second region according to the transformation matrix of the second region to obtain a second corrected region corresponding to the second region.
[0156] Each original region is processed separately, and the color values of the pixels in the original region are processed according to the transformation matrix corresponding to the original region to obtain the correction region corresponding to the original region, thereby obtaining the correction region corresponding to each original region.
[0157] Furthermore, for each original region, the color values of the pixels in the original region are processed according to the color mean of the original region and the color mean of the reference region corresponding to the original region to obtain a correction region corresponding to the original region. The correction region corresponding to the original region is the target color value corresponding to each pixel in the original region. Taking the YUV color space as an example, the correction region of the original region is the target value of the U channel and the target value of the V channel corresponding to each pixel in the original region.
[0158] In a possible implementation, for each original region, the corrected region corresponding to the original region can be obtained through the following steps 1-3:
[0159] Step 1: Subtract the color mean of the original area from the color value of each pixel in the original area to obtain a zero-removed result.
[0160] Step 2: Process the zero removal result based on the transformation matrix of the original area to obtain a transformation result.
[0161] Step 3: Add the color mean of the reference area to the transformation result to obtain the corrected area corresponding to the original area.
[0162] In another possible implementation, the above steps 1-3 can be regarded as sequentially translating, rotating, scaling and translating the vector of the color dimension. Therefore, the total transformation matrix can be obtained according to the transformation matrix of the original area, the color mean of the original area and the color mean of the reference area. Based on the total transformation matrix, the color values of the pixels in the original area are processed to obtain the correction area corresponding to the original area.
[0163] S2043: Splice the first corrected area and the second corrected area to obtain a target image.
[0164] The corrected areas corresponding to all the original areas are stitched together to obtain the color result of the target image. The color result of the target image is merged with the brightness value of the original image to obtain the target image.
[0165] The corrected areas corresponding to all the original areas are spliced according to the positions of the pixels contained in the original image to obtain the color result of the target image. The color result of the target image is the target color value corresponding to each pixel of the target image. Taking the YUV color space as an example, the color result of the target image is the target value of the U channel and the target value of the V channel corresponding to each pixel in the target image.
[0166] Since the filter migration is to convert colors, the brightness values of the pixels of the original image are not changed in the previous steps. Therefore, after obtaining the color result of the target image, the color result of the target image and the brightness values of the pixels of the original image are merged to obtain a complete target image.
[0167] In this embodiment, the color values of the pixels in each original area are processed separately to obtain a corrected area of the original area, and then the corrected areas of the original areas are spliced to obtain a target image. The transformation matrix of each original area processes the original area, so that the corrected area obtained for each original area is more accurate, thereby making the target image closer to the reference image and achieving a better filter migration effect.
[0168] On the basis of the above embodiment, in another possible implementation of step S204, all pixels of the original image can be processed according to the transformation matrix and color mean of the original area and the color mean of the reference area corresponding to the original area to obtain the color transformation result corresponding to the transformation matrix, and the mean of all color transformation results is calculated to obtain the target image, see Figure 6 , Figure 6 This is a flow chart of another image processing method provided by an embodiment of the present disclosure, where S204a-S204c are a specific implementation of S204:
[0169] S204a: Process the color values of the pixels in the original image according to the transformation matrix of the first region to obtain a first corrected image corresponding to the transformation matrix of the first region.
[0170] S204b: Process the color values of the pixels in the original image according to the transformation matrix of the second region to obtain a second corrected image corresponding to the transformation matrix of the second region.
[0171] For the transformation matrix of each original region, the color value of each pixel in the original image can be processed according to the transformation matrix of the original region to obtain a corrected image corresponding to the transformation matrix. Thus, a corrected image corresponding to each transformation matrix is obtained.
[0172] Furthermore, for each original region, the color value of each pixel in the original image is processed according to the color mean of the original region and the color mean of the reference region corresponding to the original region. Thus, a corrected image equal to the number of original regions can be obtained. Among them, the corrected image corresponding to the transformation matrix is the matching color value corresponding to each pixel in the original image. Each pixel in the original image can obtain at least two matching color values, and the number of matching color values is equal to the number of original regions. Taking the YUV color space as an example, the corrected image corresponding to the transformation matrix of the original region is the matching color value of the U channel and the matching color value of the V channel corresponding to each pixel in the original image.
[0173] In a possible implementation, for the transformation matrix of each original region, the corrected image corresponding to the transformation matrix can be obtained through the following steps ac:
[0174] Step a: subtract the color mean of the original area from the color value of the pixel point of the original image to obtain a zero-removed result.
[0175] Step b: Process the zero removal result based on the transformation matrix of the original area to obtain a transformation result.
[0176] Step c: Add the transformation result to the color mean of the reference area to obtain a corrected image corresponding to the transformation matrix.
[0177] In another possible implementation, the above steps ac can be regarded as operations of sequentially translating, rotating, scaling and translating the vector of the color dimension. Therefore, the total transformation matrix corresponding to each transformation matrix can be obtained according to the transformation matrix of each original area, the color mean of each original area and the color mean of each reference area corresponding to the original area. Based on the total transformation matrix corresponding to each transformation matrix, the original image is processed to obtain a corrected image corresponding to the transformation matrix.
[0178] S204c, fusing the first corrected image and the second corrected image to obtain a target image.
[0179] The color values of each pixel in the original image in each corrected image are fused to obtain the target value of each pixel, which is the value of the target image.
[0180] Furthermore, the mean of the corrected images corresponding to the transformation matrices of all the original regions can be calculated to obtain the target image. Exemplarily, the mean of the color values of each pixel in all the corrected images can be calculated to obtain the color result of the target image. The mean is the target color value of the pixel in the target image. Thus, the target color values corresponding to all the pixels of the target image can be obtained, that is, the color result of the target image is obtained.
[0181] Since the filter migration is to convert the color, the brightness value of the pixel of the original image is not changed in the previous step, so the color result of the target image and the brightness value of the pixel of the original image are merged to obtain the target image.
[0182] In this embodiment, the color values of the pixels in the original image are processed according to the transformation matrix of the first area to obtain a first corrected image corresponding to the transformation matrix of the first area, and the color values of the pixels in the original image are processed according to the transformation matrix of the second area to obtain a second corrected image corresponding to the transformation matrix of the second area. That is, according to the transformation matrix of each original area, all the pixels of the original image are processed respectively to obtain corrected images of multiple original images, and then all the corrected images are fused to obtain the target image, so that the transition between pixels of different brightness in the obtained target image is more natural, thereby making the target image more natural.
[0183] On the basis of the above embodiment, further, if it is necessary to perform a filter migration operation on the original video according to the color style of the reference video or the reference image, each frame image contained in the original video is taken as an original image, and the above image processing method is performed with the reference image to obtain the target image, and the target image is composed of the screen of the target video according to the position of the original image in the video.
[0184] Optionally, if the original video is the same scene, that is, the scene between each frame of the original image of the original video remains unchanged, the first frame of the original image of the original image can obtain the target image through the method of the above embodiment, and starting from the second frame of the original image of the original image, there is no need to perform steps S201-S203, that is, there is no need to calculate the transformation matrix corresponding to each original area of the frame of the original image. In step S204, the transformation matrix of each original area is directly obtained based on the first frame of the original video and the reference image.
[0185] When migrating filters on a video, the GPU is used in the electronic device for processing. For a 720P video, each frame can be processed within 2ms, thereby greatly improving the efficiency of video filter migration.
[0186] Figure 7 A schematic diagram of the structure of an image processing device provided by an embodiment of the present disclosure is shown in FIG. Figure 7 As shown, the device provided in this embodiment includes:
[0187] The region division module 701 is used to divide the original image into a plurality of original regions; the plurality of original regions include at least a first region and a second region, and the brightness value of the pixel points in the first region is greater than the brightness value of the pixel points in the second region; divide the reference image into a plurality of reference regions; the reference regions include at least a third region and a fourth region, and the brightness value of the pixel points in the third region is greater than the brightness value of the pixel points in the fourth region;
[0188] A transformation matrix generation module 702, configured to obtain a transformation matrix for the first region according to the color values of the pixels in the first region and the color values of the pixels in the third region, and to obtain a transformation matrix for the second region according to the color values of the pixels in the second region and the color values of the pixels in the fourth region;
[0189] The processing module 703 is used to perform color mapping on the original image according to the transformation matrix of the first region and the change matrix of the second region to obtain a target image.
[0190] Optionally, the transformation matrix generation module 702 is specifically used for:
[0191] According to the color values of the pixels in the multiple original areas, the covariance matrices of the color channel dimensions corresponding to the multiple original areas are calculated; according to the color values of the pixels in the multiple reference areas, the covariance matrices of the color channel dimensions corresponding to the multiple reference areas are calculated; based on the covariance matrix of the color channel dimension corresponding to the first area and the covariance matrix of the color channel dimension corresponding to the third area, the transformation matrix of the first area is determined; based on the covariance matrix of the color channel dimension corresponding to the second area and the covariance matrix of the color channel dimension corresponding to the fourth area, the transformation matrix of the second area is determined.
[0192] Optionally, the processing module 703 is specifically used for:
[0193] According to the transformation matrix of the first area, the color values of the pixels in the original image are processed to obtain a first corrected image corresponding to the transformation matrix of the first area; according to the transformation matrix of the second area, the color values of the pixels in the original image are processed to obtain a second corrected image corresponding to the transformation matrix of the second area; the first corrected image and the second corrected image are fused to obtain the target image.
[0194] Optionally, the processing module 703 is specifically used for:
[0195] According to the transformation matrix of the first area, the color values of the pixels in the first area are processed to obtain a first correction area corresponding to the first area; according to the transformation matrix of the second area, the color values of the pixels in the second area are processed to obtain a second correction area corresponding to the second area; the first correction area and the second correction area are spliced to obtain a target image.
[0196] Optionally, the area division module 701 is specifically used for:
[0197] Arrange the pixels in the original image from low to high according to the brightness value, and determine at least one first dividing value; divide the pixels in the original image into multiple original areas based on the at least one first dividing value; arrange the pixels in the reference image from low to high according to the brightness value, and determine at least one second dividing value; divide the pixels in the reference image into multiple reference areas based on the at least one second dividing value.
[0198] Optionally, the multiple original regions further include a fifth region, and the brightness value of the pixel points in the fifth region is greater than the brightness value of the pixel points in the first region, or the brightness value of the pixel points in the fifth region is less than the brightness value of the pixel points in the second region;
[0199] The reference area further includes a sixth area, wherein the brightness value of the pixel points in the sixth area is greater than the brightness value of the pixel points in the third area, or the brightness value of the pixel points in the sixth area is less than the brightness value of the pixel points in the fourth area;
[0200] The transformation matrix generation module 702 is also used for:
[0201] Obtaining a transformation matrix for the fifth region according to color values of pixels in the fifth region and color values of pixels in the sixth region;
[0202] The processing module 703 is specifically used for:
[0203] According to the transformation matrix of the first region, the change matrix of the second region and the transformation matrix of the fifth region, color mapping is performed on the original image to obtain a target image.
[0204] The device of the above embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0205] The present disclosure provides an electronic device, including: one or more processors; a memory; and one or more computer programs; wherein the one or more computer programs are stored in the memory; when the one or more processors execute the one or more computer programs, the electronic device implements the above Figure 2-Figure 6An image processing method according to any one of the illustrated embodiments.
[0206] The present disclosure provides a computer storage medium including computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned Figure 2-Figure 6 An image processing method according to any one of the illustrated embodiments.
[0207] The present disclosure provides a computer program product, which, when executed on a computer, enables the computer to execute the above Figure 2-Figure 6 An image processing method according to any one of the illustrated embodiments.
[0208] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0209] The above are only specific embodiments of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to these embodiments herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An image processing method, characterized in that: include: Dividing the original image into a plurality of original regions; the plurality of original regions at least include a first region and a second region, and the brightness value of the pixel points in the first region is greater than the brightness value of the pixel points in the second region; dividing the reference image into a plurality of reference regions; The reference area at least includes a third area and a fourth area, wherein the brightness value of the pixel points in the third area is greater than the brightness value of the pixel points in the fourth area; A transformation matrix of the first region is obtained according to the color values of the pixels in the first region and the color values of the pixels in the third region, and a transformation matrix of the second region is obtained according to the color values of the pixels in the second region and the color values of the pixels in the fourth region; wherein the transformation matrix of the first region is determined based on the covariance matrix of the color channel dimensions corresponding to the first region and the third region respectively, and the transformation matrix of the second region is determined based on the covariance matrix of the color channel dimensions corresponding to the second region and the fourth region respectively; Color mapping is performed on the original image according to the transformation matrix of the first region and the change matrix of the second region to obtain a target image.
2. The method according to claim 1, characterized in that Before obtaining the transformation matrix of the first region according to the color values of the pixels in the first region and the color values of the pixels in the third region, and obtaining the transformation matrix of the second region according to the color values of the pixels in the second region and the color values of the pixels in the fourth region, the method further includes: Calculate the covariance matrix of the color channel dimensions corresponding to the multiple original regions respectively according to the color values of the pixel points in the multiple original regions; According to the color values of the pixels in the multiple reference areas, the covariance matrices of the color channel dimensions respectively corresponding to the multiple reference areas are calculated.
3. The method according to claim 1, characterized in that: The step of performing color mapping on the original image according to the transformation matrix of the first region and the change matrix of the second region to obtain a target image includes: Processing the color values of the pixels in the original image according to the transformation matrix of the first region to obtain a first corrected image corresponding to the transformation matrix of the first region; Processing the color values of the pixels in the original image according to the transformation matrix of the second region to obtain a second corrected image corresponding to the transformation matrix of the second region; The first corrected image and the second corrected image are fused to obtain the target image.
4. The method according to claim 1, characterized in that The step of performing color mapping on the original image according to the transformation matrix of the first region and the change matrix of the second region to obtain a target image includes: Processing color values of pixels in the first region according to the transformation matrix of the first region to obtain a first correction region corresponding to the first region; Processing color values of pixels in the second region according to the transformation matrix of the second region to obtain a second corrected region corresponding to the second region; The first correction area and the second correction area are spliced to obtain the target image.
5. The method according to any one of claims 1 to 4, characterized in that: The step of dividing the original image into a plurality of original regions comprises: Arrange the pixels in the original image from low to high according to the brightness value, and determine at least one first dividing value; Dividing the pixels in the original image into a plurality of original regions based on the at least one first dividing value; The step of dividing the reference image into a plurality of reference areas comprises: Arrange the pixels in the reference image from low to high according to brightness values, and determine at least one second dividing value; Based on the at least one second demarcation value, pixels in the reference image are divided into a plurality of reference areas.
6. The method according to any one of claims 1 to 4, characterized in that: The multiple original regions further include a fifth region, the brightness value of the pixels in the fifth region is greater than the brightness value of the pixels in the first region, or the brightness value of the pixels in the fifth region is less than the brightness value of the pixels in the second region; The reference area further includes a sixth area, wherein the brightness value of the pixel points in the sixth area is greater than the brightness value of the pixel points in the third area, or the brightness value of the pixel points in the sixth area is less than the brightness value of the pixel points in the fourth area; The method further comprises: Obtaining a transformation matrix for the fifth region according to the color values of the pixels in the fifth region and the color values of the pixels in the sixth region; The step of performing color mapping on the original image according to the transformation matrix of the first region and the change matrix of the second region to obtain a target image includes: Color mapping is performed on the original image according to the transformation matrix of the first region, the change matrix of the second region, and the transformation matrix of the fifth region to obtain a target image.
7. An image processing device, characterized in that: include: A region division module, used to divide the original image into a plurality of original regions; the plurality of original regions at least include a first region and a second region, and the brightness value of the pixel points in the first region is greater than the brightness value of the pixel points in the second region; Dividing the reference image into a plurality of reference areas; the reference areas at least include a third area and a fourth area, wherein the brightness value of the pixel points in the third area is greater than the brightness value of the pixel points in the fourth area; A transformation matrix generation module, used to obtain a transformation matrix of the first area according to the color values of the pixels in the first area and the color values of the pixels in the third area, and to obtain a transformation matrix of the second area according to the color values of the pixels in the second area and the color values of the pixels in the fourth area; wherein the transformation matrix of the first area is determined based on a covariance matrix of color channel dimensions corresponding to the first area and the third area respectively, and the transformation matrix of the second area is determined based on a covariance matrix of color channel dimensions corresponding to the second area and the fourth area respectively; A processing module is used to perform color mapping on the original image according to the transformation matrix of the first area and the change matrix of the second area to obtain a target image.
8. An electronic device comprising: one or more processors; Memory; and one or more computer programs; wherein, the one or more computer programs are stored in the memory; characterized in that, when the one or more processors execute the one or more computer programs, the electronic device implements the image processing method as described in any one of claims 1-6.
9. A computer storage medium, characterized in that The method comprises computer instructions, which, when executed on an electronic device, enable the electronic device to execute the image processing method according to any one of claims 1 to 6.
10. A computer program product, characterized in that When the computer program product is run on a computer, the computer is enabled to execute the image processing method according to any one of claims 1 to 6.
