After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 140533 - Red-eye removal tool
Red-eye removal tool
Status: RESOLVED FIXED
Product: gthumb
Classification: Other
Component: general
2.9.x
Other All
: High enhancement
: ---
Assigned To: Paolo Bacchilega
Paolo Bacchilega
: 164561 325577 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2004-04-19 18:45 UTC by Michael Knepher
Modified: 2006-11-04 16:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
New red eye removal edition feature. (12.57 KB, patch)
2005-12-30 01:19 UTC, Nelson Benitez
none Details | Review
New icon (677 bytes, image/png)
2005-12-30 01:21 UTC, Nelson Benitez
  Details
'improved' redeye removal patch (30.71 KB, patch)
2006-03-06 04:37 UTC, michal
none Details | Review
stand-alone redeye fix tool (4.12 KB, application/x-compressed-tar)
2006-03-08 20:52 UTC, michal
  Details
stand-alone redeye fix tool (4.12 KB, application/x-compressed-tar)
2006-03-08 22:07 UTC, michal
  Details
Adds redeye-reduction tool to gthumb. (33.21 KB, patch)
2006-10-24 13:18 UTC, Michael Chudobiak
none Details | Review
cleaned up redeye tool patch (34.65 KB, patch)
2006-10-24 23:10 UTC, Michael Chudobiak
none Details | Review
redeye, v3 (34.65 KB, patch)
2006-10-26 19:12 UTC, michal
none Details | Review
redeye, v4 (34.78 KB, patch)
2006-10-27 12:39 UTC, Michael Chudobiak
none Details | Review
header file for redeye removal (2.33 KB, patch)
2006-11-04 12:59 UTC, manuel braga
none Details | Review

Description Michael Knepher 2004-04-19 18:45:48 UTC
Would some-sort of red-eye removal tool be possible to include in gthumb?
Comment 1 Alan Horkan 2004-09-13 21:11:50 UTC
Adobe Photoshop Album and Picasa from Google and many other Thumbnail browsers
include simple red-eye removal tools.  Seems like a good idea to me. 
Comment 2 Per Jonsson 2004-11-24 02:13:55 UTC
That would be a killer feature and make it a great tool for digital photos.
Comment 3 David Hassler 2005-01-10 04:51:36 UTC
I would also like to log some support for this feature request, it would be a
huge timesaver.  
Comment 4 Sebastien Bacher 2005-01-19 10:44:57 UTC
*** Bug 164561 has been marked as a duplicate of this bug. ***
Comment 5 Kjetil Wikestad 2005-01-30 17:27:03 UTC
Red eye removal tool is the only feature I miss from gthumb. Now if only gthumb
could be set as the default image viewer in gnome...
Comment 6 Nelson Benitez 2005-10-04 11:17:00 UTC
I also would like to have this feature in gthumb.
Comment 7 Nelson Benitez 2005-12-30 01:19:16 UTC
Created attachment 56529 [details] [review]
New red eye removal edition feature.

This adds a red eye removal functionality, the interesting bits are taken from f-spot who took it from flphoto[1], which seems it's the only open source implementation of this feature. If you read the link you see this is not perfect, It works well with photos that don't have red colors apart from the eyes, maybe a future patch could make this apply to a manual-defined area of the image instead of the whole image, that would be cool.

I'll also attach the icon I've come for this new action.

[1] http://www.easysw.com/~mike/flphoto/images.html#redeye
Comment 8 Nelson Benitez 2005-12-30 01:21:02 UTC
Created attachment 56530 [details]
New icon
Comment 9 Paolo Bacchilega 2006-01-04 22:54:16 UTC
*** Bug 325577 has been marked as a duplicate of this bug. ***
Comment 10 Paolo Bacchilega 2006-01-05 10:14:03 UTC
thanks for the patch, I'll take a look at it in the next days.
Comment 11 michal 2006-03-03 06:10:58 UTC
I looked at the redeye removal in f-spot at one point a while ago and found it not that great.  There is a redeye plugin for the gimp that uses a very slightly more sophisticated algorithm.  It has the same problem - that it picks up undesired regions, but it seems to me the quality of the final image is better with the gimp plug-in version.

It seems like this algorithm combined a tool like the crop selection to confine the area, would do the trick nicely - though circles might be better than a rectangle.

The gimp plug-in is available here
http://registry.gimp.org/file/redeye.c?action=view&id=4215
Comment 12 michal 2006-03-06 04:37:57 UTC
Created attachment 60738 [details] [review]
'improved' redeye removal patch

Here is a new patch with an expanded redeye removal algorithm.

This patch does a first pass through the image looking for candidate pixels
based on their color (same as the gimp plugin), but adds a couple more constraints.

Then it finds regions of candidate pixels, and does several tests to decide if the region should be classified as a red eye or not.

There are a number of tuneable parameters that affect the tests.

It has sort of a debug mode that spits out all reasons why regions are eliminated, and then marks all the regions it keeps as pink with blue boundaries so they are easy to find.

This works very well in images I've tested it on - there is a dramatic reduction in the number of false positives, and I think the eyes look a little more natural than in f-shot algorithm.

What I think would be the best, would be to have two menu items:  one for auto redeye removal, that would do something like what this patch now does, and a second item for a 'guided' removal.  I see two possibilities for guided removal:

1) it could then allow the user to set a region inside which a dramatically simplified (more agressive) version of this auto routine would work.

2)  it could let the user simply click on (or close to) the redeye.  The find_region routine here could then be used to fix the redeye. 

I'd be happy to write the fix and detect code if someone else wants to write the ui and infrastructure for one of those options. 

It seems that improving the auto version is probably a lot of work.
I can imagine trying to collect masses of RGB values from as many different redeyes as possible to see if a volume in some colorspace can be selected more sanely, but at the end of the day, there will always be images that can't be fixed automatically.  I think a user-guided version would be best.
Comment 13 michal 2006-03-08 20:52:20 UTC
Created attachment 60937 [details]
stand-alone redeye fix tool

Here's a stand-alone application that does more or less what I'd like to see
built in.

you start this program up with:
gredeye <image>
then you click on the red regions to fix.
When you close the windows it prompts for a file name to save to 
(if it did any fixing).
Comment 14 michal 2006-03-08 22:07:20 UTC
Created attachment 60939 [details]
stand-alone redeye fix tool

sorry - this version should actually build.
Comment 15 Michael Chudobiak 2006-09-13 13:17:42 UTC
Nice tool! I like the click-to-remove-demon-eye feature! What needs to happen to get a full patch for gthumb, based on your tool?

Red-eye removal is desperately needed in gthumb.
Comment 16 michal 2006-09-13 16:12:33 UTC
Well - much of it should be cut-and-paste.  what's needed is a decision on how to do the UI as part of gthumb.  Activating 'red-eye mode' from the image menu seems straightforward.  But then the question is how to deactivate?  A dialog with an 'end red-eye mode' button could pop up, or you could right-click on the image, or ...?  Either way, I think you'd want to have some obvious indication to the user that they are in red-eye removal mode.

Another thing that's needed is a way to return mouse-click positions on the image to the red-eye routine.  I haven't looked through the gthumb source carefully, but I don't think there is a facility for this built in.  No idea how much trouble it would be.

One though I had on improving my earlier program was to have the tool's aggressiveness in deciding what's red increase with the number of click's its captured that failed to find a red region - so if it doens't fix the red eye on the first click, you click again and again till it fixes it.

There is a tuneable parameter (THRESHOLD) that could be incremented on each failed mouse click.  If one wanted to make the whole thing a little fancier, an easy-to-reach 'undo' function would be nice - to uncorrect the last red-eye removal, and maybe a way to reset the threshold.

Comment 17 Michael Chudobiak 2006-09-13 16:48:03 UTC
I think that a dialog box should pop up, indicating that red-eye removal mode is active. It could have three controls:

1 - Exit red-eye mode
2 - Undo the last operation
3 - A threshold slider, defaulted at "50%" (or whatever you want to call it).

it could also have:

4 - A text area explaining how to use the tool
5 - Maybe an x,y coordinate readout of the mouse position

I think at this point just getting any red-eye tool into gthumb would be great. Fancy auto-tuning could come later.

What do you think?
Comment 18 Michael Chudobiak 2006-09-15 12:22:34 UTC
A patch based on gredeye is in development. Something should be available in a few weeks...
Comment 19 Nelson Benitez 2006-09-15 13:41:50 UTC
Thanks Michal and Michael! for working on this, I hope to help by testing that new patch. 

GIMP already implemented the red-eye removal tool in its main GUI (based on its plugin), the patch and discussion for that is on bug 91795. I don't have a recent GIMP to see how they implemented the UI part, but it could be useful to see how they did to take ideas.
Comment 20 Michael Chudobiak 2006-10-24 13:18:08 UTC
Created attachment 75299 [details] [review]
Adds redeye-reduction tool to gthumb.

OK, here is a full redeye-reduction tool patch that can be applied against CVS HEAD. To test it, check out gthumb from cvs (CVSROOT=:pserver:anonymous@anoncvs.gnome.org:/cvs/gnome;export CVSROOT; cvs -z3 co gthumb;) and download and apply the patch (patch -p1 < redeye-v1.patch).

To use the tool, open an image from the browser, and use Image > Redeye Reduction. Click on the red eyes. Press OK when done. Press the save icon on the toolbar, or save it when gthumb asks you too after you navigate away from the image.

I think there are some bugs in the gthumb save code, so please keep your eyes open for assertion errors and the like. Bug 363974 is also of concern.

This patch is based on the standalone program "gredeye" by Carl Michal, which in turn borrows some code from gimp. Marty Leisner integrated gredeye into gthumb, and I tidied up the user interface a bit.

Anyway... please test!

- Mike
Comment 21 michal 2006-10-24 18:15:28 UTC
Works really well for me!  Thanks for doing this.

If at some point I can find some time, I may try to implement a progressive aggressiveness factor - so if it doesn't fix a spot the first time you click on it, you can click again and again, and eventually it will fix it.

I would suggest changing the name from "Redeye Reduction" to "Redeye Removal"
Comment 22 Michael Chudobiak 2006-10-24 18:52:27 UTC
I'll change the "Reduction" to "Removal", and add a "Help" button + manual docs in v2, coming soon.

- Mike
Comment 23 Michael Chudobiak 2006-10-24 23:10:19 UTC
Created attachment 75336 [details] [review]
cleaned up redeye tool patch

v2 of the previous patch. Requires the icon file in patch 56530 in libgthumb/icons.

v2 renames the tool to "Redeye Removal", removes the "Reset" button for a simpler UI, uses more stock gtk buttons, and adds the icon.

Paolo, can you commit this to HEAD for easier testing? Three new files have to be added:

src/dlg-redeye-removal.c
data/glade/gthumb_redeye.glade
libgthumb/icons/redeye-removal-16.png (patch 56530)

- Mike
Comment 24 Michael Chudobiak 2006-10-25 10:32:15 UTC
Well, after an evening of clicking on eyes, I'd say that the v2 patch works on > 90% of red eyes.

It has some trouble when the "redeye" is actually orangish or whitish.

Carl, a progressive aggressive feature would be great! Hopefully v2 will be committed, to simplify further tweaks.

- Mike
Comment 25 michal 2006-10-26 19:12:35 UTC
Created attachment 75467 [details] [review]
redeye, v3

So - I spent an hour or so working on a progressive agression feature - and for me it doesn't actually help much.  I tried just moving the threshold as done in the gimp plugin, but the red eyes that don't get fixed easily still aren't found with a more aggressive threshold.  Most of the ones I find that aren't fixed immediately, are as you said a whitish orange.  This algorithm doesn't find those hues easily.  If some better way of doing this occurs to me, I'll write it, but for now, I don't think its worth including.

I did notice two small problems in v2.  One is a typo that was originally mine
the height of the image was used in both directions, when one should have been the width.  The other is in calculating the scale factor - I reduced the available screen height to 90% of the maximum value to try to avoid having the buttons at the bottom interfere with the panel.
Comment 26 Michael Chudobiak 2006-10-26 20:17:05 UTC
Looks good. 

Paolo, please commit v3 (along with the new icon, which has to be renamed to redeye-removal-16.png when saving).

- Mike
Comment 27 michal 2006-10-27 00:17:34 UTC
Woops - I just realized in my 'fix' of the available screen height, I multiplied by 10/9, should have been 9/10
Comment 28 Michael Chudobiak 2006-10-27 12:39:20 UTC
Created attachment 75502 [details] [review]
redeye, v4

Here is a new patch with improved scaling factors. This version uses a float scale factor, rather than an integer. The integer scale factor was too coarse to notice the difference between 9/10 and 10/9, Carl. (i.e, my photo had 2048 height, my screen has 1200, so +/- 10% isn't noticed in 2048/1200 = 2 approx.)

Please commit, Paolo...
Comment 29 Michael Chudobiak 2006-10-31 19:13:55 UTC
Patch applied to CVS HEAD. Thanks everyone!

- Mike
Comment 30 manuel braga 2006-11-04 12:59:20 UTC
Created attachment 75990 [details] [review]
header file for redeye removal

The dlg_redeye_removal has not been declared in gth-window-actions-callbacks.c

Also the scale factor calcule has to be changed.
I get the top of the window hidden by gnome-panel.
Comment 31 Michael Chudobiak 2006-11-04 15:30:01 UTC
Thanks Manuel! Patch committed.

The scaling factors are currently:

width_scale = 1.1 * (gfloat) width / (gfloat) gdk_screen_get_width(screen);
height_scale = 1.25 * (gfloat) height / (gfloat) gdk_screen_get_height(screen);

What height scaling factor works best for you?

- Mike
Comment 32 manuel braga 2006-11-04 16:57:15 UTC
In this case, the image is set to 80% of the screen height, but the size of the window's widgets has to be counted too.
I my case 1.35 for the height will do, but.

This has to be more flexible.