A color difference correction method and related apparatus

By extracting a local image of the boundary line of the highlighted area from the image and using the gradient change value of the color channel for correction, the color difference phenomenon in the image is solved, the color difference correction efficiency is improved, and the transition information of the image is preserved to prevent distortion.

CN115908172BActive Publication Date: 2025-12-19ZHEJIANG DAHUA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211396470.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-07
Publication Date
2025-12-19
Estimated Expiration
2042-11-07

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively correct color differences in image processing, especially at the edges of bright areas, leading to image distortion.

Method used

By extracting the boundary between the highlighted and non-highlighted areas from the original image, a local image is obtained. The gradient change value of one color channel in the local image is used to correct the other color channels. The local image is then corrected using the gradient change values ​​of each color channel.

Benefits of technology

It improves the efficiency of color difference correction, avoids correcting the entire image, preserves the transition information between the highlight area and the adjacent area, and prevents image distortion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115908172B_ABST
    Figure CN115908172B_ABST
Patent Text Reader

Abstract

The application discloses a color difference correction method and related device, the method comprises the following steps: obtaining an original image; wherein the original image contains at least adjacent first area and second area, and the average brightness of the first area is greater than the average brightness of the second area; obtaining a local image containing the first area and the second area boundary based on the original image; obtaining the first gradient change value of one color channel in the local image, and obtaining the second gradient change value of the remaining color channels in the local image based on the first gradient change value; correcting the local image based on the gradient change value of each color channel to obtain a corrected image. In the above manner, the application can improve the efficiency of correcting the color difference of the edge of the highlight area of the image, and improve the quality of the corrected image.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing, in particular to a color difference correction method and related device. BACKGROUND

[0002] In an optical imaging system, the incident light formed by the emission or reflection of an object is refracted by a lens to form an image plane. Since the refractive index of the lens is not consistent for different wavelengths, the outgoing light cannot be focused on the same point, thereby forming a chromatic or color aberration phenomenon.

[0003] The color difference phenomenon generally exists at the junction of high and low light in an image, and is specifically manifested as a colored edge. The common "purple edge" phenomenon in digital photos is a significant manifestation of the color difference phenomenon. In the prior art, part of the color difference is removed mainly through image filtering processing, but this method may cause the loss of part of the features in the image, thereby causing image distortion. SUMMARY

[0004] The technical problem solved by the present application is to provide a color difference correction method and related device, which can improve the efficiency of correcting the color difference of the edge of the highlight area of an image and improve the quality of the corrected image.

[0005] To solve the above technical problem, one technical solution adopted by the present application is to provide a color difference correction method, comprising: obtaining an original image; wherein the original image contains at least a first region and a second region adjacent to each other, and the average brightness of the first region is greater than the average brightness of the second region; obtaining a local image containing the boundary line between the first region and the second region based on the original image; obtaining a first gradient change value of one color channel in the local image, and obtaining a second gradient change value of the remaining color channels in the local image based on the first gradient change value; and correcting the local image based on the gradient change values of each color channel to obtain a corrected image.

[0006] To solve the above technical problem, another technical solution adopted by the present application is to provide an electronic device comprising a memory and a processor coupled to each other, wherein the processor stores program instructions, and the processor is configured to execute the program instructions to implement the color difference correction method described in the above technical solution.

[0007] To solve the above technical problem, still another technical solution adopted by the present application is to provide a storage device storing program instructions executable by a processor, wherein the program instructions are configured to implement the color difference correction method described in the above technical solution.

[0008] The beneficial effect of the present application is that, different from the prior art, the color difference correction method proposed by the present application extracts a local image containing the boundary between the highlight area and the non-highlight area from the original image, and according to the color characteristics of the color difference area, obtains the first gradient change value of one color channel in the local image, and corrects the gradient change values of the remaining color channels related to the color characteristics of the color difference area based on the first gradient change value, so as to correct the local image based on the gradient change values of the color channels to obtain a corrected image. This method can avoid correcting the complete original image, thereby improving the efficiency of color difference correction, and using the gradient change values of the color channels to correct the local image can effectively preserve the transition information between the highlight area and the adjacent area, avoiding distortion of the corrected image. BRIEF DESCRIPTION OF DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort. Among them:

[0010] Figure 1 is a flowchart of an embodiment of the color difference correction method of the present application;

[0011] Figure 2 is Figure 1 is a flowchart of an embodiment of step S102 in the present application;

[0012] Figure 3 is an 8-neighbor system diagram;

[0013] Figure 4 is Figure 2 is a flowchart of an embodiment of step S203 in the present application;

[0014] Figure 5 is a flowchart of an embodiment of step S103;

[0015] Figure 6 is a flowchart of another embodiment of the color difference correction system proposed by the present application;

[0016] Figure 7 is a schematic diagram of an original image;

[0017] Figure 8 is a schematic diagram of an embodiment of a refined image;

[0018] Figure 9 is a schematic diagram of a minimum fitting rectangle;

[0019] Figure 10is a schematic diagram of a local image in the original image;

[0020] Figure 11 is a schematic diagram of the gradient change value of the red channel and the blue channel of a first pixel point in a local image before correction;

[0021] Figure 12 is a schematic diagram of the gradient change value of the red channel and the blue channel of a first pixel point in a local image after correction;

[0022] Figure 13 is a schematic diagram of the gradient change value of the red channel and the blue channel of a first pixel point in another local image before correction;

[0023] Figure 14 is a schematic diagram of the gradient change value of the red channel and the blue channel of a first pixel point in another local image after correction;

[0024] Figure 15 is a schematic diagram of the structure of an embodiment of the color difference correction system proposed in the present application;

[0025] Figure 16 is a schematic diagram of the structure of an embodiment of the electronic device proposed in the present application;

[0026] Figure 17 is a schematic diagram of the structure of an embodiment of the storage device proposed in the present application. DETAILED DESCRIPTION

[0027] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.

[0028] Please refer to Figure 1 , Figure 1 is a schematic diagram of the flow of an embodiment of the color difference correction method proposed in the present application, and the method comprises the following steps:

[0029] S101: Obtain an original image. The original image contains at least a first region and a second region adjacent to each other, and the average brightness of the first region is greater than the average brightness of the second region.

[0030] Specifically, the implementation process of step S101 includes: obtaining an original image containing a highlight region. Wherein, the highlight region in the original image is a first region, and a region other than the highlight region is a second region, and the average brightness of the first region is greater than the average brightness of the second region. And the junction of the highlight region and the non-highlight region (i.e. the junction of the first region and the second region) is prone to color difference phenomenon. Optionally, the original image can be obtained by camera shooting.

[0031] S102: Obtain a local image of the original image, and the local image contains a boundary line of the first region and the second region.

[0032] Specifically, please refer to Figure 2 , Figure 2 for Figure 1 the flowchart of an embodiment of step S102 in the method. Specifically, the implementation process of step S102 includes:

[0033] S201: Convert at least part of the original image containing the boundary line into a binary image.

[0034] Specifically, the implementation process of step S201 includes: in response to the original image being an RGB format image, converting the original image into a YUV format luminance image, and obtaining the luminance value of each pixel point in the Y channel in the luminance image. Wherein, YUV is a color coding method, "Y" represents brightness (Luminance or Luma), that is, gray scale value, and "U" and "V" represent chroma (Chrominance or Chroma), which is used to specify the color of the pixel. Wherein, the luminance value of each current pixel point in the Y channel in the original image can be obtained by the following formula:

[0035] Y xy =0.298×R xy +0.162×G xy +0.117×B xy

[0036] Wherein, R xy represents the component value of the current pixel point in the red channel in the original image, G xy represents the component value of the current pixel point in the green channel in the original image, B xy represents the component value of the current pixel point in the blue channel in the original image, and Y xy represents the luminance value of the current pixel point in the luminance image.

[0037] Further, the luminance value greater than a first threshold Y thr1 and less than a second threshold Y thr2all the second screening pixels, and deleting the pixels in the luminance image other than the second screening pixels. Obtaining a plurality of second screening pixels through screening helps to remove the pixels with large luminance values and small luminance values in the luminance image, so as to retain the pixels near the junction of the first region and the second region, thereby helping to obtain the boundary line between the first region and the second region through subsequent steps. Specifically, the pixel P1 satisfying the following formula is taken as a second screening pixel.

[0038] Y thr1 <Y(P1)<Y thr2

[0039] Further, the second screening pixels with luminance values greater than a third threshold value are marked as a first numerical value, and the remaining second screening pixels are marked as a second numerical value, so as to obtain a binary image. The third threshold value can be obtained by relevant researchers through estimation, or can be obtained by multiple experiments. The binary processing of the luminance image is a common image processing method, and the specific process is not described in detail here.

[0040] Optionally, in the embodiment, the first threshold value Y thr1 is greater than or equal to 80% of the maximum luminance value, and / or the second threshold value Y thr2 is less than or equal to 95% of the maximum luminance value; and / or the first numerical value is 1, and the second numerical value is 0.

[0041] S202: Screening a plurality of first screening pixels located on the boundary line from the binary image.

[0042] Specifically, the implementation process of step S202 includes: performing thinning processing on the binary image obtained through step S201, so as to screen a plurality of first screening pixels located on the boundary line from the binary image. Specifically, the above-mentioned binary image can be thinned by using a zhang fast parallel thinning algorithm, so as to extract the boundary line between the first region and the second region from the binary image. In response to the fact that the color difference phenomenon generally occurs at the junction of the first region and the second region, obtaining the boundary line between the first region and the second region helps to determine the region where the color difference phenomenon occurs, and to perform color difference correction on the region alone, so as to improve the efficiency of color difference correction.

[0043] Please refer to Figure 3 , Figure 3 is an 8-neighbor system diagram. Specifically, the above-mentioned thinning process includes: taking P1 as the center and P2-P9 as the adjacent pixels around P1 to construct an 8-neighbor system. If the following formulas are satisfied at the same time, the corresponding pixel P1 is deleted to obtain a first thinned image.

[0044] 2≤N(P1)≤6

[0045] S(P1)=1

[0046] P2 x P4 x P6 = 0

[0047] P4 x P6 x P8 = 0

[0048] Wherein, P1 is any pixel point in the binary image, N(P1) is the number of non-zero points in P2~P9, S(P1) is the number of times that the values of these points change from 0 to 1 in the order of P2, P3, P4, …, P9, P2.

[0049] Further, after obtaining the first refined image through the above process, the pixel points in the first refined image are screened again. Specifically, any pixel point in the first refined image is taken as P1, P2~P9 are the adjacent pixel points around P1, if the following formulas are satisfied at the same time, the corresponding pixel point P1 is deleted to obtain a second refined image.

[0050] 2≤N(P1)≤6

[0051] S(P1) = 1

[0052] P2 x P4 x P8 = 0

[0053] P2 x P6 x P8 = 0

[0054] Further, the second refined image is taken as the final refined image, and the pixel points in the refined image are taken as the first screening pixels, and the plurality of first screening pixels are located at the junction of the first region and the second region. Therefore, the set composed of the plurality of first screening pixels in the second refined image can be regarded as the junction of the first region and the second region.

[0055] S203: determining a local image based on the plurality of first screening pixels.

[0056] Please refer to Figure 4 , Figure 4 for Figure 2 an embodiment of step S203. Specifically, step S203 includes:

[0057] S301: obtaining a minimum fitting rectangle of the plurality of first screening pixels, and taking the center of the minimum fitting rectangle as the center point of the local image.

[0058] Specifically, the implementation process of step S301 includes: obtaining a minimum fitting rectangle. Wherein, the plurality of first screening pixels are located in the minimum rectangle. The center of the minimum fitting rectangle is taken as the center point of the local image, thereby assisting in the expansion of the center point to obtain the local image. The minimum fitting rectangle corresponding to the known point set can be obtained by the existing program, and the specific process is not described in detail here.

[0059] S302: expand the center point by a first distance in the vertical direction and a second distance in the horizontal direction to obtain a local image.

[0060] Specifically, in the embodiment, before step S302, a step of obtaining a third value is included, the third value is a difference between the first threshold Y thr2 and the second threshold Y thr1 .

[0061] Further, each second pixel point in the vertical direction of the center point is obtained one by one. For each remaining color channel, a first ratio of the current second pixel point in the remaining color channel to one of the color channels is obtained. Specifically, the one of the color channels is any one of the red channel, the blue channel and the green channel in the RGB format, and the remaining color channels are the other two color channels, each of which has a corresponding component value. Further, for each remaining color channel, a first ratio change rate of the current second pixel point to another second pixel point adjacent in the vertical direction is obtained. In response to the first ratio change rate of the current second pixel point corresponding to each remaining color channel being zero at the same time, a distance between the current second pixel point and the center point is taken as a fourth value.

[0062] Further, each third pixel point of the center point in the horizontal direction is obtained one by one. For each remaining color channel, a second ratio of the current third pixel point in the remaining color channel to one of the color channels is obtained. Further, for each remaining color channel, a second ratio change rate of the current third pixel point to another third pixel point adjacent in the horizontal direction is obtained. In response to the second ratio change rate of the current third pixel point corresponding to each remaining color channel being zero at the same time, a distance between the current third pixel point and the center point is taken as a fifth value.

[0063] In the embodiment, the remaining color channels are color channels related to color difference, that is, when color difference occurs in the current image, the remaining color channels of the pixel points corresponding to the color difference region are offset, and the component values of the remaining color channels are corrected to realize color difference correction of the image; in addition, the one of the color channels is a color channel with low correlation to color difference. The calculation of the third value, the fourth value and the fifth value helps to determine the range of abnormal component values of the remaining color channels in the original image, thereby helping to determine the region where color difference occurs in the original image.

[0064] Further, the implementation process of step S302 includes: in response to a third value being greater than a fourth value, using the third value as a first distance; otherwise, using the fourth value as the first distance. And, in response to a third value being greater than a fifth value, using the third value as a second distance; otherwise, using the fifth value as the second distance. An image region is obtained by extending the center point vertically by the first distance and horizontally by the second distance, and the portion of the original image corresponding to this image region is taken as a local image. Color difference correction of the local image can complete the correction of the original image, improving the efficiency of the correction. Optionally, in other embodiments, the third value can also be directly used as the first and second distances.

[0065] Optionally, in another embodiment, step S203 may also include: for each first selected pixel, extending the first selected pixel vertically by a first distance and horizontally by a second distance to obtain a local image. The process of obtaining the first and second distances can be referred to step S302.

[0066] In one embodiment, when one of the color channels is the green channel and the remaining color channels include the red and blue channels, the implementation process of step S302 includes: obtaining the third value through the following formula:

[0067] Offset1 = Y thr2 -Y thr1

[0068] Here, offset1 represents the third value.

[0069] Furthermore, the first ratio change rate between the current second pixel and another adjacent second pixel in the vertical direction is calculated using the following formula:

[0070]

[0071]

[0072] Among them, R n (x, y) / G n (x, y) represents the first ratio of the red channel component value to the green channel component value of the nth second pixel, ΔGR hn This represents the rate of change of the first ratio of the second pixel corresponding to the nth red channel in the vertical direction; B n (x, y) / G n (x, y) represents the first ratio of the blue channel component value to the green channel component value of the nth second pixel, ΔGB hnThis represents the first ratio change rate of the nth second pixel corresponding to the blue channel in the vertical direction. Furthermore, n is greater than or equal to 1 and less than or equal to H1, where H1 is the height of the original image; Δy represents the vertical distance between the nth second pixel and its adjacent second pixel in the vertical direction.

[0073] The first ratio change rate ΔGR in response to the nth second pixel corresponding to the red channel hn The rate of change of the first ratio ΔGB of the second pixel corresponding to the nth pixel in the blue channel hn If the value is zero, obtain the distance between the nth second pixel and the center point, and use this distance as the fourth value, offset2.

[0074] Furthermore, the second ratio change rate between the current third pixel and another third pixel adjacent in the horizontal direction is calculated using the following formula:

[0075]

[0076]

[0077] Among them, R m (x, y) / G m (x, y) represents the second ratio of the red channel component value to the green channel component value of the m-th third pixel, ΔGR wm B represents the rate of change of the second ratio at the m-th third pixel corresponding to the red channel in the horizontal direction; m (x, y) / G m (x, y) represents the first ratio of the blue channel component value to the green channel component value of the m-th third pixel, ΔGB wm This represents the second ratio change rate of the m-th third pixel corresponding to the blue channel in the horizontal direction. Additionally, m is greater than or equal to 1 and less than or equal to W2, where W2 is the width of the original image; Δx represents the vertical distance between the m-th third pixel and its horizontally adjacent third pixel.

[0078] The second ratio change rate ΔGR in response to the m-th third pixel corresponding to the red channel wm The second ratio change rate ΔGB of the third pixel corresponding to the m-th channel wm If the value is zero, obtain the distance between the m-th third pixel and the center point, and use this distance as the fifth value, offset3.

[0079] Furthermore, the first distance L1 extending in the vertical direction and the second distance L2 extending in the horizontal direction are obtained through the following formulas:

[0080]

[0081]

[0082] S103: Obtain a first gradient change value of one of the color channels in the local image, and obtain a second gradient change value of the remaining color channels in the local image based on the first gradient change value.

[0083] Specifically, the implementation process of step S103 includes: taking each pixel point in the local image as a first pixel point, and for each first pixel point in the local image, obtaining the component value of the first pixel point in each color channel. Specifically, in response to the local image being an RGB format image, obtaining the component value of each first pixel point in the red channel, the green channel and the blue channel in the local image.

[0084] Further, the first gradient change value of one of the color channels in the local image is obtained. Specifically, based on the current first pixel point and another first pixel point adjacent to the current first pixel point in the vertical direction, the first vertical gradient change value of one of the color channels in the vertical direction of the current first pixel point is obtained; and based on the current first pixel point and another first pixel point adjacent to the current first pixel point in the horizontal direction, the first horizontal gradient change value of one of the color channels in the horizontal direction of the current first pixel point is obtained. That is, the first gradient change value includes the first vertical gradient change value and the first horizontal gradient change value.

[0085] Further, the second gradient change value of the remaining color channels of the current first pixel point in the local image is obtained based on the first vertical gradient change value and the first horizontal gradient change value. Wherein, the first gradient change value can be taken as the second gradient change value of the remaining color channels in the local image; that is, the first vertical gradient change value is taken as the second vertical gradient change value of the remaining color channels in the vertical direction of the current first pixel point, and the first horizontal gradient change value is taken as the second horizontal gradient change value of the remaining color channels in the horizontal direction of the current first pixel point. In this embodiment, the remaining color channels are the color channels related to the color characteristics of the color difference in the image, and one of the color channels is the color channel with lower correlation to the color characteristics of the color difference in the image. By obtaining the second gradient change value of the remaining color channels based on the first gradient change value of one of the color channels, the second gradient change value of the remaining color channels is corrected.

[0086] Alternatively, in other embodiments, the second gradient change value of the remaining color channels can also be obtained by multiplying the first gradient change value of one of the color channels by a corresponding weight value by setting the corresponding weight value.

[0087] Please refer to Figure 5 , Figure 5A flowchart of an embodiment of step S103 is shown in FIG. 4. In the embodiment, the one color channel is the green color channel, and the other two color channels are the red color channel and the blue color channel. Specifically, step S103 includes:

[0088] S401: Obtain each first pixel point in the local image one by one.

[0089] Specifically, the implementation process of step S401 includes: obtaining each first pixel point in the local image one by one, including the component value of the first pixel point in the red color channel, the green color channel, and the blue color channel.

[0090] S402: Obtain the first gradient change value of the green color channel of the first pixel point in the vertical direction and the horizontal direction.

[0091] Specifically, the implementation process of step S402 includes: based on the current first pixel point and another first pixel point adjacent to the current first pixel point in the vertical direction, obtaining the first vertical gradient change value of the green color channel of the current first pixel point in the vertical direction, and based on the current first pixel point and another first pixel point adjacent to the current first pixel point in the horizontal direction, obtaining the first horizontal gradient change value of the green color channel of the current first pixel point in the horizontal direction.

[0092] In the embodiment, the first vertical gradient value can be obtained by the following formula:

[0093]

[0094] wherein, ΔG hi represents the first vertical gradient change value of the green color channel of the i-th first pixel point in the vertical direction, G i (x, y) represents the component value of the green color channel of the i-th first pixel point. G i+1 (x, y+1) represents the component value of the green color channel of another first pixel point adjacent to the i-th first pixel point in the vertical direction, and Δy represents the vertical distance between the i-th first pixel point and another first pixel point adjacent to the i-th first pixel point in the vertical direction. Wherein, i is greater than or equal to 1 and less than or equal to H2, and H2 is the height of the local image.

[0095] In addition, in the embodiment, the first horizontal gradient change value can be obtained by the following formula:

[0096]

[0097] wherein, ΔG wj represents the first horizontal gradient change value of the green color channel of the j-th first pixel point in the horizontal direction, G j(x, y) represents the component value of the green channel of the jth first pixel point. G j+1 (x+1, y) represents the component value of the green channel of another pixel point adjacent to the jth first pixel point in the horizontal direction, and Δx represents the horizontal distance between the jth first pixel point and another first pixel point adjacent to the jth first pixel point in the horizontal direction. Wherein, j is greater than or equal to 1 and less than or equal to W2, W2 is the width of the local image.

[0098] S403: obtaining the second gradient change values of the remaining color channels of the current first pixel point in the vertical direction based on the first gradient change value in the vertical direction, and obtaining the second gradient change values of the remaining color channels of the current first pixel point in the horizontal direction based on the first gradient change value in the horizontal direction.

[0099] Specifically, the implementation process of step S403 includes: obtaining the second gradient change values of the red channel and the blue channel in the local image based on the first gradient change value of the green channel respectively. Specifically, the first gradient change value is taken as the second gradient change value of the remaining color channels in the local image, that is, the first vertical gradient change value of the green channel of the first pixel point is taken as the second vertical gradient change value of the red channel and the blue channel of the first pixel point, and the first horizontal gradient change value of the green channel of the first pixel point is taken as the second horizontal gradient change value of the red channel and the blue channel of the first pixel point. That is, the second gradient change value includes the second vertical gradient change value and the second horizontal gradient change value, and the red channel and the blue channel both have corresponding second gradient change values. Wherein, the second gradient change values of the red channel and the blue channel can be obtained by the following formula:

[0100] ΔR′ hi = ΔG hi

[0101] ΔB′ hi = ΔG hi

[0102] ΔR′ wj = ΔG wj

[0103] ΔB′ wj = ΔG wj

[0104] Wherein, ΔR’ hi represents the second vertical gradient change value of the red channel of the first pixel point in the vertical direction, ΔB’ hi represents the second vertical gradient change value of the blue channel of the first pixel point in the vertical direction, ΔR’ wj represents the second horizontal gradient change value of the red channel of the first pixel point in the horizontal direction, and ΔB’ wja second vertical gradient change value of the red color channel of the first pixel point in the vertical direction.

[0105] S104: correcting the local image based on the gradient change values of the color channels to obtain a corrected image.

[0106] Specifically, the implementation process of step S104 includes: based on the gradient change values of the color channels in the vertical and horizontal directions obtained in the above steps, restoring the component value of the corresponding color channel of the corresponding first pixel point in the corresponding direction in the local image to obtain the corrected component value of the corresponding color channel of the first pixel point. Further, superimpose the component values of all color channels to obtain the corrected corrected image. Wherein, in response to the gradient change value of one of the color channels not changing, therefore, the component value of each pixel point in the local image in one of the color channels adopts the component value of the corresponding color channel of the pixel point in the original image, that is, the component value in one of the color channels remains unchanged.

[0107] In an embodiment, after obtaining the corrected image of the local image, the corrected image is combined with the original image, that is, the corrected image replaces the corresponding part of the original image to obtain the corrected image of the original image.

[0108] Optionally, in an embodiment, after obtaining the corrected image, the corrected image is subjected to mean filtering processing to remove noise in the corrected image, and the image subjected to mean filtering processing is taken as the latest corrected image. Of course, in other embodiments, other image processing means can also be used to remove noise in the image. Wherein, the corrected image of the local image can be subjected to mean filtering processing first, and then the processed corrected image is combined with the original image, or the corrected image of the local image can be combined with the original image first and then subjected to mean filtering processing.

[0109] In an embodiment, when one of the color channels is the green color channel and the remaining color channels are the red color channel and the blue color channel, after obtaining the second gradient change value of the red color channel and the second gradient change value of the blue color channel in the local image based on the first gradient change value of the green color channel, the implementation process of step S104 includes:

[0110] the first vertical component of the red color channel of the first pixel point in the vertical direction is obtained by reverse deduction using the second vertical gradient change value of the red color channel of the first pixel point in the vertical direction, and the first horizontal component of the red color channel of the first pixel point in the horizontal direction is obtained by reverse deduction using the second horizontal gradient change value of the red color channel of the first pixel point in the horizontal direction. Further, the square root of the sum of the first vertical component and the first horizontal component is taken as the component value of the corrected red color channel of the first pixel point. Wherein, the calculation formula of the component value of the corrected red color channel is as follows:

[0111] R hi (x,y) = R i (x,y+1) - Ay x AR' hi

[0112] R wi (x,y) = R i (x+1,y) - Ax x AR' wi

[0113]

[0114] wherein, R hi (x,y) represents the second vertical component of the blue channel of the i-th first pixel point in the vertical direction, B wj (x,y) represents the second horizontal component of the blue channel of the i-th first pixel point in the horizontal direction, B'(x,y) represents the component value of the blue channel of the i-th first pixel point after correction.

[0115] Further, the second vertical component of the blue channel of the first pixel point in the vertical direction is obtained by backstepping the second vertical gradient change value of the blue channel of the first pixel point in the vertical direction, and the second horizontal component of the blue channel of the first pixel point in the horizontal direction is obtained by backstepping the second horizontal gradient change value of the blue channel of the first pixel point in the horizontal direction. Further, the square root of the sum of squares of the second vertical component and the second horizontal component is taken as the component value of the blue channel of the first pixel point after correction. The calculation formula of the component value of the blue channel after correction is as follows:

[0116] B hi (x,y) = B i (x,y+1) - Ay x AB' hi

[0117] B wi (x,y) = B j (x+1,y) - Ax x AB' wj

[0118]

[0119] wherein, B i (x,y) represents the second vertical component of the blue channel of the i-th first pixel point in the vertical direction, B j (x,y) represents the second horizontal component of the blue channel of the i-th first pixel point in the horizontal direction, B'(x,y) represents the component value of the blue channel of the i-th first pixel point after correction.

[0120] Further, in the embodiment, for all the first pixels in the local image, the component value of the red channel and the component value of the blue channel of the first pixel and the component value of the first pixel in the green channel are superimposed to obtain a corrected image, and the corrected image is subjected to noise reduction processing to remove part of the noise in the image. It should be noted that the first gradient change value of the green channel has not changed, and therefore the component value of the green channel remains unchanged.

[0121] The color difference correction method provided in the present application extracts a local image containing the boundary between the highlight region and the non-highlight region from the original image, and obtains the first gradient change value of one of the color channels in the local image according to the color characteristics of the color difference region, and corrects the gradient change values of the remaining color channels related to the color characteristics of the color difference region based on the first gradient change value, thereby correcting the local image based on the gradient change values of the color channels to obtain a corrected image. This method can avoid correcting the entire original image, thereby improving the efficiency of color difference correction, and using the gradient change values of the color channels to correct the local image can effectively preserve the transition information between the highlight region and the adjacent region, avoiding distortion of the corrected image.

[0122] Referring to Figure 6 , Figure 6 is a flowchart of another embodiment of the color difference correction system provided in the present application. In this embodiment, the original image contains a red channel, a blue channel and a green channel. Moreover, there is a color difference at the boundary between the first region and the second region in the original image, and the color difference exists in the form of a purple edge, i.e., the boundary between the first region and the second region contains purple. The purple edge phenomenon is formed due to the fact that the green channel is accurately focused during imaging, while the red channel and the blue channel are offset, and therefore when correcting the purple edge, the red channel component and the blue channel component of the pixels at the boundary between the first region and the second region in the image need to be corrected. The specific correction process includes:

[0123] S501: Obtain an original image.

[0124] Specifically, referring to Figure 7 , Figure 7 is a schematic diagram of the original image. As Figure 7 shown, the middle region of the original image is the first region, and the remaining regions are the second region, and the first region is the highlight region.

[0125] S502: Convert at least part of the original image containing the boundary between the first region and the second region into a binary image, and screen a plurality of first screening pixels located on the boundary from the binary image.

[0126] Specifically, the implementation process of step S502 includes: converting the original image in step S501 into a luminance image, and obtaining a maximum luminance value in the first region. Further, the first threshold value and the second threshold value are determined based on the maximum luminance value. Wherein, 80% of the maximum luminance value can be taken as the first threshold value, and 95% of the maximum luminance value can be taken as the second threshold value; or the first threshold value and the second threshold value can also be estimated according to actual conditions. For example, in the present embodiment, the first threshold value is set to 200 and the second threshold value is set to 250 according to the experience of the relevant research and development personnel.

[0127] Further, the pixel points in the luminance image with luminance values greater than the first threshold value and less than the second threshold value are taken as second screening pixels, and the pixel points other than the second screening pixels in the luminance image are deleted. The binarization processing is performed on all the second screening pixels to obtain a binarization image. Further, the binarization image is subjected to thinning processing to screen a plurality of first screening pixels located on the boundary line between the first region and the second region from the binarization image, so as to obtain a thinning image. Specifically, please refer to Figure 8 , Figure 8 for a schematic diagram of an embodiment of the thinning image. As shown in Figure 8 , the plurality of first screening pixels are obtained by thinning processing, and the plurality of first screening pixels are located at the junction of the first region and the second region, that is, the plurality of first screening pixels can be regarded as the boundary between the first region and the second region. In the present embodiment, the process of binarization processing and thinning processing can refer to the above-mentioned embodiments, which will not be described in detail here.

[0128] S503: obtaining a center point of a local image containing the boundary line between the first region and the second region.

[0129] Please refer to Figure 9 , Figure 9 for a schematic diagram of a minimum fitting rectangle. Specifically, the implementation process of step S503 includes: as shown in Figure 9 , for the boundary line between the first region and the second region, a minimum fitting rectangle 100 of the plurality of first screening pixels is obtained, and the center of the minimum fitting rectangle 100 is taken as the center point of the local image. The specific process can refer to the above-mentioned embodiments. It should be noted that Figure 9 only one minimum fitting rectangle 100 corresponding to one boundary line is schematically shown in the figure, and when the thinning image contains a plurality of boundary lines, the number of minimum fitting rectangles 100 can be multiple.

[0130] S504: expanding the center point by a first distance in the vertical direction and by a second distance in the horizontal direction to obtain a local image.

[0131] Specifically, the implementation process of step S504 includes: taking the difference between the second threshold value and the first threshold value as a third value.

[0132] Obtain each second pixel point in the vertical direction where the center point is located, and obtain the first ratio of the red channel component value to the green channel component value and the first ratio of the blue channel component value to the green channel component value of the current second pixel point for the red channel and the blue channel. Obtain the first ratio change rate of the current second pixel point and another second pixel point adjacent in the vertical direction. The first ratio change rate includes the first ratio change rate corresponding to the red channel and the first ratio change rate corresponding to the blue channel. In response to the first ratio change rates of the current second pixel point corresponding to the red channel and the blue channel being zero at the same time, the distance between the current second pixel point and the center point is taken as the fourth value.

[0133] Obtain each third pixel point in the horizontal direction where the center point is located, and obtain the second ratio of the red channel to the green channel and the second ratio of the blue channel to the green channel of the current third pixel point for the red channel and the blue channel. Obtain the second ratio change rate of the current third pixel point and another third pixel point adjacent in the horizontal direction. The second ratio change rate includes the second ratio change rate corresponding to the red channel and the second ratio change rate corresponding to the blue channel. In response to the second ratio change rates of the current third pixel point corresponding to the red channel and the blue channel being zero at the same time, the distance between the current third pixel point and the center point is taken as the fifth value.

[0134] Further, in response to the third value being greater than the fourth value, the third value is taken as the first distance; otherwise, the fourth value is taken as the first distance. In response to the third value being greater than the fifth value, the third value is taken as the second distance; otherwise, the fifth value is taken as the second distance. The center point is expanded by the first distance in the vertical direction and by the second distance in the horizontal direction to obtain an image region, and part of the original image corresponding to the image region is taken as a local image. Specifically, please refer to Figure 10 , Figure 10 A schematic view of the local image in the original image. In Figure 10 The original image contains two local images 200. The local image is obtained by the boundary line between the first region and the second region to determine the specific region where the purple edge phenomenon occurs, thereby helping to improve the efficiency of color difference correction.

[0135] S505: Obtain the first gradient change value of the green channel in the local image, and obtain the second gradient change value of the red channel and the second gradient change value of the blue channel in the local image based on the first gradient change value.

[0136] Specifically, the step S505 is to take the first gradient change value of the green channel in the local image as the second gradient change value of the red channel and the blue channel. Specifically, each first pixel point in the local image is obtained one by one, and based on the current first pixel point and another pixel point adjacent to the current first pixel point in the vertical direction, the first vertical gradient change value of the green channel of the current first pixel point in the vertical direction is obtained. And, based on the current first pixel point and another pixel point adjacent to the current first pixel point in the horizontal direction, the first horizontal gradient change value of the green channel of the current first pixel point in the horizontal direction is obtained.

[0137] Further, the first vertical gradient change value is taken as the second vertical gradient change value of the red channel and the blue channel of the current first pixel point in the vertical direction, and the first horizontal gradient change value is taken as the second horizontal gradient change value of the red channel and the blue channel of the current first pixel point in the horizontal direction. Wherein, the specific process can refer to step S103 in Figure 1 , which will not be elaborated here. Specifically, please refer to Figure 11 , Figure 11 A schematic diagram of correcting the gradient change value of the red channel and the blue channel of a first pixel point in a local image. Figure 11 The corresponding local image is Figure 10 the local image 200 on the left side in FIG. 2. Further, please refer to Figure 12 , Figure 12 A schematic diagram of correcting the gradient change value of the red channel and the blue channel of a first pixel point in a local image. For the local image 200 on the right side in FIG. 2, please refer to Figure 10 , Figure 13 , Figure 13 A schematic diagram of correcting the gradient change value of the red channel and the blue channel of a first pixel point in another local image. Further, please refer to Figure 14 , Figure 14 A schematic diagram of correcting the gradient change value of the red channel and the blue channel of a first pixel point in another local image. In combination with Figures 11 to 14 It can be obviously observed that by the above steps, the abnormal gradient change value of the pixel point can be corrected, so that the gradient change value of the first pixel point in the red channel and the blue channel in the local image is more smooth, to help subsequent correction of the purple edge based on the corrected gradient change value.

[0138] S506: correcting the local image based on the gradient change value of the red channel and the blue channel to obtain a corrected image.

[0139] Specifically, the implementation process of step S506 includes: using the second vertical gradient change value of the red channel in the vertical direction of the first pixel point and the second horizontal gradient change value of the red channel in the horizontal direction of the first pixel point to restore the component value of the red channel of the first pixel point, so as to obtain the corrected component value of the red channel of the first pixel point; and using the second vertical gradient change value of the blue channel in the vertical direction of the first pixel point and the second horizontal gradient change value of the blue channel in the horizontal direction of the first pixel point to restore the component value of the blue channel of the first pixel point, so as to obtain the corrected component value of the blue channel of the first pixel point. The specific process can refer to the above embodiments.

[0140] Further, the corrected component value of the red channel, the corrected component value of the blue channel and the component value of the green channel are superimposed to obtain a corrected image. Wherein, in response to the purple edge phenomenon being caused by the deviation of the red channel and the blue channel relative to the green channel in the imaging process, the component value of the green channel of the first pixel point adopts the component value of the green channel of the corresponding pixel point in the original image when the corrected image is obtained. It should be noted that the corrected image is a corrected image of a partial image, and after the corrected image is obtained, the corrected image replaces the corresponding part in the original image to complete the correction of the original image.

[0141] In addition, in the embodiment, after the corrected image is obtained, the corrected image is subjected to mean filtering processing to remove the noise in the corrected image.

[0142] Please refer to Figure 15 , Figure 15 The figure is a structural schematic diagram of an embodiment of the color difference correction system proposed in the present application. Specifically, the color difference correction system includes an acquisition module 10, a first processing module 20, a second processing module 30 and a correction module 40.

[0143] Specifically, the acquisition module 10 is configured to acquire an original image. Wherein, the original image at least contains adjacent first and second regions, and the average brightness of the first region is greater than that of the second region.

[0144] The first processing module 20 is coupled with the acquisition module 10, and is configured to obtain a partial image containing the boundary line of the first and second regions based on the original image.

[0145] The second processing module 30 is coupled with the first processing module 20, and is configured to obtain the first gradient change value of one color channel in the partial image, and obtain the second gradient change value of the remaining color channels in the partial image based on the first gradient change value.

[0146] The correction module 40 is coupled to the second processing module 30, and is configured to correct the local image based on the gradient change value of each color channel to obtain a corrected image.

[0147] Referring to Figure 16 , Figure 16 A structural schematic diagram of an embodiment of an electronic device according to the present application is shown in FIG. 8. The electronic device includes a memory 50 and a processor 60 coupled to each other. The memory 50 stores program instructions. The processor 60 is configured to execute the program instructions to implement the color difference correction method according to any of the embodiments described above. Specifically, the electronic device includes, but is not limited to, a desktop computer, a notebook computer, a tablet computer, a server, etc., without limitation. In addition, the processor 60 can also be referred to as a CPU (Central Processing Unit). The processor 60 can be an integrated circuit chip having a signal processing capability. The processor 60 can also be a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. In addition, the processor 60 can be implemented by an integrated circuit chip together.

[0148] Referring to Figure 17 , Figure 17 A structural schematic diagram of an embodiment of a storage device according to the present application is shown in FIG. 8. The storage device 70 stores program instructions 80 executable by a processor. The program instructions 80 are configured to implement the steps of any of the color difference correction methods described above.

[0149] The above description is merely an embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation based on the content of the specification and drawings, or direct or indirect application in other related technical fields, is also included in the patent protection scope of the present application.

Claims

1. A color difference correction method characterized by, The method comprises: obtaining an original image, wherein the original image comprises at least a first region and a second region adjacent to each other, and the average brightness of the first region is greater than that of the second region; obtaining a local image of the original image, wherein the local image comprises a boundary between the first region and the second region; obtaining a first gradient change value of one color channel in the local image, and obtaining a second gradient change value of the remaining color channels in the local image based on the first gradient change value; specifically, each first pixel point in the local image is obtained one by one; based on the current first pixel point and another first pixel point adjacent to the current first pixel point in the vertical direction, a first gradient change value of the green channel of the current first pixel point in the vertical direction is obtained; and based on the current first pixel point and another first pixel point adjacent to the current first pixel point in the horizontal direction, a first gradient change value of the green channel of the current first pixel point in the horizontal direction is obtained; based on the first gradient change value in the vertical direction, a second gradient change value of the remaining color channels of the current first pixel point in the vertical direction is obtained, and based on the first gradient change value in the horizontal direction, a second gradient change value of the remaining color channels of the current first pixel point in the horizontal direction is obtained; correcting the local image based on the gradient change values of the color channels to obtain a corrected image; wherein the step of obtaining a local image comprising a boundary between the first region and the second region based on the original image comprises: converting at least part of the original image comprising the boundary into a binary image; screening a plurality of first screening pixels located on the boundary from the binary image; and determining the local image based on the plurality of first screening pixels; wherein the step of determining the local image based on the plurality of first screening pixels comprises: obtaining a minimum fitting rectangle of the plurality of first screening pixels, taking the center of the minimum fitting rectangle as a center point of the local image; and extending the center point by a first distance in the vertical direction and by a second distance in the horizontal direction to obtain the local image.

2. The color difference correction method according to claim 1, characterized by, The step of obtaining a second gradient change value of the remaining color channels in the local image based on the first gradient change value comprises: taking the first gradient change value as the second gradient change value of the remaining color channels in the local image.

3. The color difference correction method according to claim 1 or 2, wherein the local image comprises a red channel, a blue channel and a green channel, a purple edge exists at the boundary between the first region and the second region, and the step of obtaining a first gradient change value of one color channel in the local image and obtaining a second gradient change value of the remaining color channels in the local image based on the first gradient change value comprises: obtaining a first gradient change value of the green channel in the local image; ​ A second gradient change value of a red color channel and a second gradient change value of a blue color channel in the local image are obtained based on the first gradient change value of the green color channel respectively.

4. The color difference correction method according to claim 1, characterized by, The step of converting the original image containing at least part of the boundary line into a binary image comprises: transforming the original image into a luminance image and obtaining a maximum luminance value in the first region; determining a first threshold value and a second threshold value based on the maximum luminance value, wherein the first threshold value is less than the second threshold value; screening all second screening pixels with a luminance value greater than the first threshold value and less than the second threshold value from the luminance image; marking the second screening pixels with a luminance greater than a third threshold value as a first numerical value and marking the remaining second screening pixels as a second numerical value to obtain the binary image.

5. The color difference correction method of claim 4, wherein the first threshold value is greater than or equal to 80% of the maximum luminance value; and / or the second threshold value is less than or equal to 95% of the maximum luminance value; and / or the first numerical value is 1 and the second numerical value is 0. Before the step of expanding the center point by a first distance in a vertical direction and by a second distance in a horizontal direction to obtain the local image, comprising:

6. The color difference correction method according to claim 1, characterized by, taking a difference value between the second threshold value and the first threshold value as a third numerical value; obtaining each second pixel point in the vertical direction where the center point is located one by one; obtaining a first ratio of a current second pixel point for each remaining color channel between the remaining color channels and one of the color channels; obtaining a first ratio change rate of the current second pixel point and another second pixel point adjacent to the current second pixel point in the vertical direction; in response to the first ratio change rate of the current second pixel point corresponding to each remaining color channel being zero at the same time, taking a distance between the current second pixel point and the center point as a fourth numerical value; obtaining each third pixel point in the horizontal direction where the center point is located one by one; obtaining a second ratio of a current third pixel point for each remaining color channel between the remaining color channels and one of the color channels; obtaining a second ratio change rate of the current third pixel point and another third pixel point adjacent to the current third pixel point in the horizontal direction; in response to the second ratio change rate of the current third pixel point corresponding to each remaining color channel being zero at the same time, taking a distance between the current third pixel point and the center point as a fifth numerical value. The step of expanding the center point by a first distance in a vertical direction and by a second distance in a horizontal direction to obtain the local image comprises:

7. The color difference correction method according to claim 6, characterized by, in response to the third numerical value being greater than the fourth numerical value, taking the third numerical value as the first distance; otherwise, taking the fourth numerical value as the first distance; in response to the third numerical value being greater than the fifth numerical value, taking the third numerical value as the second distance; otherwise, taking the fifth numerical value as the second distance. A processor and a memory coupled to each other, the processor having program instructions stored therein, and the processor being configured to execute the program instructions to implement the color difference correction method of any one of claims 1-7.

8. An electronic device, comprising: ​ 9. A memory device, comprising: The program instructions stored in the memory can be executed by the processor to implement the color difference correction method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Improved Zhang parallel image refinement algorithm

    CN110097495A