This application relates to the following applications, each of which is incorporated herein by reference: U.S. patent application Ser. No. 10/424,419, filed Apr. 28, 2003, by Huitao Luo et al., and entitled “DETECTING AND CORRECTING RED-EYE IN A DIGITAL IMAGE;” and U.S. patent application Ser. No. 10/653,019, filed on even date herewith by Huitao Luo et al., and entitled “DETECTING AND CORRECTING RED-EYE IN AN IMAGE”.
This invention relates to systems and methods of detecting and correcting redeye in an image.
Redeye is the appearance of an unnatural reddish coloration of the pupils of a person appearing in an image captured by a camera with flash illumination. Redeye is caused by light from the flash reflecting off blood vessels in the person's retina and returning to the camera.
Several techniques have been proposed to reduce the redeye effect. A common redeye reduction solution for cameras with a small lens-to-flash distance is to use one or more pre-exposure flashes before a final flash is used to expose and capture an image. Each pre-exposure flash tends to reduce the size of a person's pupils and, therefore, reduce the likelihood that light from the final flash will reflect from the person's retina and be captured by the camera. In general, pre-exposure flash techniques typically only will reduce, but not eliminate, redeye.
A large number of image processing techniques have been proposed to detect and correct redeye in color images. In general, these techniques typically are semi-automatic or automatic. Semi-automatic redeye detection techniques rely on human input. For example, in some semi-automatic redeye reduction systems, a user must manually identify to the system the areas of an image containing redeye before the defects can be corrected. Many automatic redeye reduction systems rely on a preliminary face detection step before redeye areas are detected. A common automatic approach involves detecting faces in an image and, subsequently, detecting eyes within each detected face. After the eyes are located, redeye is identified based on shape, coloration, and brightness of image areas corresponding to the detected eye locations. In general, face-detection-based automatic redeye reduction techniques have high computation and memory resource requirements. In addition, most of the face detection algorithms are only able to detect faces that are oriented in an upright frontal view; these approaches cannot detect faces that are rotated in-plane or out-of-plane with respect to the image plane.
Embedded systems are processing systems that often are incorporated into a larger system, such as a device, an appliance, or a tool. An embedded system usually includes computer hardware, software, or firmware that provides limited processing power and usually has access to limited memory resources. A computer printer typically includes an embedded system that provides a basic user interface that allows a user to manually push buttons, and to start and stop printing, and to otherwise control the printer and examine its status. Any solution for implementing functionality in an embedded application environment must operate within the limited processing power constraints and the limited memory resource constraints of the embedded system. As a result, implementing functionality, such a detecting and correcting redeye in an image is a challenge in an embedded application environment.
The invention features systems and methods of detecting and correcting redeye in an image.
In one aspect, the invention features a scheme (systems and methods) for processing an input image. In accordance with this inventive scheme, the input image is sub-sampled to generate a thumbnail image, redeye pixel areas are detected in the thumbnail image.
In another aspect, the invention features a scheme (systems and methods) for processing an input image having lines of pixels with original color values. In accordance with this inventive scheme, one or more redeye pixel areas corresponding to respective areas in the input image are detected. Each pixel in the input image corresponding to the detected redeye pixel areas is classified as a redeye pixel or a non-redeye pixel on a line-by-line basis without reference to pixels in adjacent lines. The original color values of pixels in the input image classified as redeye pixels are corrected.
Other features and advantages of the invention will become apparent from the following description, including the drawings and the claims.
In the following description, like reference numbers are used to identify like elements. Furthermore, the drawings are intended to illustrate major features of exemplary embodiments in a diagrammatic manner. The drawings are not intended to depict every feature of actual embodiments nor relative dimensions of the depicted elements, and are not drawn to scale.
In general, the redeye detection and correction embodiments described herein may be incorporated into any system or method in which such functionality is desired. These embodiments, however, are particularly suitable for incorporation into embedded environments, which typically have limited processing and memory resources.
I. System Overview
In response to user confirmation to proceed with printing, redeye correction module 16 maps the detected redeye areas 18 to a version of the input image scaled to a prescribed output resolution (step 54). Redeye correction module 16 corrects redeye in the input image at the prescribed output resolution to generate the corrected image 20 (step 56). As explained in detail below, in some implementations, the redeye correction module 16 corrects redeye on a line-by-line basis without reference to pixel data in adjacent lines. In this way, redeye correction module 16 may operate in embedded environments in which one or both of the processing resources and the memory resources are severely constrained, while still providing exceptional real-time redeye correction results.
In some implementations, the redeye correction module 16 automatically corrects the detected redeye pixel areas without awaiting user confirmation.
As explained in detail below, redeye detection module 14 detects redeye regions in a way that compensates for errors and other artifacts that are inherently introduced by the sub-sampling, compressing, and scaling steps so that redeyes in the input image area detected with high accuracy. In addition, redeye correction module 16 corrects redeye pixels detected in input image 12 in a way that appears natural and that handles special classes of redeye, such as glowing redeyes, that are detected by the redeye detection module 14.
II. Detecting Redeye Pixel Areas
Referring to
A. Global Screening
Global Candidate Redeye Pixel Area Detecting
Referring to
where r, g, and b are red, green, and blue component pixel values of input image 12, respectively, α, β and γ are weighting factors, and d is a prescribed constant with a value selected to avoid singularities and to give higher weights to bright pixels. In one exemplary implementation in which each of r, g, and b have values in the range of [0,255], α=255, β=γ=0, and d has a value of 8. As shown in
In one exemplary implementation, pixel redness measures (R0) for redness map 60 are computed as follows: R0=(255·r)/(r+g+b+d) when r>g, r>b; otherwise R0=0. Other representative redness measures (R1, R2, R3, R4) that may be used to compute redness map 60 are expressed in equations (2)-(5) below:
where r, g, and b are red, green, and blue component pixel values of input image 12, respectively, and Cr and Cb are the red and blue chrominance component pixel values of the input image 12 in the YCbCr color space.
Referring back to
The two-dimensional redness filter is defined with respect to a central kernel pixel area and a pixel area surrounding the kernel pixel area. As shown in
Given the integral image S, the sum of image pixels within an arbitrary rectangle (x1, x2) and (y1, y2) can be obtained by:
Sum(x1, x2, y1, y2)=S(x2, y2)−S(x2, y1)−S(x1, y2)+S(x1, y1) (8)
Based on equation (8), the average value of the pixels within an arbitrary rectangle can be obtained efficiently with three integer additions/subtractions and one division. In the above-described implementation, the average pixel values APVR1 and APVR2over areas AR1 and AR2, respectively, are computed and the two-dimensional FIR of equation (6) is applied to the redness map 60 to generate the following redness score (RS1) for each corresponding region of the redness map:
RS1=APVR1−APVR2 (9)
In another implementation, a nonlinear FIR filter is applied to the redness map 60 to generate the following redness score (RS2) for each corresponding region of the redness map:
where w is a constant weighting factor, which may be determined empirically. In this equation, APVR1 represents the absolute redness of the central kernel square AR1, and (APVR1/APVR2) represents the contrast between the central square AR1 and the surrounding area AR2. The redness score RS2 of equation (10) formulates how a red dot region must be sufficiently red while also exhibiting high contrast against its surrounding regions. In the above-described implementations, redeye areas are approximated by square candidate pixel areas. In other embodiments, redeye areas may be approximated by different shapes (e.g., rectangles, circles or ellipses).
Referring to
In some embodiments, a number of fast heuristics are applied to the candidate redeye areas in the final binary map 88 to eliminate false alarms. Known redeye pixel techniques may be used to eliminate false alarms (i.e., candidate redeye pixel areas that are not likely to correspond to actual redeye areas), including aspect ratio inspection and shape analysis techniques. For example, in some implementations, atypically elongated candidate redeye areas are removed from the candidate redeye pixel area map 64.
Global Candidate Redeye Pixel Area Verification
Referring to
Initially, small candidate redeye pixel areas are processed in order to preserve small redeye areas in the candidate redeye pixel area map 64 (step 90). As shown in
Referring back to
Next, the average redness of each enlarged candidate redeye pixel area 108 is compared with those of its eight neighboring boxes 110, each of which has the same size as the corresponding enlarged candidate redeye area 108 (see
MIN (CenterAverage−NeighborAverage[k])<CMIN (11)
where k=1, 2, . . . , 8, MIN is a function that computes the minimum of the computed contrast measures, and CMIN is an empirically determined minimum redness contrast threshold. If the condition of equation (11) is not satisfied, the candidate redeye area under test is sent for further verification.
Referring to
G1=0.299×r+0.587×g+0.114×b (12)
G2=0.299×(255−r)+0.587×g+0.114×b (13)
where r, g and b are red, green and blue values for each pixel within the region and the grayscale values are obtained for each pixel and averaged over the region. In this grayscale mapping, G1 is a conventional grayscale mapping computed from (r, g, b), whereas G2 is the grayscale mapping computed from (255−r, g, b). The grayscale mapping G2 handles instances of “glowing” redeyes (i.e., when a redeye are appears much brighter than its surroundings). In accordance with the above approach, such atypical “glowing” redeyes are mapped to a grayscale channel that allows them to be treated in the same way as typical redeyes.
A known search technique is performed over the computed grayscale map 70 to locate one or more areas corresponding to irises. In the illustrated embodiment, an iris area is represented as a square. In this embodiment, each candidate redeye pixel area 108 remaining after the above-described redness verification process is assumed to correspond to a respective pupil area, which has a size that is equal to or smaller than the corresponding iris area 114 (shown as a square in
Once the final size of the grayscale iris area (or box) 114 is determined, the grayscale contrast between the final grayscale iris area 114 and the surrounding boxes (0-7) are used to verify that the iris area corresponds to an actual iris in the thumbnail image 44. As illustrated in
{N(k%8), N((k+1)%8), . . . , N((k+4)%8)} (14)
where % is the modulo operator and k=0, 1, . . . , 7. This enables situations in which a redeye is located at the edge of a face in the thumbnail image 44 to be handled. Out of the eight subsets of surrounding boxes, the most uniform subset 120-134 is selected as the basis for computing a measure of grayscale contrast (CGRAY) with the central candidate box. That is:
CGRAY=AVER{N(m%8),N((m+1)%8), . . . ,N((m+4)%8)}/N(8) (15)
where m=argmin STD {N(k%8), N((k+1)%8), . . . , N((k+4)%8)}, k=0, 1, . . . 7, AVER{a(1), a(2), . . . , a(n)} represents the average of array {a(k)}, and STD{a(1), a(2), . . . , a(n)} represents the standard deviation of array {a(k)}. Based on the grayscale contrast computation of equation (15), candidate redeye pixel areas having corresponding candidate iris areas with computed contrast measures below an empirically determined threshold are removed from the candidate redeye pixel area map 64.
B. Local Verification
Referring back to
The segmentation verification filter is applied to the redness map 60 to ensure that each of the candidate redeye pixel areas 108 exhibits high contrast relative to surrounding neighboring areas (step 73;
As shown in
where R1, R2, . . . , Rn denote the redness of the n pixels located within the given candidate redeye pixel area, and the AVE(.) function computes the average and the MED(.) function computes the median of an input array.
Exemplary binarized regions of redness map 60 corresponding to neighborhood pixel area 142 are shown in
Candidates may be filtered from the candidate redeye pixel area map 64 based on a skin tone verification process modeled at least in part on the observation that a redeye is a non-skin-tone region (i.e., the eye) surrounded by a skin tone region (i.e., the face). In this process, pixels in the thumbnail image 44 are classified as corresponding to either a skin tone area or a non-skin tone area. Any skin tone classification technique may be used to classify pixels of thumbnail image 44.
As is illustrated in
Referring to
CS(k)=s(k%8)+s((k+1)%8)+s((k+2)%8)+ . . . +s((k+4)%8), k=0,1, . . . , 7 (17)
A given candidate redeye pixel area passes this skin tone verification test (i.e., is not filtered from candidate redeye pixel area map 64) only if the maximum of CS(k) is above a predefined threshold.
Referring back to
In above-described process, a pairing candidate is detected for each current redeye candidate by searching for other candidate redeye pixel areas in the candidate redeye pixel area map 64 in neighboring areas that are located within a fixed distance range with respect to the current candidate (line 3 above). Referring to
r1=(h+w)×1.5 (18)
r2=(h+w)×6.5 (19)
In some embodiments, paired candidate redeye pixel areas also are required to be similar in size. For example, in the pseudo code implementation of the pairing local verification process described above (line 5), the size of two candidate redeye pixel areas are compared to make sure that they are similar enough. For example, in some embodiments, if the candidate redeye pixel areas being paired are squares of lengths s1 and s2, respectively, and s1 ≦s2, then the two candidate redeye pixel areas are labeled as pairs if the ratio s2/s1 is less than a prescribed mismatch threshold. In one exemplary implementation, the mismatch threshold is set to a value of 2.6.
The texture pattern verification step at the line 6 of the above pseudo code verifies that the grayscale texture of a neighborhood template defined by the two pairing candidates is similar enough to a human eye pattern. Referring to
Referring to
In one embodiment, the template size is set to 7 by 21 pixels (i.e., d=7 in
During the pair matching verification process, the pair matching filter identifies the neighborhood region 158 (
The generated statistical model (block 170) is tested using the statistical model generated in the training stage (block 184) to verify whether the candidate pair region corresponds to an eye pattern or not (block 172). For example, in one implementation, two distance features are computed to measure its similarity to the trained reference eye pair pattern: a distance within the low-dimension eigenvector space, and a distance from the low-dimension eigenvector space. See, for example, K.-K. Sung, Learning and example selection for object and pattern detection, Ph.D. thesis, MIT Al Lab, 1996, which is incorporated herein by reference.
C. Redeye Detection at Multiple Resolutions
Referring to
The embodiments of
III. Redeye Correction
A. Mapping Detected Redeye Pixels
In some implementations, the mapped detected redeye pixel areas are enlarged to compensate for errors that might occur as a result of the inaccuracy inherent in the quantization processes involved in mapping areas from the resolution of the thumbnail image 44 to the output resolution. In these implementations, the horizontal dimension and the vertical dimension of the mapped redeye pixel areas are enlarged by an enlargement amount that decreases with the original horizontal and vertical dimension of the mapped redeye pixel areas. For example, in one implementation, the dimensions of the mapped redeye pixel areas are enlarged as follows:
As shown in
B. Classifying Redeye Pixels
Referring back to
For each mapped redeye pixel area 201 (step 210), if the mapped redeye pixel area is not atypically large (step 212), pixels in the mapped redeye pixel area are classified as candidate redeye pixels based on skin tone coloration (step 214). In one implementation, a mapped redeye pixel area 201 is considered to be atypically large if any dimension (e.g., width or height) is larger than 10 pixels. If the redeye pixel area 201 is atypically large (step 212) but the size of the corresponding grayscale iris area relative to the mapped redeye pixel area is not atypically large (step 216), then pixels in the mapped redeye pixel area also are classified as candidate redeye pixels based on skin tone coloration (step 214). In one implementation, a mapped grayscale iris area is considered to be atypically large if its grayscale iris area is 50% larger than its corresponding mapped redeye pixel area 201. In the skin tone classification process, pixels in the input image 12 are classified as corresponding to either a skin tone area or a non-skin tone area using any type of skin tone classification or segmentation technique.
If the redeye pixel area 201 is atypically large (step 212) and the size of the corresponding grayscale iris area relative to the mapped redeye pixel area is atypically large (step 216), then it is assumed that the mapped redeye pixel area 201 is completely separated from the eyelid and surrounding skin tone regions of a person's face. In this case, the skin-tone-coloration-based pixel classification step (step 214) is omitted for the mapped redeye pixel area 201 being processed.
Candidate redeye pixels in the mapped redeye pixel areas are classified based on a pixel-based redness classification process (step 218). In one implementation, candidate redeye pixels in input image 12 having color components satisfying the following criteria are classified as candidate redeye pixels, and other candidate redeye pixels are filtered from the candidate set:
Cr>128,
Cr>Cb, and
Cr>Y, (20)
where Cr, Cb and Y are the color components of the input image pixels represented in the YCbCr color space.
After pixels in a mapped redeye pixel area have been classified based on a redness threshold (step 218), candidate redeye pixels are classified line-by-line based on horizontal coherence (step 220). For example, in one implementation, if a given candidate redeye pixel is located adjacent to a pixel previously classified as a candidate redeye pixel and has a redness value greater than an empirically determined threshold, then the given pixel also is classified as a candidate redeye pixel.
Referring to
In some embodiments, the inner bounding region 222 is centered at the center of the mapped redeye pixel area 201 being processed and has dimensions (e.g., width and height) that correspond to the average of the dimensions of the mapped redeye pixel area 201 and its corresponding grayscale iris area 226. That is, the width of the inner bounding region 22 equals one-half of the sum of the width of the mapped redeye pixel area 201 and the width of the corresponding grayscale iris area 226. Similarly, the height of the inner bounding region 22 equals one-half of the sum of the height of the mapped redeye pixel area 201 and the height of the corresponding grayscale iris area 226. The outer bounding region 224 also is centered at the center of the mapped redeye pixel area 201. In one implementation, the dimensions of the outer bounding region are 50% larger than the corresponding dimensions of the inner bounding region 222 if the inner bounding region 222 is larger than two pixels; otherwise, the dimensions of the outer bounding region are 200% larger than the corresponding dimensions of the inner bounding region 222.
In addition to redness and skin-tone coloration, pixels between the inner and outer bounding regions 222, 224 are classified based on application of a grayscale threshold to the grayscale values of the pixels as follows. In some implementations the green channel in RGB color space is used to approximate the grayscale values of pixels. In one implementation, the applied grayscale threshold corresponds to the average of the average of the grayscale values within the inner bounding region 22 and the average of the grayscale values between the inner and outer bounding regions 222, 226. For example, if the average of the gray values within the inner bounding region 222 is 90 and the average of the gray values outside the inner bounding region 222 but within the outer bounding region is 224, then the average gray value 105 ((90+120)/2) is the grayscale threshold used to segment the pixels between the inner and outer bounding regions 222, 224. Pixels between the inner and outer bounding regions 222, 224 having grayscale values below the computed grayscale threshold are classified as candidate redeye pixels.
All candidate redeye pixels within the outer bounding region 224 are classified as redeye pixels based on connectivity, with stringent requirements to remove fragments, outliers, and noise. In some embodiments, the stripe-based segmentation approach described in the attached Appendix is used to segment redeye pixels. Referring to
C. Re-Coloring Redeye Pixels
Referring back to
Initially, color correction darkening factors and weights are computed for the redeye pixels to be corrected. The darkening factors and weights indicate how strongly original color values of redeye pixels are to be desaturated (i.e., pushed towards neutral or gray values). As explained in detail below, these two factors vary with pixel location relative to the center of the redeye pixel correction region 228 to give a smooth transition between the pixels in the input image 12 that are changed and those that are not to avoid artifacts.
The darkening factors are computed based on luminance (or gray) values of the input image pixels. In one implementation, the darkening factors are computed based on the graph shown in
The weights (wt) are set for a given redeye pixel based on the number of redeye pixels that neighbor the given pixel. For example, in one implementation, the weights may be set as follows:
where redeye neighbors corresponds to the number of redeye pixels that neighbor the given pixel being assigned a weighting factor. In this formulation, redeye pixels near the center of the redeye pixel correction region 228 are assigned higher weights than redeye pixels near the boundaries of the redeye pixel correction region 228.
Color values of redeye pixels are corrected by desaturating and darkening original color values in accordance with the computed darkening and weight factors. In some RGB color space implementations, the color values (red, green, blue) of each input image pixel identified as a redeye pixel are corrected to the final color values (R1, G1, B1) as follows:
In these embodiments, it is assumed that the color components of the input image pixels are defined with respect to the RGB color space. These embodiments readily may be extended to other color space representations. It is noted that if wt=1, pixel values are pushed all the way to neutral (i.e., the pixel values are set to the same shade of gray). If wt=0, none of the color component values of the corresponding pixel are changed. In this implementation, lower luminance pixels (i.e., smaller green values) generally are pushed darker than higher luminance pixels, which have their luminance unchanged.
IV. Conclusion
Other embodiments are within the scope of the claims.
This Appendix describes a method of segmenting foreground pixels from background pixels in a binary image (or pixel map) by scanning the binary map in stripes of one or more pixel lines and tracking objects containing foreground pixels connected across stripes. In on implementation of this approach, foreground pixels are assigned a value of “1” and background pixels are assigned a value of “0”. The foreground pixels are segmented into objects by labeling the foreground pixels such that all of the connected pixels have the same label, and each label is used to represent one object.
Experiments have shown that the following method is three to five times faster than a typical stack-based segmentation approach. In addition, in some implementations, this method is scalable in terms of speed and memory requirements.
I. Definitions and Data Structures
The strip-based segmentation method is described with reference to the follows terms and data structures.
A stripe is defined as a consecutive horizontal run of foreground pixels.
In this definition, the object_pointer data field point to the object to which the corresponding stripe belongs, and the next_stripe_pointer field links multiple stripes into a linked list.
For a stripe object “S”, a function O=OBJECT(S) is defined to return the object_pointer field of S. That is, object O is the object to which stripe S belongs.
An OBJECT is a logic data structure that represents an object defined in image analysis. An object has the following attributes: a containing rectangle, its total size, and a pointer that links to stripes that belong to the object. A pseudo code definition of an OBJECT structure is as follows.
The stripe_pointer field points to the header of a linked list of STRIPE objects, which belong to this object, and the next_object_pointer field links multiple objects into a linked list.
For two objects O1 and O2, a merge function is defined as:
O=MERGE_OBJECT(O1, 02)
The MERGE_OBJECT function merges two objects O1, O2 into one object O. The resulting object O has the combined size and a containing rectangle encompassing the containing rectangles of O1 and O2. In addition, the stripes belonging to O1 and O2 are merged into one linked list in O.
A CONTAINER is a linked list of OBJECT data structures. For a container C, an ADD(C,O) operation adds an OBJECT O to container C, and a DELETE(C,O) operation deletes an OBJECT O from container C.
II. Stripe-Based Segmentation
In this approach, an image is scanned line-by-line. At each scan line, a number of stripes are defined, and their connectivity with stripes on the adjacent previously-scanned line is analyzed. If a given stripe is connected with any stripe on the adjacent previously-scanned line, the object associated with the given stripe is extended to the current scan line.
In this approach, the size and containing rectangle of each object are determined in a one-pass scan of the image. A second pass is used to label each pixel.
The following pseudo code describes one implementation of the stripe-based segmentation method. In this description, the input is a binary image and the output is a container “C”, which contains all the generated objects.
Number | Name | Date | Kind |
---|---|---|---|
5432863 | Benati et al. | Jul 1995 | A |
6009209 | Acker et al. | Dec 1999 | A |
6016354 | Lin et al. | Jan 2000 | A |
6292574 | Schildkraut et al. | Sep 2001 | B1 |
20020150292 | O'Callaghan | Oct 2002 | A1 |
20020176623 | Steinberg | Nov 2002 | A1 |
20030044063 | Meckes et al. | Mar 2003 | A1 |
20040037460 | Luo et al. | Feb 2004 | A1 |
20040196503 | Kurtenbach et al. | Oct 2004 | A1 |
Number | Date | Country |
---|---|---|
0635972 | Jan 1995 | EP |
Number | Date | Country | |
---|---|---|---|
20050047656 A1 | Mar 2005 | US |