R
R
Ramir12014-01-15 08:20:59
JavaScript
Ramir1, 2014-01-15 08:20:59

Is there an algorithm for removing red eyes in a photo?

Good afternoon!
Tell me the algorithm for removing red eyes, if the area with the eye is selected?
That is, we have a rectangle with an eye. Then we sort through all the pixels and ...
I will implement it in JavaScript, but it would be interesting to know the formula.
That's what we have now, but not all red colors are captured.

var p = imageData.width * imageData.height, pix = p * 4, r, g, b;
     while (p--) {
           pix -= 4;
           r = data[pix];
           b = data[pix + 1];
           g = data[pix + 2];
if (parseFloat(r / (g + b) / 2) > 0.4) {
           data[pix] = Math.round((g + b) / 2);
     }
}

Thanks to!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2014-01-15
@OLS

Try to convert to HSV and make a selection on the "red" range H ?

R
Ramir1, 2014-01-15
@Ramir1

can you give me some formula? How to define red? How much to select?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question