Image purple fringe eliminating system, method, computer-readable storage medium, and photographing device

11050985 · 2021-06-29

Assignee

Inventors

Cpc classification

International classification

Abstract

Disclosed in the present invention are an image purple fringe eliminating system, method, a computer-readable storage medium, and a photographing device. The system traverses an image, calculates a hue of a pixel, counts a ratio of purple hue to adjacent purple hue pixels in the image, and calculates a dynamic purple fringe detection threshold; creates a mask with the same size as the image acquired by an image acquisition module, and detects the pixels that fall into a purple fringe area; corrects the detected pixel falling into the purple fringe area, correcting both a red channel intensity value and a blue channel intensity value of the pixels within the purple fringe region using a green channel intensity value. The invention can automatically correct the purple fringe of the image, improve the image shooting quality and the user experience.

Claims

1. An image purple fringe eliminating method performed by a photographing device, comprising steps of: acquiring an image; traversing the acquired image and calculating hues of pixels, counting a ratio of pixels of purple and adjacent to purple in the image, and calculating a dynamic detection threshold value of purple fringe; creating a mask with a same size as the acquired image, and detecting pixels within a purple fringe region; correcting the detected pixels within the purple fringe region, and correcting both a red channel intensity value and a blue channel intensity value of the pixels within the purple fringe region using a green channel intensity value; and outputting a corrected image.

2. The method of claim 1, wherein a step of traversing the acquired image and calculating hues of pixels, specifically comprises: traversing the acquired image, scanning all pixels one by one, and calculating a hue of a pixel according to the following formula: h = { 60 ° × r - b max - min + 240 ° if max = b & b - g > 25 60 ° × g - b max - min + 360 if max = r & r - g > 25 0 else where, h is a hue of a pixel; r, g, and b respectively represent a red channel intensity value, a green channel intensity value and a blue channel intensity value of pixels of an image, max represents a maximum intensity value of the three color channels, and min represents a minimum intensity value of the three color channels.

3. The method of claim 2, wherein a step of counting a ratio of pixels of purple and adjacent to purple in the image, specifically comprises: using a preset hue threshold value range of purple and adjacent to purple, counting a total number N of pixels of purple and adjacent to purple of which the hues are within the preset hue threshold value range, and calculating a ratio of the total number N of pixels of purple and adjacent to purple relative to pixels of the whole image using the formula: ratio = N Size where Size represents a size of the image.

4. The method of claim 3, wherein a step of calculating a dynamic detection threshold value of purple fringe, specifically comprises: using the formula: { minPH = 195 + t * ratio maxPH = 315 - t * ratio and calculating a detection threshold value of purple fringe, where min PH, max PH represent a minimum hue threshold value and a maximum hue threshold value of purple fringe respectively, and parameter t is 20.

5. The method of claim 4, wherein a step of creating a mask with a same size as the acquired image, and detecting pixels within a purple fringe region, specifically comprises: creating a mask with the same size as the acquired image, and detecting all the pixels of which the hues are higher than the minimum hue threshold value and lower than the maximum hue threshold value of the purple fringe, and calculating the purple fringe region using the formula: mask ( i , j ) = { 255 minPH < h < maxPH 0 else where mask(i,j)=255 represents the pixels falling into the purple fringe region, otherwise the pixels do not fall into the purple fringe region; min PH, max PH represent a minimum hue threshold value and a maximum hue threshold value of purple fringe respectively; thereby detecting pixels within the purple fringe region.

6. The method of claim 1, wherein a step of correcting the detected pixels within the purple fringe region, and correcting both a red channel intensity value and a blue channel intensity value of the pixels within the purple fringe region using a green channel intensity value, specifically comprises: correcting the red channel intensity value and the blue channel intensity value of the pixels within the purple fringe region using the formula: { r corrected = λ r .Math. r + ( 1 - λ r ) .Math. g 0 < λ r < 1 b corrected = λ b .Math. b + ( 1 - λ b ) .Math. g 0 < λ b < 1 , where r, g, and b represent the red channel intensity value, the green channel intensity value and the blue channel intensity value respectively; r.sub.corrected, b.sub.corrected represent correction values of the red channel intensity value and the blue channel intensity value respectively; and λr, λ.sub.b represent parameters of the red channel and the blue channel, respectively.

7. A non-transitory computer readable medium, having stored thereon, a set of computer-executable instructions for causing one or more processors to perform steps of an image purple fringe eliminating method, comprising: acquiring an image; traversing the acquired image and calculating hues of pixels, counting a ratio of pixels of purple and adjacent to purple in the image, and calculating a dynamic detection threshold value of purple fringe; creating a mask with a same size as the acquired image, and detecting pixels within a purple fringe region; correcting the detected pixels within the purple fringe region, and correcting both a red channel intensity value and a blue channel intensity value of the pixels within the purple fringe region using a green channel intensity value; and outputting a corrected image.

8. A photographing device, comprising: one or more processors; a non-transitory, computer readable memory; a display screen; and one or more computer-executable instructions; wherein the processors are connected with the memory and display screen respectively by bus; the one or more computer-executable instructions are stored in the memory and are executable by the one or more processors to perform steps of an image purple fringe eliminating method, comprising: acquiring an image; traversing the acquired image and calculating hues of pixels, counting a ratio of pixels of purple and adjacent to purple in the image, and calculating a dynamic detection threshold value of purple fringe; creating a mask with a same size as the acquired image, and detecting pixels within a purple fringe region; correcting the detected pixels within the purple fringe region, and correcting both a red channel intensity value and a blue channel intensity value of the pixels within the purple fringe region using a green channel intensity value; and outputting a corrected image.

9. The device of claim 8, wherein a step of traversing the acquired image and calculating hues of pixels, specifically comprises: traversing the acquired image, scanning all pixels one by one, and calculating a hue of a pixel according to the following formula: h = { 60 ° × r - b max - min + 240 ° if max = b & b - g > 25 60 ° × g - b max - min + 360 if max = r & r - g > 25 0 else where, h is a hue of a pixel; r, g, and b respectively represent a red channel intensity value, a green channel intensity value and a blue channel intensity value of pixels of an image, max represents a maximum intensity value of the three color channels, and min represents a minimum intensity value of the three color channels.

10. The method of claim 9, wherein a step of counting a ratio of pixels of purple and adjacent to purple in the image, specifically comprises: using a preset hue threshold value range of purple and adjacent to purple, counting a total number N of pixels of purple and adjacent to purple of which the hues are within the preset hue threshold value range, and calculating a ratio of the total number N of pixels of purple and adjacent to purple relative to pixels of the whole image using the formula: ratio = N Size where Size represents a size of the image.

11. The method of claim 10, wherein a step of calculating a dynamic detection threshold value of purple fringe, specifically comprises: using the formula: { minPH = 195 + t * ratio maxPH = 315 - t * ratio and calculating a detection threshold value of purple fringe, where min PH, max PH represent a minimum hue threshold value and a maximum hue threshold value of purple fringe respectively, and parameter t is 20.

12. The method of claim 8, wherein a step of creating a mask with a same size as the acquired image, and detecting pixels within a purple fringe region, specifically comprises: creating a mask with the same size as the acquired image, and detecting all pixels of which hues are higher than the minimum hue threshold value and lower than the maximum hue threshold value of the purple fringe, and calculating the purple fringe region using the formula: mask ( i , j ) = { 255 minPH < h < maxPH 0 else where mask(i,j)=255 represents the pixels falling into the purple fringe region, otherwise the pixels do not fall into the purple fringe region; min PH, max PH represent a minimum hue threshold value and a maximum hue threshold value of purple fringe respectively; thereby detecting pixels within the purple fringe region.

13. The method of claim 8, wherein a step of correcting the detected pixels within the purple fringe region, and correcting both a red channel intensity value and a blue channel intensity value of the pixels within the purple fringe region using a green channel intensity value, specifically comprises: correcting the red channel intensity value and the blue channel intensity value of the pixels within the purple fringe region using the formula: { r corrected = λ r .Math. r + ( 1 - λ r ) .Math. g 0 < λ r < 1 b corrected = λ b .Math. b + ( 1 - λ b ) .Math. g 0 < λ b < 1 , where r, g, and b represent the red channel intensity value, the green channel intensity value and the blue channel intensity value respectively; r.sub.corrected, b.sub.corrected represent correction values of the red channel intensity value and the blue channel intensity value respectively; and λr, λ.sub.b represent parameters of the red channel and the blue channel, respectively.

Description

BRIEF DESCRIPTION OF THE DRAWINGS

(1) FIG. 1 is a diagram illustrating an image purple-fringe eliminating system of the present invention; and

(2) FIG. 2 is a flowchart illustrating an image purple-fringe eliminating method of the present invention.

DETAILED DESCRIPTION OF THE INVENTION

(3) The following is a detailed explanation of the invention in combination with the drawings and embodiments; and the embodiments are only better modes of the invention and do not limit the protection scope of the invention.

(4) Referring to FIG. 1, which illustrates a diagram of an image purple fringe eliminating system, the system comprising an image acquisition unit 101, a threshold calculation unit 102, a purple fringe detection unit 103, a purple fringe correction unit 104, and an image output unit 105.

(5) The image acquisition unit 101, is used for acquiring an image;

(6) the threshold calculation unit 102, is used for traversing the image acquired by the image acquisition unit 101, calculating hues of pixels, counting a ratio of pixels of purple and adjacent to purple in the image, and calculating a dynamic detection threshold value of purple fringe.

(7) Traversing the acquired image and calculating hues of pixels, specifically comprises: traversing the acquired image, scanning all pixels one by one, and calculating a hue of a pixel according to the following formula 1:

(8) h = { 60 ° × r - b max - min + 240 ° if max = b & b - g > 25 60 ° × g - b max - min + 360 if max = r & r - g > 25 0 else where, h is a hue of a pixel; r, g, and b respectively represent a red channel intensity value, a green channel intensity value and a blue channel intensity value of pixels of an image, max represents the maximum intensity value of the three color channels, and min represents the minimum intensity value of the three color channels.

(9) Counting a ratio of pixels of purple and adjacent to purple in the image specifically comprises: using a preset hue threshold value range [195-315] of purple and adjacent to purple, counting the total number N of pixels of purple and adjacent to purple of which the hues within the threshold value range, and calculating a ratio of the total number N of pixels of purple and adjacent to purple relative to the pixels of the whole image via the formula 2:

(10) ratio = N Size where Size represents the size of the image.

(11) Calculating a dynamic detection threshold value of purple fringe, specifically comprises: using the formula 3:

(12) { minPH = 195 + t * ratio maxPH = 315 - t * ratio calculating the dynamic detection threshold value of purple fringe, where min PH, max PH represent the minimum hue threshold value and the maximum hue threshold value of purple fringe respectively, and parameter t is generally 20.

(13) The purple fringe detection unit 103, is used for creating a mask with the same size as the image acquired by the image acquisition unit, and detecting pixels within purple fringe region.

(14) The purple fringe detection unit can be specifically used for: creating a mask with the same size as the image acquired by the image acquisition unit, and detecting all the pixels of which the hues higher than the minimum hue threshold value and lower than the maximum hue threshold value of the purple fringe, and calculating the purple fringe region using the formula 4:

(15) mask ( i , j ) = { 255 minPH < h < maxPH 0 else where mask(i,j)=255 represents the pixels falling into the purple fringe region, otherwise the pixels do not fall into the purple fringe region; min PH, max PH respectively represent the minimum hue threshold value and the maximum hue threshold value of the purple fringe; thereby detecting pixels within the purple fringe region.

(16) The purple fringe correction unit 104, is used for correcting the detected pixels within the purple fringe region, and correcting both a red channel intensity value and a blue channel intensity value of the pixels within the purple fringe region using a green channel intensity value.

(17) The purple fringe correction unit corrects the red channel intensity value and the blue channel intensity value of the pixels within the purple fringe region using the formula 5:

(18) { r corrected = λ r .Math. r + ( 1 - λ r ) .Math. g 0 < λ r < 1 b corrected = λ b .Math. b + ( 1 - λ b ) .Math. g 0 < λ b < 1 , where r, g, and b represent the red channel intensity value, the green channel intensity value and the blue channel intensity value respectively; r.sub.corrected, b.sub.corrected represent correction values of the red channel intensity value and the blue channel intensity value respectively; and λr, λ.sub.b represent the parameters of the red channel and the blue channel, respectively.

(19) The image output unit 105, is used for outputting a corrected image.

(20) Referring to FIG. 2, a flowchart of an image purple-fringe eliminating method is illustrated. The image purple-fringe eliminating method comprises the following steps.

(21) Step 201, acquiring an image.

(22) Step 202, traversing the acquired image and calculating hues of pixels, counting a ratio of pixels of purple and adjacent to purple in the image, and calculating a dynamic detection threshold value of purple fringe.

(23) The step of traversing the acquired image and calculating hues of pixels, specifically comprises: traversing the acquired image, scanning all pixels one by one, and calculating a hue of a pixel according to the formula 1:

(24) h = { 60 ° × r - b max - min + 240 ° if max = b & b - g > 25 60 ° × g - b max - min + 360 if max = r & r - g > 25 0 else where, h is a hue of a pixel; r, g, and b respectively represent a red channel intensity value, a green channel intensity value and a blue channel intensity value of pixels of an image, max represents the maximum intensity value of the three color channels, and min represents the minimum intensity value of the three color channels.

(25) The step of counting a ratio of pixels of purple and adjacent to purple in the image, specifically comprises: using a preset hue threshold value range [195-315] of purple and adjacent to purple, counting the total number N of pixels of purple and adjacent to purple of which the hues within the threshold value range, and calculating a ratio of the total number N of pixels of purple and adjacent to purple relative to the pixels of the whole image via the formula 2:

(26) ratio = N size where Size represents the size of the image.

(27) The step of calculating a dynamic detection threshold value of purple fringe, specifically comprises: using the formula 3:

(28) { minPH = 195 + t * ratio maxPH = 315 - t * ratio calculating the dynamic detection threshold value of purple fringe, where min PH, max PH represent the minimum hue threshold value and the maximum hue threshold value of purple fringe respectively, and parameter t is generally 20.

(29) Step 203, creating a mask with the same size as the acquired image, and detecting pixels within purple fringe region.

(30) The step 203 specifically comprises: creating a mask with the same size as the acquired image of step 201, and detecting all the pixels of which the hues higher than the minimum hue threshold value and lower than the maximum hue threshold value of the purple fringe, and calculating the purple fringe region using the formula 4:

(31) mask ( i , j ) = { 255 minPH < h < maxPH 0 else where mask(i,j)=255 represents the pixels falling into the purple fringe region, otherwise the pixels do not fall into the purple fringe region; min PH, max PH respectively represent the minimum hue threshold value and the maximum hue threshold value of the purple fringe; thereby detecting pixels within the purple fringe region.

(32) Step 204, correcting the detected pixels within the purple fringe region, correcting both a red channel intensity value and a blue channel intensity value of the pixels within the purple fringe region using a green channel intensity value.

(33) The step 204 specifically comprises: correcting the red channel intensity value and the blue channel intensity value of the pixels within the purple fringe region according to the formula 5:

(34) 0 { r corrected = λ r .Math. r + ( 1 - λ r ) .Math. g 0 < λ r < 1 b corrected = λ b .Math. b + ( 1 - λ b ) .Math. g 0 < λ b < 1 , where r, g, and b represent the red channel intensity value, the green channel intensity value and the blue channel intensity value respectively; r.sub.corrected, b.sub.corrected represent correction values of the red channel intensity value and the blue channel intensity value respectively; and λr, λ.sub.b represent the parameters of the red channel and the blue channel, respectively. Generally, λr, λ.sub.b is a relatively small number.

(35) Step 205, outputting a corrected image.

(36) The present invention further provides a non-transitory computer readable medium having stored thereon, a set of computer-executable instructions for causing a processor to perform the steps of the image purple-fringe eliminating method of the present invention.

(37) The present invention further provides a photographing device, comprising:

(38) one or more processors; a non-transitory, computer readable memory, a display screen, and one or more computer-executable instructions; the processors are connected with the memory and display screen respectively by bus; the one or more computer-executable instructions are stored in the memory and are executable by the one or more processors to perform the steps of the image purple-fringe eliminating method of the present invention.

(39) Of the method of the present invention, all or some steps may be established into functional block diagram, and are performed by computer system under computer program instructions, and computer program instructions are stored in a non-transitory, computer readable memory.

(40) The above mentioned is preferred embodiments of the invention and is not used to limit the invention. Although the preferred embodiments of the present disclosure have been illustrated and described above, any modification and equivalent replacement made within the spirit and principles of the invention, shall be included in the protection scope of the invention.