Method for removing purple edge of image

By detecting the edges, bright and dark junction areas and purple edge color characteristics of the image, and determining and correcting the purple edge parts, the problem of difficulty in accurately detecting the purple edge algorithm in the prior art is solved, and the visual experience of the image and scene adaptability are improved.

CN119941766APending Publication Date: 2025-05-06HEFEI JUNZHENG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311454279.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-03
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

In the prior art, it is difficult for the deviated purple edge algorithm to accurately detect purple edges in images of different scenes, resulting in missed detection and misdetection, affecting the visual experience of the image.

Method used

By gradually detecting the image edge, bright and dark junction area and purple edge color characteristics, the purple edge area is determined and corrected to reduce the possibility of missed detection and missed detection.

Benefits of technology

Accurate detection and correction of purple edges is achieved, the visual experience of the image is improved, and the scene adaptability and robustness are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119941766A_ABST
    Figure CN119941766A_ABST
Patent Text Reader

Abstract

The invention provides a method for removing purple edges of an image, which comprises the following steps of: S0, inputting the image: if the input image is an HDR image, carrying out the step S1; if the input is an LDR image, performing a step S5; s2, an edge detection module, S3, a bright and dark area detection module, and S4, intersection of the S2 and the S3, and only retaining a component B as a mask of the HDR; s5, obtaining an LDR image; s6, obtaining a mask of the LDR through a color characteristic detection module; s7, calculating an LDR four-neighborhood mean value according to the intersection of the step S4 and the step S6, and replacing an original pixel value; and S8, obtaining a Depurble result. According to the method, the image edge, the bright and dark junction area and the color, namely the purple edge color characteristic are detected to gradually determine the purple edge part, and then the purple edge is corrected, so that the possibility of missing detection and false detection is reduced, and the method has higher scene adaptability and robustness.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of intelligent monitoring video processing, and in particular relates to a method for removing purple fringes from an image. Background Art

[0002] In the prior art, the lens refracts light of different spectra to different degrees, resulting in the inability to image light of different spectra onto one point. The imaging system generally focuses on the green channel accurately, while the blue and red channels cannot be completely focused accurately, resulting in purple-red color fringing at the edges of objects, affecting the visual experience of the image.

[0003] Usually, you can choose a more advanced optically optimized lens / sensor to eliminate purple fringing. If conditions permit, you can also use post-processing software such as PS and Lightroom to eliminate purple fringing. In the ISP process, the CAC module depurple algorithm is often used to achieve the function of removing purple fringing. The depurple algorithm generally includes two parts: purple fringing detection and purple fringing correction.

[0004] However, the purple fringing removal algorithm is generally divided into two parts: purple fringing detection and purple fringing correction. The difficulty lies in purple fringing detection. Purple fringing generally appears at the edge where light and dark meet. Images of different scenes may have different parameter requirements for the purple fringing removal algorithm, and missed detection and false detection are inevitable.

[0005] In addition, the commonly used terms in the prior art include:

[0006] HDR: high dynamic range, dynamic range refers to the brightness ratio between the brightest object and the darkest object in the scene. The larger the dynamic range, the richer the levels that can be expressed. The dynamic range in real scenes reaches 10 9 :1, the dynamic range that the human visual system can perceive is about 10 5 :1, while the dynamic range of a general image sensor is about 10 2 :1.

[0007] LDR: low dynamic range. Purple fringing: The cause of purple fringing is relatively complex. It is generally believed to be caused by lens chromatic aberration (the lens refracts light of different spectra to different degrees, resulting in the inability of light of different spectra to be imaged at one point). The imaging system generally focuses on the green channel accurately. Due to lens chromatic aberration, the blue and red channels cannot be completely focused accurately, resulting in purple-red color fringing on the edge of the object. Summary of the invention

[0008] In order to solve the above problems, the purpose of the present application is: a good purple fringing removal algorithm must first simultaneously realize the accurate detection of the edge and color (color characteristics of purple fringing) of the bright and dark boundary areas. The present invention detects the image edge, the bright and dark boundary area, and the color (color characteristics of purple fringing) respectively to gradually determine the purple fringing location, and then corrects the purple fringing, thereby reducing the possibility of missed detection and false detection, and has stronger scene adaptability and robustness.

[0009] Specifically, the present invention provides a method for removing purple fringing from an image, the method comprising the following steps:

[0010] S0, input image: if the input is an HDR image, proceed to step S1; if the input is an LDR image, proceed to step S5;

[0011] S1, input a high dynamic range image I HDR , and normalize the HDR image, and then convert it into 8-bit data, as shown in formula (1), where I HDRN For the processed image:

[0012]

[0013] Then, step S2 and step S3 are performed respectively;

[0014] S2, edge detection module:

[0015] S2.1, Canny edge detection, using the canny operator to I HDRN Edge detection is performed, and the minimum and maximum thresholds are set to 5 and 50 respectively. The obtained edge image is recorded as I canny ;

[0016] S2.2, morphological processing, edge expansion processing, and then continue to step S4;

[0017] S3, bright and dark area detection module:

[0018] S3.1, linear multiplication value, for the HDR image I processed in step S1 HDRN Perform linear multiplication with the coefficient set to 30, as shown in formula (2):

[0019] I HDRNM =I HDRN *30 Formula (2);

[0020] S3.2, Binarization, I HDRNM Perform binarization processing, set I HDRNM_i For any point on the image, if the point is overexposed, that is, I HDRNM_i The corresponding pixel value is 255, then the pixel value of this point remains unchanged. If the point is not overexposed, that is, IHDRNM_i If the corresponding pixel value is less than 255, the pixel value of the point is changed to 0, and the image after binarization is recorded as I HDRNMB , the processing method is shown in formula (3):

[0021]

[0022] S3.3, edge expansion operation and morphological processing; continue to execute step S4;

[0023] S4, intersect the result images of steps S2.2 and S3.3, retain only the B component, and record it as the HDR mask as I HDR_mask , I HDR_mask It is a Bayer format arranged according to R, G, G, B, where B represents one of the components:

[0024] S4.1, as in formula (4), the result of step S2.3 I cannyde The result of step S3.3 I HDRNMBEF Multiplication is the intersection method, and then all pixel values ​​​​that are not zero are set to 255, and the result is recorded as I HDR_mask :

[0025] I HDR_mask =I canyde *I HDRNMBEF Formula (4)

[0026] S4.2, for I HDR_mask Further processing is performed by setting the R and G values ​​of the four components RGGB to 0, as shown in formula (4), and the resulting image is recorded as I HDR_maskB :

[0027]

[0028] Among them I HDR_maskR Represents the R component pixel in the image, I HDR_maskG represents the pixel point of the G component in the image; proceed to step S7;

[0029] S5, input LDR image: input high dynamic range image I HDR The corresponding RGB format 8-bit width LDR image I LDR ;

[0030] S6, after the color feature detection module, obtain the LDR mask:

[0031] Traverse the image and obtain the pixel points that satisfy both the B channel pixel value greater than the G channel pixel value by more than 25 and the difference between the R channel and the G channel pixel value in the image is less than 25, and set the pixel value of the pixel point that meets the conditions to 255, denoted as I LDR_maskAs shown in formula (6):

[0032]

[0033] Continue to step S7;

[0034] S7, the results of step S4.2 and step S6 are intersected, the mean of the four neighborhoods of LDR is calculated, and the original pixel value is replaced, as shown in formula (7), and the result of step S4.2 is I HDR_mask The result of step S6 LDR_mask Multiply them, and then set all pixel values ​​that are not zero to 255. The result is recorded as I mask : This is the way to do the intersection, which can also be understood as direct multiplication;

[0035] I mask =I HDR_mask *I LDR_mask Formula (7);

[0036] S8, Depurple result, corresponding to I mask The coordinates of all pixels with a value of 255 in I LDR Processing is performed to average the pixel values ​​of the four neighborhoods around the target pixel point, and the average result is assigned to I LDR The corresponding pixel point, the result is recorded as I Depurple .

[0037] The step S2.2 further comprises:

[0038] S2.2.1, for I canny Perform morphological processing, use the dilation algorithm, set the dilation kernel element parameter to 15x15, and record the result as I cannyd ;

[0039] S2.2.2, for I cannyd Perform edge expansion operation, set I cannyd_i For image I cannyd For any point with a pixel value of 255, the pixel values ​​of all points in the 9x9 square with this point as the center are set to 255. The processed image is recorded as I cannyde .

[0040] The step S3.3 further comprises:

[0041] S3.3.1, for I HDRNMB Perform edge expansion operation, set I HDRNMB_i For image I HDRNMB For any point with a pixel value of 255, the pixel values ​​of all points in the 9x9 square with this point as the center are set to 255. The processed image is recorded as I HDRNMBE ;

[0042] S3.3.2, for I HDRNMBE Perform morphological opening operation, first use the erosion algorithm, set the erosion kernel element parameter to 1x1, then use the expansion algorithm, set the expansion kernel element parameter to 15x15, and the result is recorded as I HDRNMBEF .

[0043] The intersection in step S4 is to make the intersection of the results of step S2.2.2 and step S3.3.2, that is, to retain the parts of the same positions of the two images where the values ​​are not 0.

[0044] Therefore, the advantages of the present application are: the present application designs a method for removing purple fringing from images. A good algorithm for removing purple fringing must first simultaneously realize accurate detection of the edges and colors (color characteristics of purple fringing) of the light-dark boundary area. The present invention detects the image edges, light-dark boundary areas, and colors (color characteristics of purple fringing) respectively to gradually determine the purple fringing areas, and then corrects the purple fringing, thereby reducing the possibility of missed detection and false detection, and having stronger scene adaptability and robustness. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.

[0046] Figure 1 It is a schematic diagram of the process of the present application method.

[0047] Figure 2 This is a schematic diagram of the Python code implementation of the result in step S8 of the method of this application. DETAILED DESCRIPTION

[0048] In order to more clearly understand the technical content and advantages of the present invention, the present invention is now further described in detail in conjunction with the accompanying drawings.

[0049] like Figure 1 As shown, the present application proposes a method for removing purple fringing from an image, the method comprising the following steps:

[0050] Step S0, input image: if the input is an HDR image, proceed to step S1; if the input is an LDR image, proceed to step S5;

[0051] Step S1, HDR image: Input a high dynamic range image I HDR , and normalize the HDR image, and then convert it into 8-bit data, as shown in formula (1), where I HDRN For the processed image:

[0052]

[0053] Then, step S2 and step S3 are performed respectively;

[0054] Step S2, edge detection module:

[0055] S2.1, Canny edge detection, using the canny operator to I HDRN Edge detection is performed, and the minimum and maximum thresholds are set to 5 and 50 respectively. The obtained edge image is recorded as I canny ;

[0056] S2.2, morphological processing, edge expansion processing:

[0057] S2.2.1, for I canny Perform morphological processing, use the dilation algorithm, set the dilation kernel element parameter to 15x15, and record the result as I cannyd ;

[0058] S2.2.2, for I cannyd Perform edge expansion operation, set I cannyd_i For image I cannyd For any point with a pixel value of 255, the pixel values ​​of all points in the 9x9 square with this point as the center are set to 255. The processed image is recorded as I cannyde ; Continue to step S4;

[0059] Step S3, bright and dark area detection module:

[0060] S3.1, linear multiplication value, for the HDR image I processed in step S1 HDRN Perform linear multiplication with the coefficient set to 30, as shown in formula (2):

[0061] I HDRNM =I HDRN *30 Formula (2)

[0062] S3.2, Binarization, I HDRNM Perform binarization processing, set I HDRNM_i For any point on the image, if the point is overexposed, that is, I HDRNM_i The corresponding pixel value is 255, then the pixel value of this point remains unchanged. If the point is not overexposed, that is, I HDRNMB_i If the corresponding pixel value is less than 255, the pixel value of the point is changed to 0, and the image after binarization is recorded as I HDRNMB , the processing method is shown in formula (3):

[0063]

[0064] S3.3, edge expansion operation, morphological processing:

[0065] S3.3.1, for IHDRNMB Perform edge expansion operation, set I HDRNM_i For image I HDRNMB For any point with a pixel value of 255, the pixel values ​​of all points in the 9x9 square with this point as the center are set to 255. The processed image is recorded as I HDRNMBE ;

[0066] S3.3.2, for I HDRNMBE Perform morphological opening operation, first use the erosion algorithm, set the erosion kernel element parameter to 1x1, then use the expansion algorithm, set the expansion kernel element parameter to 15x15, and the result is recorded as I HDRNMBF ;

[0067] Step S4, intersection, only retaining the B component as the HDR mask; denoted as I HDR_mask , I HDR_mask It is a Bayer format arranged according to R, G, G, B, where B represents one of the components:

[0068] S4.1, as in formula (4), the result of step S2.2.2 I cannyde The result of step S3.3.2 I HDRNMBEF Multiply them, and then set all pixel values ​​that are not zero to 255. The result is recorded as I HDR_mask :

[0069] I HDR_mask =I canyde *I HDRNMBEF Formula (4)

[0070] S4.2, for I HDR_mask Further processing is performed by setting the R and G values ​​of the four components RGGB to 0, as shown in formula (4), and the resulting image is recorded as I HDR_maskB :

[0071]

[0072] Among them I HDR_maskR Represents the R component pixel in the image, I HDR_maskG represents the pixel point of the G component in the image; proceed to step S7;

[0073] Step S5, LDR image: input high dynamic range image I HDR The corresponding RGB format 8-bit width LDR image I LDR ;

[0074] Step S6, obtaining the LDR mask through the color characteristic detection module;

[0075] Traverse the image and obtain the pixel points that satisfy both the B channel pixel value greater than the G channel pixel value by more than 25 and the difference between the R channel and the G channel pixel value in the image is less than 25, and set the pixel value of the pixel point that meets the conditions to 255, denoted as I LDR_mask As shown in formula (6):

[0076]

[0077] Continue to step S7;

[0078] Step S7, the results of step S4.2 and step S6 are intersected, the mean of the four neighborhoods of LDR is calculated, and the original pixel value is replaced, as shown in formula (7). The result of step S4.2 is I HDR_mask The result of step S6 LDR_mask Multiply them, and then set all pixel values ​​that are not zero to 255. The result is recorded as I mask :

[0079] I mask =I HDR_mask *I LDR_mask Formula (7)

[0080] Step S8, Depurple result, corresponding to I mask The coordinates of all pixels with a value of 255 in I LDR Processing is performed to average the pixel values ​​of the four neighborhoods around the target pixel point, and the average result is assigned to I LDR The corresponding pixel point, the result is recorded as I Depurple The Depurple result in step S8 is implemented by python3 code: Figure 2 shown.

[0081] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for removing purple fringing from an image, characterized in that: The method comprises the following steps: S0, input image: if the input is an HDR image, proceed to step S1; if the input is an LDR image, proceed to step S5; S1, input a high dynamic range image I HDR , and normalize the HDR image, and then convert it into 8-bit data, as shown in formula (1), where I HDRN For the processed image: Then, step S2 and step S3 are performed respectively; S2, edge detection module: S2.1, Canny edge detection, using the canny operator to I HDRN Edge detection is performed, and the minimum and maximum thresholds are set to 5 and 50 respectively. The obtained edge image is recorded as I canny ; S2.2, morphological processing, edge expansion processing, and then continue to step S4; S3, bright and dark area detection module: S3.1, linear multiplication value, for the HDR image I processed in step S1 HDRN Perform linear multiplication with the coefficient set to 30, as shown in formula (2): I HDRNM =I HDRN *30 Formula (2); S3.2, Binarization, I HDRNM Perform binarization processing, set I HDRNM_i For any point on the image, if the point is overexposed, that is, I HDRNM_i The corresponding pixel value is 255, then the pixel value of this point remains unchanged. If the point is not overexposed, that is, I HDRNM_i If the corresponding pixel value is less than 255, the pixel value of the point is changed to 0, and the image after binarization is recorded as I HDRNMB , the processing method is shown in formula (3): S3.3, edge expansion operation and morphological processing; continue to execute step S4; S4, intersect the result images of steps S2.2 and S3.3, retain only the B component, and record it as the HDR mask as I HDR_mask , I HDR_mask It is a Bayer format arranged according to R, G, G, B, where B represents one of the components: S4.1, as in formula (4), the result of step S2.3 I cannyde The result of step S3.3 I HDRNMBEF Multiplication is the intersection method, and then all pixel values ​​​​that are not zero are set to 255, and the result is recorded as I HDR_mask : I HDR_mask =I canyde *I HDRNMBEF Formula (4) S4.2, for I HDR_mask Further processing is performed by setting the R and G values ​​of the four components RGGB to 0, as shown in formula (4), and the resulting image is recorded as I HDR_maskB : Among them I HDR_maxkR Represents the R component pixel in the image, I HDR_maxkG represents the pixel point of the G component in the image; proceed to step S7; S5, input LDR image: input high dynamic range image I HDR The corresponding RGB format 8-bit width LDR image I LDR ; S6, after the color feature detection module, obtain the LDR mask: Traverse the image and obtain the pixel points that satisfy both the B channel pixel value greater than the G channel pixel value by more than 25 and the difference between the R channel and the G channel pixel value in the image is less than 25, and set the pixel value of the pixel point that meets the conditions to 255, denoted as I LDR_mask As shown in formula (6): Continue to step S7; S7, the results of step S4.2 and step S6 are intersected, the mean of the four neighborhoods of LDR is calculated, and the original pixel value is replaced, as shown in formula (7), and the result of step S4.2 is I HDR_mask The result of step S6 LDR_mask Multiply them, and then set all pixel values ​​that are not zero to 255. The result is recorded as I mask : This is the way to do the intersection, which can also be understood as direct multiplication; I mask =I HDR_mask *I LDR_mask Formula (7); S8, Depurple result, corresponding to I mask The coordinates of all pixels with a value of 255 in I LDR Processing is performed to average the pixel values ​​of the four neighborhoods around the target pixel point, and the average result is assigned to I LDR The corresponding pixel point, the result is recorded as I Depurple .

2. The method for removing purple fringing from an image according to claim 1, characterized in that: The step S2.2 further comprises: S2.2.1, for I canny Perform morphological processing, use the dilation algorithm, set the dilation kernel element parameter to 15x15, and record the result as I cannyd ; S2.2.2, for I cannyd Perform edge expansion operation, set I cannyd_i For image I cannyd For any point with a pixel value of 255, the pixel values ​​of all points in the 9x9 square with this point as the center are set to 255. The processed image is recorded as I cannyde .

3. The method for removing purple fringing from an image according to claim 2, characterized in that: The step S3.3 further comprises: S3.3.1, for I HDRNMB Perform edge expansion operation, set I HDRNMB_i For image I HDRNMB For any point with a pixel value of 255, the pixel values ​​of all points in the 9x9 square with this point as the center are set to 255. The processed image is recorded as I HDRNMBE ; S3.3.2, for I HDRNMBE Perform morphological opening operation, first use the erosion algorithm, set the erosion kernel element parameter to 1x1, then use the expansion algorithm, set the expansion kernel element parameter to 15x15, and the result is recorded as I HDRNMBEF .

4. The method for removing purple fringing from an image according to claim 3, characterized in that: The intersection in step S4 is to make the intersection of the results of step S2.2.2 and step S3.3.2, that is, to retain the parts of the same positions of the two images where the values ​​are not 0.