views:

2468

answers:

7

I need to implement red eye reduction for an application I am working on.

Googling mostly provides links to commercial end-user products.

Do you know a good red eye reduction algorithm, which could be used in a GPL application?

+2  A: 

The simplest algorithm, and still one that is very effective would be to zero out the R of the RGB triple for the region of interest.

The red disappears, but the other colors are preserved.

A further extension of this algorithm might involve zeroing out the R value for only the triples where red is the dominant color (R > G and R > B).

japollock
+2  A: 

If no one else comes up with a more direct answer, you could always download the source code for GIMP and see how they do it.

Bill the Lizard
+2  A: 

You can try imagemagick -- some tips on this page for how to do that

http://www.cit.gu.edu.au/~anthony/info/graphics/imagemagick.hints

search for red eye on the page

Lou Franco
+4  A: 

First you need to find the eyes! The standard way would be to run an edge detector and then a Hough transform to find two circles of the same size, but there might be easier algorithms for simply finding clusters of red pixels.

Then you need to decide what to replace them with, assuming there is enough green/blue data in the image you could simply ignore the red channel.

OpenCV is a very good free library for image processing, it might be overkill for what you want - but has a lot of examples and a very active community. You could also search for object tracking algorithms, tracking a coloured object in a scene is a very similair and common problem.

Martin Beckett
+2  A: 

The open source project Paint.NET has an implementation in C#.

JC
I don't think the source is attainable any more.
John T
+3  A: 

a great library to find eyes is openCV. it is very rich with image processing functions. see also this paper

kiwi
+10  A: 

I'm way late to the party here, but for future searchers I've used the following algorithm for a personal app I wrote.

First of all, the region to reduce is selected by the user and passed to the red eye reducing method as a center Point and radius. The method loops through each pixel within the radius and does the following calculation:

//Value of red divided by average of blue and green:
Pixel pixel = image.getPixel(x,y);
float redIntensity = ((float)pixel.R / ((pixel.G + pixel.B) / 2));
if (redIntensity > 1.5f)  // 1.5 because it gives the best results
{
    // reduce red to the average of blue and green
    bm.SetPixel(i, j, Color.FromArgb((pixel.G + pixel.B) / 2, pixel.G, pixel.B));
}

I really like the results of this because they keep the color intensity, which means the light reflection of the eye is not reduced. (This means eyes keep their "alive" look.)

Benry