Embodiment one
Refer to Fig. 1, Fig. 1 is the schematic flow sheet of the method for the detection blood-shot eye illness of the embodiment of the present invention one, and as shown in Figure 1, the described method detecting blood-shot eye illness comprises:
Step S11: obtain the blood-shot eye illness sample point in eyes image.
Step S12: search for the pixel comprised in the preset range of described blood-shot eye illness sample point, calculate the color distance between described pixel and described blood-shot eye illness sample point.
Step S13: based on described color distance determination red pixel point, with the region at described red pixel point place for red eye region, described preset range is relevant to the resolution of described eyes image.
Particularly, perform step S11, in this step, the acquisition of seeing red sample point in eyes image can be obtained by the aid in existing image processing software, and the red pixel point as clicked in red eye region by the aid single carried in the image processing softwares such as photoshop or acdsee by user sees red sample point to obtain.
In addition, if obtain the blood-shot eye illness sample point in eyes image on mini-plant, as: mobile terminal, then the image processing tool that can carry by means of mobile terminal is to obtain blood-shot eye illness sample point.
Perform step S12, search for the pixel comprised in the preset range of described blood-shot eye illness sample point, calculate the color distance between described pixel and described blood-shot eye illness sample point.Described preset range is relevant to the resolution of described eyes image.In general, described preset range is 0.25 ~ 0.5 times of face region area, and in order to red eye region can be searched quickly, usual described preset range is by the circle of seeing red 0.25 ~ 0.5 times that the area centered by sample point is face region area, also can be rectangle or other polygons.
In the present embodiment, the pixel in preset range can be searched for by the following two kinds mode, and calculate the color distance between described pixel and described blood-shot eye illness sample point.
Refer to Fig. 2, Fig. 2 is the schematic diagram that the search of the embodiment of the present invention one comprises a kind of way of search of the pixel in the preset range of blood-shot eye illness sample point.As shown in Figure 2, the first pixel of the predetermined neighborhood of search center pixel, described central pixel point is positioned at described preset range.The present embodiment, the central pixel point that first time searches for is the blood-shot eye illness sample point R obtained in step S11, and described predetermined neighborhood is four neighborhoods or eight neighborhood.For Fig. 2, the pixel of four neighborhoods of blood-shot eye illness sample point R is pixel 2,4,5,7; The pixel of the eight neighborhood of blood-shot eye illness sample point R is pixel 1,2,3,4,5,6,7,8.
In the present embodiment with predetermined neighborhood for eight neighborhood is described whole search procedure.First the pixel 1,2,3,4,5,6,7,8 of the eight neighborhood of search blood-shot eye illness sample point R.Calculate the color distance between pixel 1,2,3,4,5,6,7,8 and blood-shot eye illness sample point R respectively.Next, centered by the pixel once searched in the past, pixel proceeds eight neighborhood search.In the present embodiment, before the pixel that once searches be pixel 1, 2, 3, 4, 5, 6, 7, 8, then can with pixel 1, 2, 3, 4, 5, 6, 7, centered by a pixel in 8, pixel carries out eight neighborhood search, for pixel 8, then the pixel of its eight neighborhood should be pixel R, 5, 13, 7, 9, 12, 11, 10, in the present embodiment, preferably, the front pixel once searched for no longer is searched for, therefore the pixel 9 only searched for for pixel 8 in its eight neighborhood, 10, 11, 12, 13, then pixel 9 is calculated, 10, 11, 12, color distance between 13 and blood-shot eye illness sample point R.Next, centered by a pixel then in pixel 9,10,11,12,13, pixel carries out eight neighborhood search, the color distance between the pixel that calculating searches and blood-shot eye illness sample point R.Repeat the process of above-mentioned search and calculating, until final search to the region at pixel place exceed described preset range, then stop search.
Refer to Fig. 3, Fig. 3 is the schematic diagram that the search of the embodiment of the present invention one comprises the another kind of way of search of the pixel in the preset range of blood-shot eye illness sample point.As shown in Figure 3, centered by described blood-shot eye illness sample point R, search for the pixel of predetermined neighborhood.In the present embodiment, described predetermined neighborhood can be that predetermined length is the square of the length of side centered by described blood-shot eye illness sample point R; Or centered by described blood-shot eye illness sample point R, predetermined length and width are respectively long and wide rectangle.In the present embodiment, for predetermined neighborhood for square illustrates accordingly, if the coordinate of blood-shot eye illness sample point R be (x, y), then centered by described blood-shot eye illness sample point R, search for the length of side be 2 times pixel interval from the pixel of square neighborhood.Also namely searching coordinates is respectively (x-1, y), (x+1, y), (x-1, y+1), (x, y+1), (x+1, y+1), (x-1, y-1), the pixel of (x, y-1), (x+1, y-1).Corresponding in Fig. 3, be then pixel 1,2,3,4,5,6,7,8, calculate pixel 1,2,3,4, color distance between 5,6,7,8 and described blood-shot eye illness sample point R.Increase described predetermined neighborhood, then described predetermined neighborhood can be increased by increasing the default length of side in the present embodiment, as preset as described in increasing the length of side be 4 times pixel interval from, then search for the length of side be 4 times pixel interval from the pixel of square neighborhood, be then search pixel point 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24 corresponding to Fig. 3.Then, calculate pixel 9,10,11,12,13,14,15,16,17,18,19,20, color distance between 21,22,23,24 and described blood-shot eye illness sample point R, increase described predetermined neighborhood, continue search, and calculate the color distance between pixel and described blood-shot eye illness sample point R searched.Repeat above-mentioned search pixel point, calculate the process of color distance and increase neighborhood, until the pixel region searched exceeds described preset range, then stop search.
By above-mentioned two kinds of modes, then can search the pixel in the preset range comprising described blood-shot eye illness sample point.Then the color distance between pixel and described blood-shot eye illness sample point searched is calculated.For different color spaces, then obtain the color distance between the pixel searched and described blood-shot eye illness sample point in different ways.In the present embodiment, for rgb color space, then the color distance between the pixel searched and described blood-shot eye illness sample point is obtained by following formula:
Wherein, d represents the color distance between pixel and blood-shot eye illness sample point, and R, G, B represent the red channel value of pixel, green channel value, blue channel value respectively, R
s, G
s, B
srepresent red channel value, green channel value, the blue channel value of blood-shot eye illness sample point respectively.
Perform step S13, based on described color distance determination red pixel point, with the region at described red pixel point place for red eye region.By performing step S12, searching the pixel in preset range, also having calculated the color distance between pixel and described blood-shot eye illness sample point searched simultaneously, therefore red pixel point can be determined based on described color distance.Particularly, if described color distance is greater than first threshold and is less than Second Threshold, then described pixel is red pixel point.For rgb space, described first threshold is 1, and described Second Threshold is 20.Also namely for rgb space, when the color distance between described blood-shot eye illness sample point and the pixel searched is greater than 1 and is less than 20, then the pixel searched is red pixel point.And for the color distance with described blood-shot eye illness sample point equal 1 pixel can also can not for red pixel point for red pixel point, similarly, for the pixel that the color distance with described blood-shot eye illness sample point equals 20, can be that red pixel point also can not for red pixel point, when color distance between pixel and described blood-shot eye illness sample point equals first threshold or Second Threshold, whether determine that this pixel is the accuracy requirement of red pixel point when then depending on that red eye region detects.
In the present embodiment, with the color space at eyes image place for rgb space, the color distance between blood-shot eye illness sample point and the pixel searched is illustrated, and determines that red pixel point is to obtain red eye region with the threshold value of rgb space.In order to more accurate red eye region can be obtained, after obtaining the blood-shot eye illness sample point in eyes image, color space conversion can also be carried out to described eyes image in the present embodiment, by in different color spaces, the measurement of the color distance between described blood-shot eye illness sample point and the pixel searched more accurately is determined red pixel point.
Particularly, carrying out color space conversion to described eyes image can be carried out color space conversion before searching for the pixel comprised in the preset range of described blood-shot eye illness sample point, then search for the pixel in preset range in color space after conversion, and calculate the color distance between described pixel and described blood-shot eye illness sample point.
Also can be carry out color space conversion after searching for the pixel comprised in the preset range of described blood-shot eye illness sample point, in color space after conversion, calculate the color distance between described pixel and described blood-shot eye illness sample point.
In the present embodiment, if the color space at the eyes image place of extracting is rgb space, then can be converted to any one color space in CIELab space, HSV space, yuv space.The image of rgb space being converted to CIELab space or HSV space or yuv space is prior art, so place repeats no more.
In the present embodiment, if the color space of the eyes image after changing is CIELab space, then the color distance calculated between described pixel and described blood-shot eye illness sample point is undertaken by following formula:
Wherein, d represent pixel and blood-shot eye illness sample point between color distance, l, a, b represent respectively pixel luminance channel, from redness to the scope of green, from blueness to the scope of yellow, l
s, a
s, b
srepresent the luminance channel of blood-shot eye illness sample point respectively, from redness to the scope of green, from blueness to the scope of yellow.
If the color space of the eyes image after changing is HSV space, then the color distance calculated between described pixel and described blood-shot eye illness sample point is undertaken by following formula:
Wherein, d represents the color distance between pixel and blood-shot eye illness sample point, and h, s, v represent the tone of pixel, saturation degree and brightness respectively, h
s, s
s, v
srepresent the tone of blood-shot eye illness sample point, saturation degree and brightness respectively, α
1, β
1represent weight coefficient.
If the color space of the eyes image after changing is yuv space, then the color distance calculated between described pixel and described blood-shot eye illness sample point is undertaken by following formula:
Wherein, d represents the color distance between pixel and blood-shot eye illness sample point, and y represents that brightness u, v of pixel represent the colourity of pixel, y
srepresent the brightness of blood-shot eye illness sample point, u
s, v
srepresent the colourity of blood-shot eye illness sample point, α
2, β
2represent weight coefficient.
And correspond to above-mentioned CIELab space or HSV space or yuv space, when it determines red pixel point, also be that the color distance between the blood-shot eye illness sample point calculated at each color space and the pixel searched is judged, when described color distance is greater than first threshold and is less than Second Threshold, described pixel is then red pixel point.Unlike, for different color spaces, the value of described first threshold, Second Threshold is had nothing in common with each other, and specifically in different color spaces, described first threshold, Second Threshold get how many, tested determine by reality.
In addition, it should be noted that, in the present embodiment, obtain blood-shot eye illness sample point by means of the aid in image processing software by the mode that single is clicked by user, and in other embodiments, also multiple blood-shot eye illness sample point can be obtained by user by repeatedly clicking, the pre-stator range comprising described blood-shot eye illness sample point is all existed for each the blood-shot eye illness sample point obtained, to the scope that the pre-stator range corresponding to each blood-shot eye illness sample point asks union to obtain, for finally comprising the preset range of multiple blood-shot eye illness sample point.Then based on this preset range search pixel point, and the color distance calculated between the pixel that searches and multiple blood-shot eye illness sample point is to determine red pixel point.
Determine red pixel point by above-mentioned mode, the region at described red pixel point place is the red eye region detected.After red eye region being detected, next described red eye region is corrected, namely remove described red eye region.
Refer to Fig. 4, Fig. 4 is the schematic flow sheet of the method for the removal blood-shot eye illness of the embodiment of the present invention one, and as shown in Figure 4, the described method removing blood-shot eye illness comprises:
Step S11: obtain the blood-shot eye illness sample point in eyes image.
Step S12: search for the pixel comprised in the preset range of described blood-shot eye illness sample point, calculate the color distance between described pixel and described blood-shot eye illness sample point.
Step S13: based on described color distance determination red pixel point, with the region at described red pixel point place for red eye region, described preset range is relevant to the resolution of described eyes image.
Step S14: based on described color distance determination black pixel point, utilize described black pixel point to correct described red eye region.
In the present embodiment, the process that execution step S11 ~ S13 detection red eye region and above-mentioned detection are seen red is similar, repeats no more herein.
Perform step S14: based on described color distance determination black pixel point, utilize described black pixel point to correct described red eye region.Searched for the pixel in the preset range comprising described blood-shot eye illness sample point by above-mentioned step S11 and S12, concrete search procedure can see the description in the above-mentioned method detecting blood-shot eye illness.In the present embodiment, still with the color space at eyes image place for rgb space illustrates accordingly, then the obtain manner of described color distance is identical with above-mentioned steps S12, unlike, for the pixel searched, when color distance between itself and described blood-shot eye illness sample point is greater than the 3rd threshold value and is less than the 4th threshold value, then this pixel searched is black pixel point.Be 20 for the 3rd threshold value described in rgb space, described 4th threshold value is 40.Also the color distance namely between the pixel searched and described blood-shot eye illness sample point is greater than 20 when being less than 40, and this pixel is black pixel point.And for the color distance with described blood-shot eye illness sample point equal 20 pixel can also can not for black pixel point for black pixel point, similarly, for the pixel that the color distance with described blood-shot eye illness sample point equals 40, can be that black pixel point also can not for black pixel point, when color distance between pixel and described blood-shot eye illness sample point equals the 3rd threshold value or the 4th threshold value, whether determine that this pixel is the accuracy requirement of black pixel point when then depending on that red eye region detects.
In addition, owing to being utilize the black pixel point that searches to correct red eye region in the present embodiment, therefore the black pixel point searched is more accurate then correct after the effect of red eye region better, therefore when determining black pixel point in the present embodiment, also can carry out at different color spaces, specific formula for calculation can see the computing formula of seeing red the color distance between sample point and the pixel searched in above-mentioned CIELab space or HSV space or yuv space.Only correspond to no color space, the value of the 3rd threshold value and the 4th threshold value is different, specifically gets what value and is tested by reality and determine.
In the present embodiment, utilize described black pixel point to correct described red eye region and carry out especially by following formula:
Wherein, R
new, G
new, B
newbe respectively the red channel value of pixel after correction in described red eye region, green channel value, blue channel value, G
old, B
oldbe respectively the green channel value of pixel before correction, the blue channel value in described red eye region, the green channel value of red pixel point and blue channel value in the red eye region also namely detected.
be respectively the red channel value mean value of black pixel point, green channel value mean value, blue channel value mean value, particularly, exactly the red channel value phase adduction of all black pixel points searched is obtained to red channel value mean value divided by the sum of black pixel point, the green channel value phase adduction of all black pixel points searched is obtained to green channel value mean value divided by the sum of black pixel point, obtains blue channel value mean value to the blue channel value phase adduction of all black pixel points searched divided by the sum of black pixel point.α is weight factor, α ∈ [0,1].
By above-mentioned correcting method, the red eye region detected is corrected, and the green channel value of employing black pixel point and the red pixel point before correcting, blue channel value are corrected red eye region, because it has taken into account the pixel value of red pixel point self and black pixel point around thereof, corresponding adjustment has been carried out to the RGB triple channel value of the pixel after correction, therefore, achieve the desaturation effect of the red eye region after to correction, and red eye region after correcting is relatively natural, effect is better.
Corresponding to the method for above-mentioned detection blood-shot eye illness, the embodiment of the present invention also provides a kind of device detecting blood-shot eye illness, refers to Fig. 5, and Fig. 5 is the structural representation of the device of the detection blood-shot eye illness of the embodiment of the present invention one, and as shown in Figure 5, the described device 1 detecting blood-shot eye illness comprises:
Acquiring unit 10, for obtaining the blood-shot eye illness sample point in eyes image.
Search computing unit 11, be connected with described acquiring unit 10, for searching for the pixel in the preset range comprising described blood-shot eye illness sample point, calculate the color distance between described pixel and described blood-shot eye illness sample point, described preset range is relevant to the resolution of described eyes image.
Red pixel point determining unit 12, is connected with described search computing unit 11, for based on described color distance determination red pixel point, with the region at described red pixel point place for red eye region.
In the present embodiment, described search computing unit 11 comprises:
First search subelement 110, be connected with described acquiring unit 10, for the pixel of the predetermined neighborhood of search center pixel, described central pixel point is positioned at described preset range.
First computing unit 111, searches for subelement 110 with described first, red pixel point determining unit 12 is connected, for calculating the color distance between pixel and described blood-shot eye illness sample point searched.
First control module 112, search for subelement 110, first computing unit 111 be connected with described first, when region for the pixel place searched at described first search subelement 110 does not exceed described preset range, control described first search subelement 110, first computing unit 111 and work; Wherein, the central pixel point that first time searches for is described blood-shot eye illness sample point, the pixel that later central pixel point of searching for for each time once searches before being.
In the present embodiment, the predetermined neighborhood of described first search subelement 110 search center pixel can be neighbours territory, also can be eight neighborhood.In the present embodiment, preferably, the pixel of the not searched mistake of the predetermined neighborhood of described first search subelement 110 search center pixel.
In other embodiments, described search computing unit comprises:
Second search subelement (not shown), for searching for the pixel of predetermined neighborhood centered by described blood-shot eye illness sample point.
Second computing unit (not shown), searches for subelement be connected, for calculating the color distance between described pixel and described blood-shot eye illness sample point with described second.
Second control module (not shown), search for subelement with described second, the second computing unit is connected, when pixel region for searching at described second search subelement not exceeding described preset range, increasing described predetermined neighborhood union and controlling described second search subelement, the second computing unit work.
In the present embodiment, the described device 1 detecting blood-shot eye illness also comprises: color space converting unit (not shown), for obtain the blood-shot eye illness sample point in eyes image at described acquiring unit 10 after, carry out color space conversion to described eyes image.Described search computing unit 11 is for calculating pixel described in the color space after conversion and the color distance between described blood-shot eye illness sample point.
In the present embodiment, if the color space of described eyes image is rgb space, described color space converting unit is used for any one color space be converted to by described eyes image in CIELab space, HSV space, yuv space.
Particularly, if described eyes image is converted to CIELab space by described color space converting unit, then described search computing unit 11 is by the color distance described in following formulae discovery between pixel and described blood-shot eye illness sample point:
Wherein, d represent pixel and blood-shot eye illness sample point between color distance, l, a, b represent respectively pixel luminance channel, from redness to the scope of green, from blueness to the scope of yellow, l
s, a
s, b
srepresent the luminance channel of blood-shot eye illness sample point respectively, from redness to the scope of green, from blueness to the scope of yellow.
If described eyes image is converted to HSV space by described color space converting unit, then described search computing unit 11 is by pixel described in following formulae discovery and the color distance between described blood-shot eye illness sample point
Wherein, d represents the color distance between pixel and blood-shot eye illness sample point, and h, s, v represent the tone of pixel, saturation degree and brightness respectively, h
s, s
s, v
srepresent the tone of blood-shot eye illness sample point, saturation degree and brightness respectively, α
1, β
1represent weight coefficient.
If described eyes image is converted to yuv space by described color space converting unit, then described search computing unit 11 is by the color distance described in following formulae discovery between pixel and described blood-shot eye illness sample point:
Wherein, d represents the color distance between pixel and blood-shot eye illness sample point, and y represents that brightness u, v of pixel represent the colourity of pixel, y
srepresent the brightness of blood-shot eye illness sample point, u
s, v
srepresent the colourity of blood-shot eye illness sample point, α
2, β
2represent weight coefficient.
In the present embodiment, described red pixel point determining unit 12 comprises: the first judging unit (not shown), for when described color distance is greater than first threshold and is less than Second Threshold, judges that described pixel is red pixel point.
In the present embodiment, when the color space of described eyes image is rgb space, described search computing unit 11 is by the color distance described in following formulae discovery between pixel and described blood-shot eye illness sample point:
Wherein, d represents the color distance between pixel and blood-shot eye illness sample point, and R, G, B represent the red channel value of pixel, green channel value, blue channel value respectively, R
s, G
s, B
srepresent red channel value, green channel value, the blue channel value of blood-shot eye illness sample point respectively.Now, described first judging unit is used for when described color distance is greater than 1 and is less than 20, judges that described pixel is red pixel point.
It should be noted that, for above-mentioned different color space, the color distance formula of its correspondence between the described blood-shot eye illness sample point of corresponding calculating and the pixel searched, when now based on first threshold and Second Threshold, the first judging unit judges that the pixel searched is red pixel point, the value of described first threshold, Second Threshold is determined by the actual test carried out at this color space.
In the present embodiment, the described course of work detecting the device of blood-shot eye illness can be carried out see the method for above-mentioned detection blood-shot eye illness, repeats no more herein.
Corresponding to the method for above-mentioned removal blood-shot eye illness, the embodiment of the present invention also provides a kind of device removing blood-shot eye illness, refers to Fig. 6, and Fig. 6 is the structural representation of the device of the removal blood-shot eye illness of the embodiment of the present invention one, and as shown in Figure 6, the described device removing blood-shot eye illness comprises:
The device 1 of above-mentioned detection blood-shot eye illness.
Correcting unit 13, being connected, for correcting described red eye region with the described device 1 of seeing red that detects.
In the present embodiment, in order to make the effect of the red eye region after correcting better, the described device removing blood-shot eye illness also comprises:
Black pixel point determining unit 14, is connected with the described device 1 of seeing red that detects, for based on described color distance determination black pixel point.
Described correction unit 13, is connected with described black pixel point determining unit 14, corrects described red eye region for utilizing described black pixel point.
In the present embodiment, described black pixel point determining unit 14 comprises: the second judging unit (not shown), during for being greater than the 3rd threshold value at described color distance and being less than the 4th threshold value, judges that described pixel is black pixel point.
In the present embodiment, be rgb space at the color space of described eyes image, described search computing unit 11 is by the color distance described in following formulae discovery between pixel and described blood-shot eye illness sample point:
Wherein, d represents the color distance between pixel and blood-shot eye illness sample point, and R, G, B represent the red channel value of pixel, green channel value, blue channel value respectively, R
s, G
s, B
srepresent red channel value, green channel value, the blue channel value of blood-shot eye illness sample point respectively.Now, described second judging unit is used for when described color distance is greater than 20 and is less than 40, judges that described pixel is black pixel point.
Described correction unit 13 is corrected described red eye region by following formula:
Wherein, R
new, G
new, B
newbe respectively the red channel value of pixel after correction in described red eye region, green channel value, blue channel value, G
old, B
oldbe respectively the green channel value of pixel before correction, the blue channel value in described red eye region, the green channel value of red pixel point and blue channel value in the red eye region also namely detected.
be respectively the red channel value mean value of black pixel point, green channel value mean value, blue channel value mean value.α is weight factor, α ∈ [0,1].
It should be noted that, the formula calculating the color distance between described blood-shot eye illness sample point and the pixel searched at different color spaces is given in the present embodiment, the value of first threshold, Second Threshold, the 3rd threshold value and the 4th threshold value when judging red pixel point or black pixel point based on described color distance is then fixed according to reality test, therefore, the value of described first threshold, Second Threshold, the 3rd threshold value and the 4th threshold value should as the restriction to technical solution of the present invention.
In the present embodiment, the course of work removing the device of blood-shot eye illness can be carried out see the method for above-mentioned removal blood-shot eye illness, no longer launches concrete detailed description in detail herein.
Embodiment two
In the present embodiment, detect in the method and embodiment one of seeing red similar, unlike, the method removing blood-shot eye illness in the present embodiment is not identical with embodiment one, the red eye region that its method removing blood-shot eye illness further comprises correcting judges accordingly, to judge whether the red eye region after correcting is correct region by mistake, during in the region of correcting for correcting region by mistake, it is suppressed.
Refer to Fig. 7, Fig. 7 is the schematic flow sheet of the method for the removal blood-shot eye illness of the embodiment of the present invention two, and as shown in Figure 7, the described method removing blood-shot eye illness comprises:
Step S11: obtain the blood-shot eye illness sample point in eyes image.
Step S12: search for the pixel comprised in the preset range of described blood-shot eye illness sample point, calculate the color distance between described pixel and described blood-shot eye illness sample point.
Step S13: based on described color distance determination red pixel point, with the region at described red pixel point place for red eye region, described preset range is relevant to the resolution of described eyes image.
Step S14 ': described red eye region is corrected.
Step S15: the mistake obtained in the red eye region after correcting based on texture analysis corrects region.
Step S16: utilize medium filtering to suppress described region of correcting by mistake.
In the present embodiment, similar in step S11 ~ S13 and embodiment one, so place no longer launches concrete detailed description in detail.Perform step S14 ' to correct described red eye region, prior art can be utilized to correct red eye region, and in the present embodiment, the average of the pixel value of the pixel in the black eyeball region near the red eye region that detects can be utilized to replace the pixel value of the pixel in red eye region.Described black eyeball region refers to the region with described red eye region with nest relation, described black eyeball region can utilize the color characteristic in black eyeball region and shape facility and obtain with the position relationship of described red eye region, as obtained black region by different color segmentation methods, then the shape of black region obtained and position relationship are judged, if the shape of the black region obtained is circular, similar round, oval, a kind of in class ellipse and there is nest relation with the red eye region detected, then this black region is black eyeball region.After obtaining black eyeball region, 6 ~ 12 pixels in the black eyeball region of fetch bit near described red eye region, calculate the average of the pixel value of 6 ~ 12 pixels, for 6 pixels, then divided by 6 by the pixel value phase adduction of 6 pixels, to obtain the average of the pixel value of 6 pixels, and the pixel value using this average as the pixel of described red eye region.
Further, in the present embodiment, in order to reduce the mistake correction rate to the red eye region detected, perform step S15, the mistake obtained in the red eye region after correcting based on texture analysis corrects region.
Particularly, obtain the degree of uniformity of the red degree of the pixel in the red eye region detected in preset range, described preset range is associated with the size of described red eye region.
If described degree of uniformity reaches preset value, then the red eye region after described correction is for correct region by mistake.
The described red eye region detected be with correct after the red eye region detected corresponding to red eye region.Preset range in the described red eye region detected, it can be 1/1 to four/2nd of described red eye region, preferably, get 1/2nd of described red eye region, and described preset range can be the arbitrary region in described red eye region, if guarantee preset range still belong to described red eye region and for red eye region 1/1 to four/2nd.In the present embodiment, described in the degree of uniformity of red degree of pixel in the red eye region that detects in preset range obtain in the following way:
Wherein, I
ibe the red degree of i-th pixel, I
afor the mean value of the red degree of the pixel in preset range in the red eye region that detects, N is the number of the pixel in preset range, and E is the degree of uniformity of the red degree of pixel in the red eye region detected in preset range.
In general, if the red eye region after correcting is wrong, to be likely eye lip portion flase drop be red eye region and then correct it, therefore, the degree of uniformity of the red degree of the pixel in preset range in (before the correction) red eye region detected is detected accordingly, if the degree of uniformity of the red degree of the pixel in this preset range is poor, then prove that this region should be a lip, in the present embodiment with the standard variance of the red degree of the pixel in preset range in the red eye region detected to weigh the degree of uniformity of red degree, therefore the standard variance of described red degree is less, the degree of uniformity representing the red degree in this region is better, therefore, weigh for the degree of uniformity of red degree for adopting the standard variance of red degree of pixel, the degree of uniformity of redness degree reaches preset value, when then referring to that the standard variance of the red degree of the pixel in the red eye region detected in preset range is greater than the first predetermined threshold value, judge that the red eye region after correcting is wrong.Described in the present embodiment, the first predetermined threshold value is more than or equal to 0.1 and is less than or equal to 0.3.
Mode according to other weighs the degree of uniformity of the red degree of the pixel in the red eye region detected in preset range, as adopted the degree of scatter of red texture to weigh the words of the degree of uniformity of the red degree of the pixel in preset range, then the degree of scatter of the red texture in this region is larger, degree of uniformity is better, now for adopting the degree of scatter of red texture to weigh for the degree of uniformity of the red degree of the pixel in preset range, the degree of uniformity of redness degree reaches preset value, when then referring to that the degree of scatter of the red texture of the pixel in the red eye region detected in preset range is less than the second predetermined threshold value, judge that the red eye region detected is wrong.Described second predetermined threshold value is tested by reality and is determined.
After determining the red eye region of by mistake correcting, perform step S16, utilize medium filtering to suppress described region of correcting by mistake.The chromatic value arranging the described pixel by mistake corrected in region is particularly described intermediate value of by mistake correcting the chromatic value of pixel before correction in region.
In the present embodiment, the space at the eyes image place of acquisition is rgb space, and determines red pixel point based on the color distance that rgb space calculates between blood-shot eye illness sample point and the pixel searched and then detect red eye region.But, due to the characteristic of human visual system, when the red eye region detected is corrected, normally carry out at yuv space, after red eye region being corrected, be converted to rgb space again.Therefore, to when correction region suppresses by mistake in the present embodiment, first the value of pixel R, G, B of this pixel before correction of by mistake correcting in region is converted to Y, U, V value in yuv space.In addition, to when correction region suppresses by mistake, the impact of brightness is not very large, therefore to when correction region suppresses by mistake, only can consider colourity (brightness is constant), all can consider brightness and colourity yet.
Therefore, when the described region of correction is by mistake suppressed, the chromatic value of all pixels in the region before correction can be calculated particularly, and using the intermediate value of all chromatic values as the chromatic value (brightness value is constant) correcting the pixel in region by mistake.After the chromatic value of the pixel by mistake corrected in region is determined, then the chromatic value and brightness value of correcting the pixel in region are converted to by mistake the value of corresponding R, G, B, to complete the described suppression correcting region by mistake.
Or, calculate chromatic value and the brightness value of all pixels in the region before correcting, and using the intermediate value of the intermediate value of all chromatic values, brightness value as chromatic value and the brightness value of correcting the pixel in region by mistake.After the chromatic value of the pixel by mistake in correction region and brightness value are determined, then the chromatic value and brightness value of correcting the pixel in region are converted to by mistake the value of corresponding R, G, B, to complete the described suppression correcting region by mistake.
In the present embodiment, be converted to yuv space from rgb space and undertaken by following formula:
Be converted to rgb space from yuv space to be undertaken by following formula:
In addition, in the present embodiment, when utilizing medium filtering to suppress the described region of correction by mistake.The chromatic value that also can arrange the described pixel by mistake corrected in region is described intermediate value of by mistake correcting the chromatic value of pixel before correction of setting range in region.Namely the intermediate value by mistake need not correcting the chromatic value of all pixels before correction in region suppresses described region of correcting by mistake, but only utilizing described intermediate value of by mistake correcting the chromatic value of pixel before correction of setting range in region to suppress described region of correcting by mistake, the size of the preset range during degree of uniformity of the red degree of the pixel in the red eye region that described setting range can detect with above-mentioned acquisition in preset range is identical.Only utilize described intermediate value of by mistake correcting the chromatic value of pixel before correction of setting range in region to suppress correcting region by mistake, can operand be reduced to a certain extent.
Corresponding to the method for above-mentioned removal blood-shot eye illness, the present embodiment also provides a kind of device removing blood-shot eye illness, refers to Fig. 8, and Fig. 8 is the structural representation of the device of the removal blood-shot eye illness of the embodiment of the present invention two, and as shown in Figure 8, the described device removing blood-shot eye illness comprises:
First acquiring unit 20, for obtaining the blood-shot eye illness sample point in eyes image.
Search computing unit 21, be connected with described first acquiring unit 20, for searching for the pixel in the preset range comprising described blood-shot eye illness sample point, calculate the color distance between described pixel and described blood-shot eye illness sample point, described preset range is relevant to the resolution of described eyes image.
Red pixel point determining unit 22, is connected with described search computing unit 21, for based on described color distance determination red pixel point, with the region at described red pixel point place for red eye region.
Correcting unit 23, being connected, for correcting described red eye region with described red pixel point determining unit 22.
Second acquisition unit 24, is connected with described correction unit 23, for obtaining the mistake correction region in the red eye region after correcting based on texture analysis.
Suppressing unit 25, be connected with described second acquisition unit 24, for utilizing medium filtering, described region of by mistake correcting being suppressed.
The course of work removing the device of blood-shot eye illness described in the present embodiment can be carried out see the method for above-mentioned removal blood-shot eye illness, repeats no more herein.
In sum, technical scheme of the present invention at least has following beneficial effect:
For automatically removing the mode of blood-shot eye illness, owing to first determining blood-shot eye illness sample point and the pixel searched in preset range, and the red pixel point determined according to color distance in preset range, therefore, reduce loss when detecting blood-shot eye illness and false detection rate, and then the leakage correction rate also reduced when removing blood-shot eye illness and by mistake correction rate.For manually removing the mode of blood-shot eye illness, owing to only needing to determine blood-shot eye illness sample point and then search in the preset range comprising described blood-shot eye illness sample point, and detect and remove blood-shot eye illness without the need to manually pointwise, therefore, decrease manual detection and remove the number of times of seeing red, improve the efficiency detecting blood-shot eye illness and remove blood-shot eye illness to a great extent.
Further, by centered by described blood-shot eye illness sample point, search for the pixel in predetermined neighborhood, with based on color distance determination red pixel point, implement comparatively simple, calculated amount is little, and the search speed accelerated red pixel point, this improves the efficiency detecting blood-shot eye illness, and then also correspondingly improve the efficiency removing blood-shot eye illness.
Further, after obtaining the blood-shot eye illness sample point in eyes image, color space conversion is carried out to described eyes image, calculate color distance between the pixel in described blood-shot eye illness sample point and preset range based on different color spaces to determine red pixel point.Because color space is different, therefore the threshold value of color distance when determining red pixel point is also different, and then accurately can detect red eye region in different color space, reduce loss when detection is seen red and false drop rate, also reduce leakage correction rate when removing blood-shot eye illness and miss correction rate.Further, due to different color space can be suitable for, thus there is very large dirigibility.
Further, to the pixel in the preset range searched, based on described color distance determination black pixel point, and described black pixel point is utilized to correct the red eye region detected adaptively, thus better to the error-correcting effect of red eye region.
Although the present invention with preferred embodiment openly as above; but it is not for limiting the present invention; any those skilled in the art without departing from the spirit and scope of the present invention; the Method and Technology content of above-mentioned announcement can be utilized to make possible variation and amendment to technical solution of the present invention; therefore; every content not departing from technical solution of the present invention; the any simple modification done above embodiment according to technical spirit of the present invention, equivalent variations and modification, all belong to the protection domain of technical solution of the present invention.