Image processing method and device, terminal and readable storage medium
By calculating the color ratio and mapping relationship, the weight value is obtained, and the high saturation correction matrix and standard correction matrix are adjusted to solve the problem of texture blur in high saturation images and improve the texture recognition of the image.
Patent Information
- Application Number
- CN202210107849.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-28
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-01-28
AI Technical Summary
The problem of blurred and indistinguishable textures in high-saturation images is mainly due to the clipping of colors outside the color gamut, resulting in reduced color differences near the color gamut boundary, and the lack of effective processing methods.
By obtaining the first saturation of the current frame image and the second saturation of the target area, calculate the color ratio, and obtain the second weight value according to the preset mapping relationship, which is used to characterize the relationship between the high saturation correction matrix and the standard correction matrix. weight, and then obtain the target matrix to correct the image.
It improves the texture recognition of high-saturation scenes in images, avoids reducing the saturation of non-high-saturation scenes, and ensures the image processing effect.
Smart Images

Figure CN114445509B
Abstract
Description
Technical Field
[0001] The present application relates to the field of imaging technology, and in particular to an image processing method, an image processing device, a method for acquiring a high-saturation matrix, a device for acquiring a high-saturation matrix, a terminal, and a non-volatile computer-readable storage medium. Background Art
[0002] Some highly saturated images have blurred textures and indistinguishable textures. The main reason is that the colors outside the color gamut are clipped, resulting in a reduction in color differences near the color gamut boundary. Therefore, there is a lack of an effective method to process highly saturated colors to improve the problem of blurred textures and indistinguishable textures. Summary of the invention
[0003] Embodiments of the present application provide an image processing method, an image processing device, a method for obtaining a high-saturation matrix, a device for obtaining a high-saturation matrix, a terminal, and a non-volatile computer-readable storage medium.
[0004] The image processing method of the embodiment of the present application includes: obtaining a first saturation of a current frame image and a second saturation of a target area of the current frame image; obtaining a color ratio according to the first saturation, the second saturation, a preset saturation threshold and a preset first weight value; obtaining a second weight value according to the color ratio and a preset mapping relationship, the mapping relationship being used to reflect the correspondence between the color ratio and the second weight value, the second weight value being used to characterize the weight between a high-saturation correction matrix and a standard correction matrix; obtaining a target matrix according to the high-saturation correction matrix, the standard correction matrix and the second weight value; and correcting the current frame image according to the target matrix.
[0005] The method for obtaining a high-saturation matrix in an embodiment of the present application includes: obtaining a first color value of each pixel point of the current frame image; performing color correction on the first color value to obtain multiple second color values, wherein the second color value includes multiple components; when any one of the components exceeds the color gamut, obtaining a hue value of each second color value; obtaining a first output value and a second output value based on the multiple hue values, the first color value, the second color value, and a preset strategy; and obtaining the high-saturation correction matrix based on the first output value, the second output value, and the standard correction matrix.
[0006] The image processing device of the embodiment of the present application includes a first acquisition module, which is used to acquire the first saturation of the current frame image and the second saturation of the target area of the current frame image; a second acquisition module, which is used to acquire the color ratio according to the first saturation, the second saturation, a preset saturation threshold and a preset first weight value; a third acquisition module, which is used to acquire the second weight value according to the color ratio and a preset mapping relationship, the mapping relationship is used to reflect the correspondence between the color ratio and the second weight value, and the second weight value is used to characterize the weight between the high-saturation correction matrix and the standard correction matrix; a fourth acquisition module, which is used to acquire the target matrix according to the high-saturation correction matrix, the standard correction matrix and the second weight value; and a correction module, which is used to correct the current frame image according to the target matrix.
[0007] The high-saturation matrix acquisition device of the implementation mode of the present application includes: a sixth acquisition module, used to acquire the first color value of each pixel point of the current frame image; a seventh acquisition module, used to perform color correction on the first color value to obtain multiple second color values; an eighth acquisition module, used to acquire the hue value of each second color value when any component exceeds the color gamut; a ninth acquisition module, used to acquire the first output value and the second output value according to the multiple hue values, the first color value, the second color value, and a preset strategy; and a tenth acquisition module, used to acquire the high-saturation correction matrix according to the first output value, the second output value and the standard correction matrix.
[0008] The terminal of the embodiment of the present application includes one or more processors, a memory and one or more programs. Among them, one or more programs are stored in the memory and executed by one or more processors, and the program includes instructions for executing the image processing method and / or the method for obtaining the high saturation matrix of the embodiment of the present application. The image processing method includes: obtaining the first saturation of the current frame image and the second saturation of the target area of the current frame image; obtaining the color ratio according to the first saturation, the second saturation, the preset saturation threshold and the preset first weight value; obtaining the second weight value according to the color ratio and the preset mapping relationship, the mapping relationship is used to reflect the corresponding relationship between the color ratio and the second weight value, and the second weight value is used to characterize the weight between the high saturation correction matrix and the standard correction matrix; obtaining the target matrix according to the high saturation correction matrix, the standard correction matrix and the second weight value; and correcting the current frame image according to the target matrix. The method for obtaining a high-saturation matrix includes: obtaining the first color value of each pixel point of the current frame image; performing color correction on the first color value to obtain multiple second color values, wherein the second color value includes multiple components; when any one of the components exceeds the color gamut, obtaining the hue value of each second color value; obtaining the first output value and the second output value according to the multiple hue values, the first color value, the second color value, and a preset strategy; and obtaining the high-saturation correction matrix according to the first output value, the second output value, and the standard correction matrix.
[0009] A non-volatile computer-readable storage medium containing a computer program according to an embodiment of the present application, when the computer program is executed by one or more processors, enables the processor to implement instructions of the image processing method and / or the method for obtaining a high-saturation matrix according to the embodiment of the present application. The image processing method includes: obtaining a first saturation of a current frame image and a second saturation of a target area of the current frame image; obtaining a color ratio according to the first saturation, the second saturation, a preset saturation threshold and a preset first weight value; obtaining a second weight value according to the color ratio and a preset mapping relationship, the mapping relationship is used to reflect the corresponding relationship between the color ratio and the second weight value, and the second weight value is used to characterize the weight between the high-saturation correction matrix and the standard correction matrix; obtaining a target matrix according to the high-saturation correction matrix, the standard correction matrix and the second weight value; and correcting the current frame image according to the target matrix. The method for obtaining a high-saturation matrix includes: obtaining the first color value of each pixel point of the current frame image; performing color correction on the first color value to obtain multiple second color values, wherein the second color value includes multiple components; when any one of the components exceeds the color gamut, obtaining the hue value of each second color value; obtaining the first output value and the second output value according to the multiple hue values, the first color value, the second color value, and a preset strategy; and obtaining the high-saturation correction matrix according to the first output value, the second output value, and the standard correction matrix.
[0010] The image processing method, image processing device, high-saturation matrix acquisition method, high-saturation matrix acquisition device, terminal and non-volatile computer-readable storage medium of the embodiments of the present application can improve the texture recognition of high-saturation scenes in images.
[0011] Additional aspects and advantages of the embodiments of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0013] Figure 1 is a flowchart of an image processing method of certain embodiments of the present application;
[0014] Figure 2 is a schematic diagram of the structure of an image processing device in some embodiments of the present application;
[0015] Figure 3 is a parameter diagram of a standard correction matrix for certain embodiments of the present application;
[0016] Figure 4 is a flowchart of an image processing method of certain embodiments of the present application;
[0017] Figure 5 is a flowchart of an image processing method of certain embodiments of the present application;
[0018] Figure 6 is a flowchart of an image processing method of certain embodiments of the present application;
[0019] Figure 7 is a flowchart of an image processing method of certain embodiments of the present application;
[0020] Figure 8 is a flowchart of an image processing method of certain embodiments of the present application;
[0021] Fig. 9 is a schematic diagram of a first histogram of certain embodiments of the present application;
[0022] Fig.10 is a flowchart of an image processing method of certain embodiments of the present application;
[0023] Fig.11 is a flowchart of an image processing method of certain embodiments of the present application;
[0024] Fig.12 is a flowchart of an image processing method of certain embodiments of the present application;
[0025] Fig.13 is a schematic diagram of a mapping diagram of certain embodiments of the present application;
[0026] Fig.14 is a flowchart of an image processing method of certain embodiments of the present application;
[0027] Fig.15 is a flowchart of an image processing method of certain embodiments of the present application;
[0028] Fig.16 is a flowchart of an image processing method of certain embodiments of the present application;
[0029] Fig.17 is a flowchart of an image processing method of certain embodiments of the present application;
[0030] Fig.18 is a flowchart of an image processing method of certain embodiments of the present application;
[0031] Fig.19 is a flowchart of an image processing method of certain embodiments of the present application;
[0032] Fig. 20 is a schematic diagram of a lookup table of certain embodiments of the present application;
[0033] Fig.21 is a flowchart of an image processing method of certain embodiments of the present application;
[0034] Fig. 22 is a flowchart of an image processing method of certain embodiments of the present application;
[0035] Fig.23 is a flowchart of an image processing method of certain embodiments of the present application;
[0036] Fig.24 is a flow chart of a method for obtaining a high saturation matrix in certain embodiments of the present application;
[0037] Fig.25 It is a schematic diagram of the structure of a high saturation matrix acquisition device in some embodiments of the present application;
[0038] Fig.26 is a flow chart of a method for obtaining a high saturation matrix in certain embodiments of the present application;
[0039] Fig. 27 is a flow chart of a method for obtaining a high saturation matrix in certain embodiments of the present application;
[0040] Fig.28 is a flow chart of a method for obtaining a high saturation matrix in certain embodiments of the present application;
[0041] Fig.29 is a flow chart of a method for obtaining a high saturation matrix in certain embodiments of the present application;
[0042] Fig.30 is a flow chart of a method for obtaining a high saturation matrix in certain embodiments of the present application;
[0043] Fig.31 is a flow chart of a method for obtaining a high saturation matrix in certain embodiments of the present application;
[0044] Fig.32 is a flow chart of a method for obtaining a high saturation matrix in certain embodiments of the present application;
[0045] Fig.33 is a schematic diagram of the structure of a terminal in some implementation modes of the present application;
[0046] Fig.34 It is a schematic diagram of the connection relationship between the computer-readable storage medium and the processor in certain embodiments of the present application. DETAILED DESCRIPTION
[0047] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals represent the same or similar elements or elements having the same or similar functions from beginning to end. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the embodiments of the present application, and cannot be understood as limiting the embodiments of the present application.
[0048] Some high-saturation images may have blurred and indistinguishable textures. The present application provides an image processing method for processing an image to improve the recognition of image texture.
[0049] See also Figure 1 The image processing method of the embodiment of the present application comprises the following steps:
[0050] 01: Get the first saturation of the current frame image and the second saturation of the target area of the current frame image;
[0051] 03: Obtaining a color ratio according to the first saturation, the second saturation, a preset saturation threshold and a preset first weight value;
[0052] 05: Obtain a second weight value according to the color ratio and a preset mapping relationship, the mapping relationship is used to reflect the corresponding relationship between the color ratio and the second weight value, and the second weight value is used to represent the weight between the high saturation correction matrix and the standard correction matrix;
[0053] 07: Obtain a target matrix according to the high saturation correction matrix, the standard correction matrix and the second weight value; and
[0054] 09: Correct the current frame image according to the target matrix.
[0055] Please combine Figure 2, the embodiment of the present application also provides an image processing device 10, and the image processing method of the embodiment of the present application can be applied to the image processing device 10. The image processing device 10 includes a first acquisition module 11, a second acquisition module 12, a third acquisition module 13, a fourth acquisition module 14 and a correction module 15, wherein the first acquisition module 11 is used to execute the method in 01, the second acquisition module 12 is used to execute the method in 02, the third acquisition module 13 is used to execute the method in 03, the fourth acquisition module 14 is used to execute the method in 04, and the correction module 15 is used to execute the method in 05. That is, the first acquisition module 11 can be used to acquire the first saturation of the current frame image and the second saturation of the target area of the current frame image. The second acquisition module 12 can be used to acquire the color ratio according to the first saturation, the second saturation, the preset saturation threshold and the preset first weight value. The third acquisition module 13 can be used to acquire the second weight value according to the color ratio and the preset mapping relationship, the mapping relationship is used to reflect the corresponding relationship between the color ratio and the second weight value, and the second weight value is used to characterize the weight between the high saturation correction matrix and the standard correction matrix. The fourth acquisition module 14 can be used to acquire a target matrix according to the high saturation correction matrix, the standard correction matrix and the second weight value. The correction module 15 can be used to correct the current frame image according to the target matrix.
[0056] See also Figure 1 and Figure 2 In method 01, the current frame image may be a single frame image input to the image processing device 10, or may be an image currently being processed among multiple frame images input to the image processing device 10, and no limitation is made here.
[0057] The current frame image includes a plurality of pixels, and the first saturation includes the saturation corresponding to each pixel of the current frame image. Similarly, the second saturation includes the saturation corresponding to each pixel of the target area. The target area is a partial area advanced from the current frame image. For example, when the user focuses on a portrait in the current frame image, the target area can be set to the area containing the portrait.
[0058] See also Figure 1 and Figure 2 In method 03, the preset saturation threshold is a threshold for measuring the saturation of the color of the image, and the saturation (value) higher than the saturation threshold can be considered as a high saturation value. The preset saturation threshold can be set according to an empirical value. In one embodiment, the clarity and saturation detection can be performed on multiple frames of sample images to obtain a mapping relationship between clarity and saturation, so as to find the saturation corresponding to the clarity when the texture of the image is blurred, and set the saturation as the saturation threshold.
[0059] The preset first weight value reflects the proportion of the target area to the current frame image. In one embodiment, the proportion of the target area to the current frame image can be set to the first weight value. For example, if the area of the target area is 20% of the area of the current frame image, the first weight value is 20%.
[0060] The color ratio is the proportion of high-saturation colors in the current frame image, specifically, the proportion of the number of high-saturation pixels in the number of pixels in the current frame image.
[0061] See also Figure 1 and Figure 2 In method 05, the second weight value is used to characterize the weight between the high saturation correction matrix and the standard correction matrix. The second weight value is set to w2, w2∈[0,1]. The standard correction matrix is the standard CCM (Color Correction Matrix, CCM) matrix in the ISP (Image Signal Processing, ISP) process, which is used to perform color correction on the image. The high saturation correction matrix is a correction matrix used to adjust high saturation colors outside the color gamut.
[0062] Please combine Figure 3 In one embodiment, let the standard correction matrix be M0 and the high saturation correction matrix be M1, then M1 = (1-K)*M2+K*M0. Where K is a preset weakening parameter, K∈[0,1], M2 is a standard known matrix with 3 rows and 3 columns, That is, the high saturation correction matrix M1 is a correction matrix obtained by weakening the parameters of the standard matrix M0. Specifically, the pixels input into the standard correction matrix M0 include color components: rr, rg, rb, gg, gr, gb, bb, br, bg, where "r" represents red, "g" represents green, and "b" represents blue. The 9 color components in the standard correction matrix M0 have corresponding parameters a, for example, component rr corresponds to parameter a11, component rg corresponds to parameter a21, component rb corresponds to parameter a31, component gr corresponds to parameter a12, component gg corresponds to parameter a22, component gb corresponds to parameter a32, component br corresponds to parameter a13, component bg corresponds to parameter a23, and component bb corresponds to parameter a33. Compared with the standard correction matrix M0, the high saturation correction matrix M1 weakens the parameter a corresponding to the color component. In this way, a part of the high saturation colors that appear outside the color gamut can be adjusted back to the color gamut. By adjusting the value of the weakening parameter K, the degree of adjusting the high-saturation colors outside the color gamut back to the color gamut can be controlled. For example, reducing the value of the weakening parameter K can adjust more high-saturation colors outside the color gamut back to the color gamut.
[0063] The main reason for the blurred texture near the high-saturation pixels in the image is that the colors of the high-saturation pixels include colors outside the color gamut and colors within the color gamut. In the process of image processing (such as the ISP process), the colors outside the color gamut are discarded, resulting in a decrease in the color difference near the color gamut boundary. The colors near the high-saturation pixels in the processed image are relatively similar, making it difficult to distinguish the texture details. The high-saturation correction matrix M1 adjusts a part of the high-saturation colors that appear outside the color gamut back to the color gamut, that is, the saturation of this part of the color that should have been discarded is reduced and retained, thereby ensuring that the colors near the color gamut boundary have a certain difference, so as to clearly distinguish the texture details in the image.
[0064] However, the high-saturation correction matrix M1 will adjust the overall color of the current frame image, so that the saturation of all colors outside the color gamut in the current frame image will be reduced, resulting in the saturation of scenes that do not need to be reduced in saturation also being reduced, and the color difference of the current frame image increasing. The image processing method of the embodiment of the present application obtains a target matrix based on the high-saturation correction matrix, the standard correction matrix and the second weight value, so that the obtained target matrix can improve the texture recognition of the high-saturation scene in the image, and will not reduce the saturation of the non-high-saturation scene.
[0065] The following is a further description with reference to the accompanying drawings.
[0066] See also Figure 4 In some embodiments, the image processing method further comprises:
[0067] 02: Extract the target area in the current frame image.
[0068] Please combine Figure 2 In some embodiments, the image processing device 10 further includes an extraction module 16 for executing the method in 02. That is, the extraction module 16 can be used to extract the target area in the current frame image.
[0069] Specifically, see Figure 5 In some embodiments, 02: extracting a target area in a current frame image includes:
[0070] 021: Use the focus area of the current frame image as the target area; or
[0071] 023: Extract the region of interest in the current frame image and use the region of interest as the target region.
[0072] Please combine Figure 2 In some embodiments, the extraction module 16 can also be used to execute the method in 021 or 023. That is, the extraction module 16 can also be used to use the focus area of the current frame image as the target area; or extract the region of interest in the current frame image and use the region of interest as the target area.
[0073] In some embodiments, the focus area is an area with clear imaging. In one embodiment, the high-definition area in the current frame image can be identified by software to determine the focus area. In another embodiment, the focus corresponding to the current frame image can be obtained, for example, the focus position is recorded when the image is captured, so that the area within a predetermined range from the focus is used as the focus area.
[0074] In some embodiments, the region of interest may include a focus area. The region of interest may also be a region that satisfies a preset condition. For example, if the preset condition is a region with a human face, then face recognition may be performed on the current frame image to take the region containing the human face as the region of interest. For another example, if the preset condition is a region of an object that appears multiple times in a historically captured image, for example, a user shoots a video recording the activities of a pet cat, and the video is a multi-frame historically captured image, in which a pet cat is an object that appears multiple times, then the pet cat in the current frame image may be identified, and the region containing the pet cat may be taken as the region of interest.
[0075] In some implementations, the region of interest may be one or more regions divided in any manner, such as dividing the current frame image into two equal parts, and taking one of the two divided regions as the region of interest.
[0076] See also Figure 6 In some embodiments, 01: obtaining a first saturation of a current frame image and a second saturation of a target area of the current frame image, including:
[0077] 011: Convert the current frame image and the target area from RGB space to HSV (Hue, Saturation, Value) space; and
[0078] 013: Get the first saturation and the second saturation in HSV space.
[0079] Please combine Figure 2 In some embodiments, the first acquisition module 11 can also be used to execute the methods in 011 and 013. That is, the first acquisition module 11 can also be used to convert the current frame image and the target area from the RGB space to the HSV space; and obtain the first saturation and the second saturation in the HSV space.
[0080] In this way, the "S (Saturation)" component of the pixel of the current frame image in the HSV space can represent the first saturation of the pixel. Similarly, the "S" component of the pixel of the target area in the HSV space can represent the second saturation of the pixel. This can facilitate subsequent processing.
[0081] In other embodiments, the first saturation and the second saturation may be obtained in other ways, such as converting the current frame image and the target area from the RGB space to the HSI (Hue-Saturation-Intensity, HSI) space, and obtaining the first saturation and the second saturation in the HSI space. This is not limited here.
[0082] See also Figure 7 In some embodiments, 03: obtaining a color ratio according to the first saturation, the second saturation, a preset saturation threshold and a preset first weight value, including:
[0083] 031: acquiring a first ratio according to the first saturation and the saturation threshold, where the first ratio is a ratio between the number of pixels corresponding to the saturation greater than the saturation threshold in the first saturation and the total number of pixels in the current frame image;
[0084] 033: acquiring a second ratio according to the second saturation and the saturation threshold, the second ratio being a ratio between the number of pixels corresponding to the saturation greater than the saturation threshold in the second saturation and the total number of pixels in the target area; and
[0085] 035: Obtain a color ratio according to the first ratio, the second ratio, and the first weight.
[0086] Please combine Figure 2 In some embodiments, the second acquisition module 12 can also be used to execute the methods in 031, 033 and 035. That is, the second acquisition module 12 can also be used to acquire the first ratio according to the first saturation and the saturation threshold; acquire the second ratio according to the second saturation and the saturation threshold; and acquire the color ratio according to the first ratio, the second ratio, and the first weight.
[0087] Assume that the first ratio is R1, the second ratio is R2, the current frame image includes n pixels, and the target area includes m pixels. In one embodiment, if the saturation corresponding to n1 pixels among the n pixels of the current frame image is greater than the saturation threshold, then R1 = n1 / n; if the saturation corresponding to m1 pixels among the m pixels of the target image is greater than the saturation threshold, then R2 = m1 / m. Assume that the first weight value is w1, and the color ratio is R, then R = w1*R2+(1-w1)*R1.
[0088] The color ratio R is used to obtain the second weight value, and the second weight value is used to obtain the target matrix, so that the target matrix finally obtained can process the current frame image according to the high-saturation color ratio to improve the texture recognition of the high-saturation scene and not reduce the color saturation of the non-high-saturation scene.
[0089] See also Figure 8In some embodiments, 031: obtaining a first ratio according to a first saturation and a saturation threshold, comprises:
[0090] 0311: Obtain a first histogram corresponding to a first saturation, where the first histogram is used to reflect the relationship between the number of pixels and the saturation of the current frame image; and
[0091] 0312: Obtain, according to the first histogram, a ratio between the number of pixels corresponding to the saturation greater than the saturation threshold in the first saturation and the total number of pixels in the current frame image as a first ratio.
[0092] Please combine Figure 2 In some embodiments, the second acquisition module 12 can also be used to execute the methods in 0311 and 0312. That is, the second acquisition module 12 can also be used to obtain a first histogram corresponding to the first saturation, and the first histogram is used to reflect the relationship between the number of pixels and the saturation of the current frame image; according to the first histogram, the ratio between the number of pixels corresponding to the saturation greater than the saturation threshold in the first saturation and the total number of pixels in the current frame image is obtained as the first ratio.
[0093] Please combine Fig. 9 , Fig. 9 is an example of the first histogram. The horizontal axis of the first histogram represents saturation, and the vertical axis represents the number of pixels. After acquiring the current frame image, the saturation of each pixel in the current frame image can be counted in the first histogram. For example, if the saturation of a pixel in the current frame image is 200, then the count value of the position with a saturation of 200 in the first histogram is increased by 1. In the first histogram finally obtained, let the total number of count values corresponding to the position where a certain saturation is located on the horizontal axis be nj1, which means that there are nj1 pixels in the current frame image with the saturation of this saturation. Let the saturation threshold be js, and among the multiple saturations on the horizontal axis, saturations j1, j2, and j3 are saturations greater than js, and saturations j1, j2, and j3 correspond to the total number of count values nj1, nj2, and nj3, respectively. Then the number of pixels n1 greater than the saturation threshold js is nj1=nj1+nj2+nj3.
[0094] See also Fig.10 In some embodiments, 033: obtaining a second ratio according to a second saturation and a saturation threshold, comprises:
[0095] 0331: Obtain a second histogram corresponding to a second saturation, where the second histogram is used to reflect the relationship between the number of pixels in the target area and the saturation;
[0096] 0332: Obtain, according to the second histogram, a ratio between the number of pixels corresponding to a saturation greater than a saturation threshold in the second saturation and the total number of pixels in the target area as a second ratio.
[0097] Please combine Figure 2 In some embodiments, the second acquisition module 12 can also be used to execute the methods in 0331 and 0332. That is, the second acquisition module 12 can also be used to obtain a second histogram corresponding to the second saturation, the second histogram is used to reflect the relationship between the number of pixels and the saturation of the target area; and obtain the ratio between the number of pixels corresponding to the saturation greater than the saturation threshold in the second saturation and the total number of pixels in the target area according to the second histogram, as the second ratio.
[0098] Please combine Fig. 9 , the second histogram is Fig. 9 The first histogram is similar, the horizontal axis represents saturation, and the vertical axis represents the number of pixels. After obtaining the target area, the saturation of each pixel in the target area can be counted in the second histogram. The process of obtaining the second histogram and the second ratio is similar to the process of obtaining the first histogram and the first ratio, and will not be repeated here.
[0099] See also Figure 1 In some implementations, the mapping relationship preset in method 05 may include a mapping curve, a mapping table, a mapping relationship formula, a mapping relationship diagram, etc., which is not limited here.
[0100] See also Fig.11 In some implementations, 05: obtaining a second weight value according to the color ratio and a preset mapping relationship includes:
[0101] 051: Obtain a second weight value according to the color ratio and the mapping table.
[0102] Please combine Figure 2 In some implementations, the third acquisition module 13 can also be used to execute the method in 051. That is, the third acquisition module 13 can also be used to acquire the second weight value according to the color ratio and the mapping table.
[0103] As an example, the mapping table includes multiple color ratio intervals, and each color ratio interval corresponds to a weight value. For example, the mapping table includes color ratio intervals E1, E2, and E3, which correspond to weight values we1, we2, and we3, respectively. After obtaining the color ratio R, it is determined in which ratio interval the color ratio R is located, and the weight value corresponding to the interval is obtained as the second weight value. For example, if the color ratio R is located in the color ratio interval E1, the weight value we1 is used as the second weight value.
[0104] See also Fig.12 In some implementations, 05: obtaining a second weight value according to the color ratio and a preset mapping relationship includes:
[0105] 053: Obtain a second weight value according to the color ratio and the mapping curve.
[0106] Please combine Figure 2 In some implementations, the third acquisition module 13 can also be used to execute the method in 053. That is, the third acquisition module 13 can also be used to acquire the second weight value according to the color ratio and the mapping curve.
[0107] Please combine Fig.13 As an example, the mapping relationship diagram is as follows Fig.13 As shown, the horizontal axis of the mapping relationship diagram is the ratio range, the ratio range is 0 to 100%, the vertical axis of the mapping relationship diagram is the weight value, the weight value range is 0 to 1, and the curve in the mapping relationship diagram is the mapping curve. After obtaining the color ratio R, the vertical coordinate position corresponding to the horizontal coordinate of the mapping curve is R is determined, and the vertical coordinate position is used as the second weight value.
[0108] See also Fig.14 In some embodiments, the mapping relationship diagram includes a first preset ratio and a second preset ratio. 053: Obtaining a second weight value according to the color ratio and the mapping curve includes:
[0109] 0531: when the color ratio is between 0 and the first preset ratio, the second weight value is 0;
[0110] 0533: when the color ratio is between the second preset ratio and 1, the second weight value is 1; and
[0111] 0535: When the color ratio is between the first preset ratio and the second preset ratio, the second weight value is a weight value corresponding to the color ratio in the mapping curve.
[0112] Please combine Figure 2 In some embodiments, the third acquisition module 13 can also be used to execute the methods in 0531, 0533 and 0535. That is, the third acquisition module 13 can also be used to, when the color ratio is between 0 and the first preset ratio, the second weight value is 0; when the color ratio is between the second preset ratio and 1, the second weight value is 1; and when the color ratio is between the first preset ratio and the second preset ratio, the second weight value is the weight value corresponding to the color ratio in the mapping curve.
[0113] Please combine Fig.13In one embodiment, let the first preset ratio be RS1 and the second preset ratio be RS2. When the color ratio R is between 0 and RS1, the weight value corresponding to the vertical axis of the mapping curve is a constant value of 0; when the color ratio R is between RS2 and 1, the weight value corresponding to the vertical axis of the mapping curve is a constant value of 1; when the color ratio R is between RS1 and RS2, the weight value corresponding to the vertical axis of the mapping curve increases as the value of R increases. The weight value corresponding to the vertical axis of the mapping curve can be determined according to the specific value of the color ratio R, and the weight value is used as the second weight value.
[0114] See also Figure 1 , assuming that the standard correction matrix is M0, the high saturation correction matrix is M1, the second weight value is w2, and the target matrix is M3, then M3 = M1*w2+(1-w2)*M0. In this way, the target matrix M3 can perform image processing based on the second weight value w2 by integrating the standard correction matrix M0 and the high saturation correction matrix M1, so that the target matrix M2 can reduce the saturation of the high saturation scene (pixel) to improve the texture recognition of the high saturation scene while avoiding reducing the saturation of the non-high saturation scene.
[0115] See also Figure 1 and Figure 3 , assuming that the standard correction matrix is M0 and the high saturation correction matrix is M1, then M1 = (1-K) * M2 + K * M0. In some embodiments, the size of the weakening parameter K can also be changed, and a different matrix Mj can be used to replace the matrix M2 in M1 = (1-K) * M2 + K * M0, so as to specifically weaken any one or more of the 9 parameters a11, a12, a13, a21, a22, a23, a31, a32, and a33 to achieve other color adjustments, such as skin color adjustment. Correspondingly, when performing other color adjustments, the color ratio R is the proportion of the corresponding adjusted color. For example, if you want to solve the problem of yellowish skin color in the image, you can set the corresponding matrix Mj and the weakening parameter K so that the high saturation correction matrix M1' = (1-K) * Mj + K * M0 can weaken the parameter a32 corresponding to the component gb to correct the problem of yellowish color in the image. Similar to the method of obtaining the color ratio R of the high saturation color ratio according to the saturation in 03, assuming that the color ratio Rj is the ratio of the yellow color in the image, the first hue of the current frame image and the second hue of the target area can be obtained, and the color ratio Rj is obtained according to the first hue, the second hue, the preset hue threshold and the preset first hue weight value, wherein the target area is the skin area. Then, the second hue weight value is obtained according to the color ratio Rj and the preset hue mapping relationship, and the target matrix M3' is obtained according to the high saturation correction matrix M1', the standard correction matrix M0 and the second hue weight value, so that after the image is processed by the target matrix M3', only the yellow hue of the skin part is adjusted, and the colors of other parts are kept unchanged.
[0116] The degree to which the target matrix M3 reduces the saturation of the high-saturation scene (pixel) depends on the setting of the weakening parameter K of the high-saturation correction matrix M1. However, different colors have different ranges of colors outside the color gamut, and the high-saturation scenes in different frames of images are also different. The same high-saturation correction matrix M1 is difficult to correct the colors of all high-saturation scenes to the optimal level. For example, the high-saturation scene of the previous frame image is reddish, and the high-saturation scene of the current frame image is bluish. After the image processing of the previous frame image using the high-saturation correction matrix M1 or the target matrix M3, the saturation of the red high-saturation scene can be reduced well, and the texture recognition of the previous frame image is significantly improved; however, when processing the current frame image, the degree of saturation reduction of the blue high-saturation scene is not enough, and the improvement of the texture recognition of the current frame image is not obvious enough.
[0117] See also Fig.15 , the image processing method of the embodiment of the present application further includes:
[0118] 04: Get the high saturation correction matrix according to the color value of the current frame image.
[0119] In this way, the high saturation color correction effect of the obtained high saturation correction matrix on the current frame image can be improved, so that the target matrix obtained according to the high saturation correction matrix can adapt to the high saturation scene of the current frame image for correction to improve the correction effect. In addition, according to the input of different frames of images, different high saturation correction matrices can be obtained accordingly, so as to obtain the target matrix according to the high saturation correction matrices corresponding to different frame images, so that the target matrix can process any input image with a high saturation scene to obtain a significant improvement in texture recognition.
[0120] Please combine Figure 2 In some embodiments, the image processing device 10 further includes a matrix acquisition module 17 for executing the method in step 04. That is, the matrix acquisition module 17 is used to acquire a high saturation correction matrix according to the color value of the current frame image.
[0121] See also Fig.16 In some implementations, 04: obtaining a high saturation correction matrix according to the color value of the current frame image, including:
[0122] 041: Get the first color value of each pixel of the current frame image;
[0123] 042: Perform color correction on the first color value to obtain a plurality of second color values;
[0124] 043: Get the hue value of each second color value;
[0125] 044: Obtain a first output value and a second output value according to a plurality of hue values, a first color value, a second color value, and a preset strategy; and
[0126] 045: Obtain a high saturation correction matrix according to the first output value, the second output value and the standard correction matrix.
[0127] Please combine Figure 2 In some embodiments, the matrix acquisition module 17 is also used to execute the methods in 041, 042, 043, 044 and 045. That is, the matrix acquisition module 17 is also used to obtain the first color value of each pixel of the current frame image; perform color correction on the first color value to obtain multiple second color values; obtain the hue value of each second color value according to the multiple hue values, the first color value, the second color value, and the preset strategy to obtain the first output value and the second output value; obtain the high saturation correction matrix according to the first output value, the second output value and the standard correction matrix.
[0128] The first color value is the RGB color value corresponding to each pixel of the current frame image. Fig.17 In some embodiments, 042: performing color correction on the first color value to obtain a plurality of second color values, comprising:
[0129] 0421: Input each first color value into a standard correction matrix to obtain a plurality of second color values.
[0130] Please combine Figure 2 In some implementations, the matrix acquisition module 17 is further used to execute the method in 0421. That is, the matrix acquisition module 17 is further used to input each first color value into a standard correction matrix to obtain a plurality of second color values.
[0131] The second color value is an RGB color value obtained after color correction is performed on the first color value, and the color correction is implemented by a standard correction matrix. In one embodiment, the first color value corresponding to a certain pixel is set to be RjiGjiBji, and after the current frame image is input into the standard correction matrix to correct the first color value, the first color value RjiGjiBji corresponding to the pixel is corrected to RjoGjoBjo, and RjoGjoBjo is the second color value corresponding to the pixel. After color correction, each pixel of the current frame image has a corresponding second color value.
[0132] See also Fig.16 The hue value of the second color value can be obtained by converting the color of the pixel from the RGB space to the HSV space. The corresponding hue value is obtained for the second color value corresponding to each pixel of the current frame image.
[0133] The preset strategy is used to determine the maximum color that exceeds the color gamut among multiple second color values. The second output value is obtained according to the second color value corresponding to the maximum color, and the first output value is obtained according to the first color value corresponding to the second color value corresponding to the maximum color. The first output value and the second output value are used to obtain a high-saturation correction matrix. Since the second output value is the maximum color that exceeds the color gamut after correction by the standard correction matrix, and the first output value is the color of the second output value before correction by the standard correction matrix, if the high-saturation correction matrix can correct the first output value and the second output value back to the color gamut, other colors that exceed the color gamut can be corrected back to the color gamut.
[0134] Different colors have different ranges of colors outside the color gamut. For example, under the sRGB (standard Red GreenBlue, sRGB) color gamut standard, the color range of the red hue outside the color gamut is smaller than the color range of the green hue outside the color gamut, that is, it may happen that the high saturation correction matrix can correct all the colors outside the color gamut of the red hue back to the color gamut, but the parameters set by the high saturation correction matrix can only correct part of the colors outside the color gamut of the green hue back to the color gamut, and cannot correct all the colors outside the color gamut of the green hue back to the color gamut. Therefore, the preset strategy needs to determine the maximum color outside the color gamut in combination with the hue values corresponding to the multiple second color values, so as to obtain different high saturation correction matrices according to the color values corresponding to different color scenes, so that any frame image with different color scenes can improve the texture recognition in the image through the high saturation correction matrix corresponding to the color scene. In this way, the texture recognition of the high saturation scene of any frame image can be significantly improved by the target matrix obtained according to the high saturation correction matrix.
[0135] See also Fig.18 In some embodiments, 044: obtaining a first output value and a second output value according to the hue value, the first color value, the second color value, and a preset strategy, includes:
[0136] 0441: Obtain a second output value according to a plurality of hue values, a plurality of second color values, and a preset strategy; and
[0137] 0443: Select a color value corresponding to the second output value from a plurality of first color values as the first output value.
[0138] Please combine Figure 2 In some embodiments, the matrix acquisition module 17 is further used to execute the methods in 0441 and 0443. That is, the matrix acquisition module 17 is further used to obtain the second output value according to multiple hue values, multiple second color values, and a preset strategy; and select a color value corresponding to the second output value from the multiple first color values as the first output value.
[0139] In one embodiment, the preset strategy first determines the maximum second color value that exceeds the color gamut according to the multiple hue values and the multiple second color values, and uses the maximum second color value as the second output value, and then selects the color value corresponding to the second output value from the multiple first color values as the first output value.
[0140] See also Fig.19 In some embodiments, 0441: obtaining a second output value according to a plurality of hue values, a plurality of second color values, and a preset strategy, includes:
[0141] 04411: Find the hue interval corresponding to each hue value, and each hue interval corresponds to a third weight value;
[0142] 04412: Obtain a weighted color value according to each second color value in the hue interval and the corresponding third weight value, where the weighted color value includes a plurality of weighted components;
[0143] 04413: Filter maximum and minimum values from multiple weighted components;
[0144] 04414: when the absolute value of the difference between the maximum value and the preset upper limit value is greater than the absolute value of the difference between the minimum value and the preset lower limit value, taking the second color value corresponding to the maximum value as the second output value; and
[0145] 04415: When the absolute value of the difference between the maximum value and the preset upper limit value is smaller than the absolute value of the difference between the minimum value and the preset lower limit value, the second color value corresponding to the minimum value is used as the second output value.
[0146] Please combine Figure 2 In some embodiments, the matrix acquisition module 17 is also used to execute the methods in 04411, 04412, 04413, 04414 and 04415. That is, the matrix acquisition module 17 is also used to find the hue interval corresponding to each hue value, each hue interval corresponds to a third weight value; obtain a weighted color value according to each second color value in the hue interval and the corresponding third weight value, the weighted color value includes a plurality of weighted components; select a maximum value and a minimum value from the plurality of weighted components; when the absolute value of the difference between the maximum value and the preset upper limit value is greater than the absolute value of the difference between the minimum value and the preset lower limit value, use the second color value corresponding to the maximum value as the second output value; and when the absolute value of the difference between the maximum value and the preset upper limit value is less than the absolute value of the difference between the minimum value and the preset lower limit value, use the second color value corresponding to the minimum value as the second output value.
[0147] In one embodiment, the third weight value is a weight value preset according to the importance of the color. For example, if the user is more concerned with solving the texture blur problem caused by the oversaturation of the red hue, a larger third weight value can be set in the hue interval corresponding to the red color, so that the high saturation correction matrix finally obtained and the target matrix obtained according to the high saturation correction matrix improve the blur problem of the red texture more than the blur problem of the textures of other colors.
[0148] In one embodiment, the hue interval may be a plurality of intervals evenly divided according to the hue range, for example, each integer value of 0 to 255 is divided into a hue interval according to the hue range of the HSV space. In another embodiment, the hue interval may be a plurality of intervals evenly divided according to the hue range, for example, according to the hue range of the HSV space, the hue between the red hue and the magenta hue is divided into one interval, and the hue between the magenta hue and the blue hue is divided into another interval, and the interval range corresponding to the magenta hue and the blue hue is larger than the interval range corresponding to the red hue and the magenta hue.
[0149] Please combine Fig. 20 , Fig. 20 The illustrated embodiment includes five hue intervals: V1, V2, V3, V4, and V5, which correspond to third weight values w31, w32, w33, w34, and w35, respectively. Assuming that the hue of a second color value R1oG1oB1o is H1, and H1 is within the hue interval V2, then the weighted color value R1wG1wB1w corresponding to the second color value R1oG1oB1o=R1oG1oB1o*w32. The weighted color values R1wG1wB1w include three weighted components: R1w, G1w, and B1w. Similarly, after the corresponding third weight values of the multiple second color values RjoGjoBjo are determined in the corresponding hue interval, multiple weighted color values RjwGjwBjw can be obtained accordingly, where j is an integer greater than 0. The multiple weighted color values RjwGjwBjw include multiple weighted components, for example, the weighted components include R1w, R2w...Rjw; G1w, G2w...Gjw; B1w, B2w...Bjw, and the maximum and minimum values will be screened from these weighted components.
[0150] The preset upper limit value and the preset lower limit value are reference values for measuring whether the color is within the color gamut. In one embodiment, the preset upper limit value is 1, the preset lower limit value is 0, and the preset upper limit value and the preset lower limit value are within the color gamut, that is, the weighted component within the range of [0, 1] is considered to be within the color gamut. The extent to which the weighted component exceeds the preset upper limit value or is lower than the preset lower limit value reflects the extent to which the weighted component exceeds the color gamut.
[0151] Let the maximum value be Dmax, the minimum value be Dmin, the preset upper limit value be 1, and the preset lower limit value be 0. Then compare the magnitudes of |Dmax - 1| and |0 - Dmin| to determine the weighted component that exceeds the gamut range the most between the maximum value Dmax and the minimum value Dmin. In the case where |Dmax - 1| > |0 - Dmin|, the maximum value Dmax exceeds the gamut range the most. Then, take the second color value corresponding to the maximum value Dmax as the second output value. For example, if the weighted component corresponding to the maximum value Dmax is R2w, the weighted color value corresponding to the weighted component R2w is R2wG2wB2w, and the second color value corresponding to the weighted color value R2wG2wB2w is R2oG2oB2o, then the second color value corresponding to the maximum value Dmax is R2oG2oB2o, and take R2oG2oB2o as the second output value. After determining that the second output value is R2oG2oB2o, take the first color value R2iG2iB2i corresponding to R2oG2oB2o as the first output value. Similarly, in the case where |Dmax - 1| < |0 - Dmin|, the minimum value Dmin exceeds the gamut range the most, then take the second color value corresponding to the minimum value Dmin as the second output value.
[0152] Please refer to Fig.21 , in some embodiments, the second color value includes multiple components. 04: Obtaining a high-saturation correction matrix according to the color value of the current frame image further includes:
[0153] 046: Generate a lookup table.
[0154] 046: Generate a lookup table, including:
[0155] 0461: Respectively determine whether multiple components of the second color value exceed the gamut range;
[0156] 0462: In the case where any one of the components of the second color value exceeds the gamut range, find the hue interval corresponding to the hue value of the second color value as the storage address of the second color value; and
[0157] 0463: Store each second color value and the first color value corresponding to the second color value in the corresponding storage address to generate a lookup table.
[0158] Please combine with Figure 2In some embodiments, the matrix acquisition module 17 is further used to execute the methods in 046, 0461, 0462 and 0463. That is, the matrix acquisition module 17 is further used to respectively determine whether multiple components of the second color value exceed the color gamut range; when any component of the second color value exceeds the color gamut range, find the hue interval corresponding to the hue value of the second color value as the storage address of the second color value; and store each second color value and the first color value corresponding to the second color value in the corresponding storage address to generate a lookup table.
[0159] Please combine Fig. 20 , Fig. 20 The illustrated embodiment is an example of a lookup table. Each storage address (the address of the second color value and the address of the first color value) corresponds to a hue interval V, and each hue interval corresponds to a third weight value w3, so each storage address corresponds to a third weight value w3. By generating a lookup table, the second color value can be screened before obtaining the weighted component, and the second color value whose component exceeds the color gamut range is weighted according to the third weight value corresponding to the storage address where it is located, and the second color value whose component does not exceed the color gamut range is not subsequently processed, so as to reduce the amount of data processing and improve image processing efficiency.
[0160] See also Fig. 22 In some embodiments, 045 obtains a high saturation correction matrix according to the first output value, the second output value and the standard correction matrix, including:
[0161] 0451: Obtain a weakening parameter according to the first output value, the second output value, the preset first relationship and the preset second relationship, and the preset component coefficient corresponding to each component; and
[0162] 0452: Obtain a high saturation correction matrix based on the attenuation parameters and the standard correction matrix.
[0163] Please combine Figure 2 In some embodiments, the matrix acquisition module 17 is further used to execute the methods in 046, 0461, 0462 and 0463. That is, the matrix acquisition module 17 is further used to acquire a weakening parameter according to the first output value, the second output value, the preset first relationship and the preset second relationship, and the preset component coefficient corresponding to each component; and acquire a high saturation correction matrix according to the weakening parameter and the standard correction matrix.
[0164] In some embodiments, assuming that the standard correction matrix is M0 and the high saturation correction matrix is M1, then M1 = (1-K) * M2 + K * M0. That is, the high saturation correction matrix M1 is obtained according to the weakening parameter K and the standard correction matrix M0. The degree of saturation reduction of the high saturation color by the high saturation correction matrix M1 can be adjusted by adjusting the size of the weakening parameter K. The weakening parameter K is obtained according to the first output value, the second output value, the preset first relationship and the preset second relationship, and the preset component coefficient corresponding to each component, so that the high saturation correction matrix M1 obtained according to the weakening parameter K can reduce the saturation of the high saturation scene of the current frame image to an appropriate degree. Since the second output value represents the color value that exceeds the color gamut range the most in the colors of each hue of the current frame image, the weakening parameter K obtained according to the first output value and the second output value can have a good correction effect on the colors of each hue of the current frame image that exceed the color gamut range, so that the high saturation correction matrix M1 can effectively improve the texture recognition of various high saturation scenes of the current frame image.
[0165] See also Fig.23 In some embodiments, 0451: obtaining a weakening parameter according to the first output value, the second output value, the preset first relationship and the preset second relationship, and the preset component coefficient corresponding to each component, including:
[0166] 04511: when any one of the multiple components of each second output value is less than a lower limit value, obtaining a first parameter according to the first output value, the multiple components corresponding to the second output value, the coefficients corresponding to the components, and the first relationship;
[0167] 04513: when any one of the multiple components of each second output value is greater than the upper limit value, obtaining a second parameter according to the first output value, the multiple components corresponding to the second output value, the coefficients corresponding to the components, and the second relationship; and
[0168] 04515: The smaller of the first and second parameters is used as the weakening parameter.
[0169] Please combine Figure 2 In some embodiments, the matrix acquisition module 17 is further used to execute the methods in 04511, 04513, and 04515. That is, the matrix acquisition module 17 is further used to acquire the first parameter according to the first output value, the multiple components corresponding to the second output value, the coefficients corresponding to the components, and the first relationship when any one of the multiple components of each second output value is less than the lower limit value; acquire the second parameter according to the first output value, the multiple components corresponding to the second output value, the coefficients corresponding to the components, and the second relationship when any one of the multiple components of each second output value is greater than the upper limit value; and use the smaller of the first parameter and the second parameter as the weakening parameter.
[0170] Assume that the first output value is RjiGjiBji, the second output value is RjoGjoBjo, the second output value includes components: Rjo, Gjo, Bjo, the lower limit value is 0, the upper limit value is 1, the first parameter is K1, and the second parameter is K2.
[0171] The first relationship is: (1-K1)*X1+K1*(ax11,ax12,ax13,)*RjiGjiBji T =0;
[0172] The second relationship is: (1-K2)*X2+K2*(ax21, ax22, ax23,)*RjiGjiBji T =1.
[0173] Among them, X1 is the component Rjo, Gjo, Bjo of the second output value RjoGjoBjo, which is less than the lower limit value 0, ax11, ax12, and ax13 are the coefficients corresponding to the component X1 in the standard correction matrix. X2 is the component Rjo, Gjo, Bjo of the second output value RjoGjoBjo, which is greater than the upper limit value 1, ax21, ax22, and ax23 are the coefficients corresponding to the component X2 in the standard correction matrix.
[0174] When any one of the multiple components of each second output value is less than the lower limit value, the first parameter K1 is determined by the first relationship; when any one of the multiple components of each second output value is greater than the upper limit value, the second parameter K2 is determined by the second relationship, and the smaller one of the first parameter K1 and the second parameter K2 is used as the weakening parameter K, so as to obtain the high saturation correction matrix M1 according to the weakening parameter K, so that the high saturation correction matrix M1 corrects the high saturation color according to the weakening parameter K. Since the smaller the value of the weakening parameter K, the higher the degree of correction of the high saturation color exceeding the color gamut range, the smaller one of the first parameter K1 and the second parameter K2 is used as the weakening parameter K, so as to ensure that the high saturation colors of different hues of the current frame image are well corrected, that is, multiple high saturation colors of different hues exceeding the color gamut range have enough colors corrected back to the color gamut range, so that the color difference near the boundary of the color gamut range is rich, so as to improve the texture recognition of the high saturation scene.
[0175] In summary, the image processing method and the image processing device 10 of the embodiment of the present application can obtain the target matrix according to the high saturation correction matrix, the standard correction matrix and the second weight value, so that the obtained target matrix can improve the texture recognition of the high saturation scene in the image, and will not reduce the saturation of the non-high saturation scene. Among them, the high saturation correction matrix is obtained according to the color value of the current frame image, and has a good correction effect on the colors of each hue in the current frame image.
[0176] See also Fig.24 The present application also provides a method for obtaining a high saturation matrix, and the method for obtaining a high saturation matrix includes:
[0177] 061: Get the first color value of each pixel of the current frame image;
[0178] 062: Perform color correction on the first color value to obtain a plurality of second color values, where the second color value includes a plurality of components;
[0179] 063: When any component exceeds the color gamut, obtain the hue value of each second color value;
[0180] 064: Obtain a first output value and a second output value according to a plurality of hue values, a first color value, a second color value, and a preset strategy; and
[0181] 065: Obtain a high saturation correction matrix according to the first output value, the second output value and the standard correction matrix.
[0182] Please combine Fig.25 The present application also provides a high saturation matrix acquisition device, which includes: a sixth acquisition module 21, a seventh acquisition module 22, an eighth acquisition module 23, a ninth acquisition module 24, and a tenth acquisition module 25. The sixth acquisition module 21 can be used to execute the method in 061; the seventh acquisition module 22 can be used to execute the method in 062; the eighth acquisition module 23 can be used to execute the method in 063; the ninth acquisition module 24 can be used to execute the method in 064; and the tenth acquisition module 25 can be used to execute the method in 065. That is, the sixth acquisition module 21 can be used to obtain the first color value of each pixel of the current frame image; the seventh acquisition module 22 can be used to perform color correction on the first color value to obtain multiple second color values, and the second color value includes multiple components; the eighth acquisition module 23 can be used to obtain the hue value of each second color value when any component exceeds the color gamut; the ninth acquisition module 24 can be used to obtain the first output value and the second output value based on multiple hue values, the first color value, the second color value, and a preset strategy; the tenth acquisition module 25 can be used to obtain a high saturation correction matrix based on the first output value, the second output value and the standard correction matrix.
[0183] Please combine Fig.16 , the method for obtaining the high saturation matrix of 061 to 065 is similar to the method of 041 to 045 in the image processing method described above, and will not be described here. The only difference is that the method of 063 obtains the hue value of each second color value when any component exceeds the color gamut range, while the method of 043 does not have the restriction condition of "when any component exceeds the color gamut range".
[0184] The method for obtaining the high saturation matrix provided in the embodiment of the present application can be obtained according to the color value of the current frame image, and has a good correction effect on the colors of each hue in the current frame image, so that enough colors in the high saturation image of each hue exceeding the color gamut range in the previous frame image are corrected back to the color gamut range, so that the color difference near the boundary of the color gamut range is rich, so as to improve the texture recognition of the high saturation scene. Combined with the image processing method described above, that is, the high saturation correction matrix obtained in the image processing method can be used alone for image processing to improve the texture recognition of high saturation scenes of different hues. In the image processing method described above, the target matrix processing image is obtained by weighting the high saturation correction matrix and the standard correction matrix, which can achieve the effect of the high saturation correction matrix to improve the high texture recognition of the saturation scene while ensuring that the saturation of the non-high saturation scene will not be reduced.
[0185] See also Fig.26 In some implementations, the method for obtaining a high saturation matrix further includes:
[0186] 066: When each component is within the color gamut, the standard correction matrix is used as the high saturation correction matrix.
[0187] Please combine Fig.25 In some embodiments, the high-saturation matrix acquisition device also includes an eleventh acquisition module 26 for executing the method in 066, that is, the eleventh acquisition module 26 is used to use the standard correction matrix as the high-saturation correction matrix when each component is within the color gamut.
[0188] In this way, when each component is within the color gamut, conventional color correction can be performed using only a standard correction matrix, without the need to obtain a high-saturation correction matrix corresponding to the current frame image, thereby saving image processing steps and improving image processing efficiency.
[0189] See also Fig. 27 In some embodiments, 062: performing color correction on the first color value to obtain a plurality of second color values, comprising:
[0190] 0621: Input each first color value into a standard correction matrix to obtain a plurality of second color values.
[0191] Please combine Fig.25 In some implementations, the seventh acquisition module 22 is further used to execute the method in 0621. That is, the seventh acquisition module 22 is further used to input each first color value into a standard correction matrix to obtain a plurality of second color values.
[0192] Please combine Fig.17, the method in 0621 is similar to the method in 0421 in the image processing method, and will not be described in detail here.
[0193] See also Fig.28 In some embodiments, 064: obtaining a first output value and a second output value according to the hue value, the first color value, the second color value, and a preset strategy, includes:
[0194] 0641: Obtain a second output value according to a plurality of hue values, a plurality of second color values, and a preset strategy; and
[0195] 0643: Select a color value corresponding to the second output value from a plurality of first color values as the first output value.
[0196] Please combine Figure 2 In some embodiments, the ninth acquisition module 24 is further used to execute the methods in 0641 and 0643. That is, the ninth acquisition module 24 is further used to acquire the second output value according to a plurality of hue values, a plurality of second color values, and a preset strategy; and select a color value corresponding to the second output value from a plurality of first color values as the first output value.
[0197] Please combine Fig.28 The methods in 0641 and 0643 are similar to the methods in 0441 and 0443 in the image processing method, and will not be described in detail here.
[0198] See also Fig.29 In some embodiments, 0641: obtaining a second output value according to a plurality of hue values, a plurality of second color values, and a preset strategy, includes:
[0199] 06411: Find the hue interval corresponding to each hue value, and each hue interval corresponds to a third weight value;
[0200] 06412: Obtain a weighted color value according to each second color value in the hue interval and the corresponding third weight value, where the weighted color value includes a plurality of weighted components;
[0201] 06413: Filter maximum and minimum values from multiple weighted components;
[0202] 06414: when the absolute value of the difference between the maximum value and the preset upper limit value is greater than the absolute value of the difference between the minimum value and the preset lower limit value, taking the second color value corresponding to the maximum value as the second output value; and
[0203] 06415: When the absolute value of the difference between the maximum value and the preset upper limit value is smaller than the absolute value of the difference between the minimum value and the preset lower limit value, the second color value corresponding to the minimum value is used as the second output value.
[0204] Please combine Figure 2 In some embodiments, the ninth acquisition module 24 is further used to execute the methods in 06411, 06412, 06413, 06414 and 06415. That is, the ninth acquisition module 24 is further used to find the hue interval corresponding to each hue value, each hue interval corresponds to a third weight value; obtain a weighted color value according to each second color value in the hue interval and the corresponding third weight value, the weighted color value includes a plurality of weighted components; select a maximum value and a minimum value from the plurality of weighted components; when the absolute value of the difference between the maximum value and the preset upper limit value is greater than the absolute value of the difference between the minimum value and the preset lower limit value, the second color value corresponding to the maximum value is used as the second output value; and when the absolute value of the difference between the maximum value and the preset upper limit value is less than the absolute value of the difference between the minimum value and the preset lower limit value, the second color value corresponding to the minimum value is used as the second output value.
[0205] Please combine Fig.19 , the methods in 06411 to 06415 are similar to the methods in 04411 to 04415 in the image processing method, and will not be repeated here.
[0206] See also Fig.30 In some embodiments, the second color value includes multiple components, and the method for obtaining the high saturation matrix further includes:
[0207] 067: Generate a lookup table.
[0208] 067: Generate a lookup table, including:
[0209] 0671: respectively determine whether multiple components of the second color value exceed the color gamut range;
[0210] 0672: When any component of the second color value exceeds the color gamut, searching for a hue interval corresponding to the hue value of the second color value as a storage address of the second color value; and
[0211] 0673: Store each second color value and the first color value corresponding to the second color value in a corresponding storage address to generate a lookup table.
[0212] Please combine Fig.25 In some embodiments, the high saturation matrix acquisition device further includes a generation module 26, which is used to execute the methods in 067, 0671, 0672 and 0673. That is, the generation module 26 is also used to generate a lookup table; respectively determine whether multiple components of the second color value exceed the color gamut range; when any component of the second color value exceeds the color gamut range, find the hue interval corresponding to the hue value of the second color value as the storage address of the second color value; and store each second color value and the first color value corresponding to the second color value in the corresponding storage address to generate a lookup table.
[0213] Please combine Fig.21 The method in 067 is similar to the method in 046 in the image processing method, and the methods in 0671 to 0673 are similar to the methods in 0461 to 0463 in the image processing method, which will not be described in detail here.
[0214] See also Fig.31 In some embodiments, 065 obtains a high saturation correction matrix according to the first output value, the second output value and the standard correction matrix, including:
[0215] 0651: Obtain a weakening parameter according to the first output value, the second output value, the preset first relationship and the preset second relationship, and the preset component coefficient corresponding to each component; and
[0216] 0652: Obtain a high saturation correction matrix based on the attenuation parameters and the standard correction matrix.
[0217] Please combine Fig.25 In some embodiments, the tenth acquisition module 25 is further used to execute the methods in 0651 and 0652. That is, the matrix acquisition module 17 is further used to acquire a weakening parameter according to the first output value, the second output value, the preset first relationship and the preset second relationship, and the preset component coefficient corresponding to each component; and acquire a high saturation correction matrix according to the weakening parameter and the standard correction matrix.
[0218] Please combine Fig. 22 The methods in 0651 and 0652 are similar to the methods in 0451 and 0452 in the image processing method, and will not be described in detail here.
[0219] See also Fig.32 In some embodiments, 0651: obtaining a weakening parameter according to the first output value, the second output value, the preset first relationship and the preset second relationship, and the preset component coefficient corresponding to each component, includes:
[0220] 06511: when any one of the multiple components of each second output value is less than a lower limit value, obtaining a first parameter according to the first output value, the multiple components corresponding to the second output value, the coefficients corresponding to the components, and the first relationship;
[0221] 06513: when any one of the multiple components of each second output value is greater than the upper limit value, obtaining a second parameter according to the first output value, the multiple components corresponding to the second output value, the coefficients corresponding to the components, and the second relationship; and
[0222] 06515: The smaller of the first and second parameters is used as the weakening parameter.
[0223] Please combine Fig.25In some embodiments, the tenth acquisition module 25 is further used to execute the methods in 06511, 06513, and 06515. That is, the tenth acquisition module 25 is further used to acquire the first parameter according to the first output value, the multiple components corresponding to the second output value, the coefficients corresponding to the components, and the first relationship when any one of the multiple components of each second output value is less than the lower limit value; acquire the second parameter according to the first output value, the multiple components corresponding to the second output value, the coefficients corresponding to the components, and the second relationship when any one of the multiple components of each second output value is greater than the upper limit value; and use the smaller of the first parameter and the second parameter as the weakened parameter.
[0224] See also Fig.33 , the embodiment of the present application also provides a terminal 100. The terminal 100 can be an electronic device such as a mobile phone, a desktop computer, a laptop computer, a camera, etc., which is not limited here. The terminal 100 includes: one or more processors 50, a memory 60; and one or more programs, wherein the one or more programs are stored in the memory 60 and executed by the one or more processors 50, and the program includes instructions for executing the image processing method of any one of claims 1 to 10 and / or the method for obtaining a high saturation matrix of any one of claims 11 to 17.
[0225] See also Fig.34 The embodiment of the present application further provides a non-volatile computer-readable storage medium 300 containing a computer program 301. One or more non-volatile computer-readable storage media 300 containing a computer program 301 in the embodiment of the present application, when the computer program 301 is executed by one or more processors 30, enables the processor 30 to execute the image processing method of any of the above embodiments, for example, to implement steps 01, 02, 03, 04, 05, 07, 09, 021, 023, 011, 013, 031, 033, 035, 0311, 0312 , 0331, 0332, 051, 053, 0531, 0533, 0535, 041, 042, 043, 044, 045, 0421, 0441, 0443, 04411, 04412, 04413, 04414, 04415, 046, 0461, 0462, 0463, 0451, 0452, 04511, 04513 and 04515. The processor 30 can execute the method for obtaining a high saturation matrix of any of the above-mentioned embodiments, for example, implementing one or more steps of steps 061, 062, 063, 064, 065, 066, 0621, 0641, 0643, 06411, 06412, 06413, 06414, 06415, 067, 0671, 0672, 0673, 0651, 0652, 06511, 06513 and 06515.
[0226] For example, when the computer program 301 is executed by one or more processors 30, the processor 30 performs the following steps:
[0227] 01: Get the first saturation of the current frame image and the second saturation of the target area of the current frame image;
[0228] 03: Obtaining a color ratio according to the first saturation, the second saturation, a preset saturation threshold and a preset first weight value;
[0229] 05: Obtain a second weight value according to the color ratio and a preset mapping relationship, the mapping relationship is used to reflect the corresponding relationship between the color ratio and the second weight value, and the second weight value is used to represent the weight between the high saturation correction matrix and the standard correction matrix;
[0230] 07: Obtain a target matrix according to the high saturation correction matrix, the standard correction matrix and the second weight value; and
[0231] 09: Correct the current frame image according to the target matrix. For another example, when the computer program 301 is executed by one or more processors 30, the processor 30 performs the following steps:
[0232] 061: Get the first color value of each pixel of the current frame image;
[0233] 062: Perform color correction on the first color value to obtain a plurality of second color values, where the second color value includes a plurality of components;
[0234] 063: When any component exceeds the color gamut, obtain the hue value of each second color value;
[0235] 064: Obtain a first output value and a second output value according to a plurality of hue values, a first color value, a second color value, and a preset strategy; and
[0236] 065: Obtain a high saturation correction matrix according to the first output value, the second output value and the standard correction matrix.
[0237] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, a technician in the field may combine and combine different embodiments or examples described in this specification and features of different embodiments or examples, unless they are contradictory.
[0238] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0239] Although the embodiments of the present application have been shown and described above, it is to be understood that the above embodiments are exemplary and cannot be construed as limitations on the present application. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present application.
Claims
1. An image processing method, characterized in that: include: Acquire a first saturation of a current frame image and a second saturation of a target area of the current frame image; Obtaining a color ratio according to the first saturation, the second saturation, a preset saturation threshold, and a preset first weight value; Acquire a second weight value according to the color ratio and a preset mapping relationship, wherein the mapping relationship is used to reflect the corresponding relationship between the color ratio and the second weight value, and the second weight value is used to represent the weight between the high saturation correction matrix and the standard correction matrix; Acquire a target matrix according to the high saturation correction matrix, the standard correction matrix and the second weight value; and Correcting the current frame image according to the target matrix; The obtaining of the color ratio according to the first saturation, the second saturation, a preset saturation threshold and a preset first weight value includes: Acquire a first ratio according to the first saturation and the saturation threshold, where the first ratio is a ratio between the number of pixels corresponding to the saturation greater than the saturation threshold in the first saturation and the total number of pixels in the current frame image; Acquire a second ratio according to the second saturation and the saturation threshold, the second ratio being a ratio between the number of pixels corresponding to the saturation greater than the saturation threshold in the second saturation and the total number of pixels in the target area; and The color ratio is acquired according to the first ratio, the second ratio, and the first weight.
2. The image processing method according to claim 1, characterized in that The acquiring the first saturation of the current frame image and the second saturation of the target area of the current frame image includes: Convert the current frame image and the target area from the RGB space to the HSV space; and The first saturation and the second saturation are acquired in the HSV space.
3. The image processing method according to claim 1, characterized in that: Also includes: The high saturation correction matrix is obtained according to the color value of the current frame image.
4. The image processing method according to claim 3, characterized in that: The obtaining the high saturation correction matrix according to the color value of the current frame image includes: Obtaining a first color value of each pixel of the current frame image; Performing color correction on the first color value to obtain a plurality of second color values, wherein the second color values include a plurality of components; When any one of the components exceeds the color gamut, obtaining the hue value of each of the second color values; Obtaining a first output value and a second output value according to the plurality of hue values, the first color value, the second color value, and a preset strategy; and The high-saturation correction matrix is obtained according to the first output value, the second output value, and the standard correction matrix.
5. The image processing method according to claim 4, characterized in that: The obtaining of the first output value and the second output value according to the hue value, the first color value, the second color value, and a preset strategy includes: Acquire the second output value according to the plurality of hue values, the plurality of the second color values, and the preset strategy; and A color value corresponding to the second output value is selected from the plurality of first color values to serve as the first output value.
6. The image processing method according to claim 5, characterized in that: Obtaining the second output value according to the plurality of hue values, the plurality of the second color values, and the preset strategy includes: Finding a hue interval corresponding to each of the hue values, each of the hue intervals corresponding to a third weight value; Acquire a weighted color value according to each of the second color values in the hue interval and the corresponding third weight value, wherein the weighted color value includes a plurality of weighted components; Filtering the maximum value and the minimum value from the plurality of weighted components; When the absolute value of the difference between the maximum value and the preset upper limit value is greater than the absolute value of the difference between the minimum value and the preset lower limit value, the second color value corresponding to the maximum value is used as the second output value; and When the absolute value of the difference between the maximum value and the preset upper limit value is smaller than the absolute value of the difference between the minimum value and the preset lower limit value, the second color value corresponding to the minimum value is used as the second output value.
7. The image processing method according to claim 4, characterized in that: The step of performing color correction on the first color value to obtain a plurality of second color values comprises: Each of the first color values is input into the standard correction matrix to obtain a plurality of the second color values.
8. The image processing method according to claim 4, characterized in that: Each of the second output values includes a plurality of components, and obtaining the high saturation correction matrix according to the first output value, the second output value and the standard correction matrix includes: Acquire a weakening parameter according to the first output value, the second output value, the preset first relationship and the preset second relationship, and a preset component coefficient corresponding to each of the components; and The high saturation correction matrix is obtained according to the attenuation parameter and the standard correction matrix.
9. The image processing method according to claim 8, characterized in that: The step of obtaining the first output value, the second output value, the preset first relationship and the preset second relationship, and the preset component coefficient corresponding to each of the components to obtain the weakening parameter includes: When any one of the multiple components of each of the second output values is less than a lower limit value, obtaining a first parameter according to the first output value, the multiple components corresponding to the second output value, the coefficients corresponding to the components, and the first relationship; When any one of the plurality of components of each second output value is greater than an upper limit value, obtaining a second parameter according to the first output value, the plurality of components corresponding to the second output value, the coefficients corresponding to the components, and the second relationship; and The smaller one of the first parameter and the second parameter is used as the weakening parameter.
10. An image processing device, characterized in that: include: A first acquisition module, used to acquire a first saturation of a current frame image and a second saturation of a target area of the current frame image; A second acquisition module, used for acquiring a color ratio according to the first saturation, the second saturation, a preset saturation threshold and a preset first weight value; a third acquisition module, configured to acquire a second weight value according to the color ratio and a preset mapping relationship, wherein the mapping relationship is used to reflect the corresponding relationship between the color ratio and the second weight value, and the second weight value is used to represent the weight between the high saturation correction matrix and the standard correction matrix; A fourth acquisition module, configured to acquire a target matrix according to the high saturation correction matrix, the standard correction matrix and the second weight value; and A correction module, used for correcting the current frame image according to the target matrix; The second acquisition module is further used to acquire a first ratio according to the first saturation and the saturation threshold, wherein the first ratio is a ratio between the number of pixels corresponding to the saturation greater than the saturation threshold in the first saturation and the total number of pixels in the current frame image; Acquire a second ratio according to the second saturation and the saturation threshold, where the second ratio is a ratio between the number of pixels corresponding to the saturation greater than the saturation threshold in the second saturation and the total number of pixels in the target area; and obtaining the color ratio according to the first ratio, the second ratio, and the first weight.
11. A terminal, characterized in that: The terminal comprises: one or more processors, memory; and One or more programs, wherein the one or more programs are stored in the memory and executed by the one or more processors, and the programs include programs for executing the image processing method according to any one of claims 1 to 9.
12. A non-volatile computer-readable storage medium containing a computer program, which, when executed by one or more processors, enables the processors to implement the image processing method according to any one of claims 1 to 9.
