GNOME Bugzilla – Bug 140533
Red-eye removal tool
Last modified: 2006-11-04 16:57:15 UTC
Would some-sort of red-eye removal tool be possible to include in gthumb?
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.
That would be a killer feature and make it a great tool for digital photos.
I would also like to log some support for this feature request, it would be a huge timesaver.
*** Bug 164561 has been marked as a duplicate of this bug. ***
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...
I also would like to have this feature in gthumb.
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
Created attachment 56530 [details] New icon
*** Bug 325577 has been marked as a duplicate of this bug. ***
thanks for the patch, I'll take a look at it in the next days.
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
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.
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).
Created attachment 60939 [details] stand-alone redeye fix tool sorry - this version should actually build.
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.
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.
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?
A patch based on gredeye is in development. Something should be available in a few weeks...
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.
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
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"
I'll change the "Reduction" to "Removal", and add a "Help" button + manual docs in v2, coming soon. - Mike
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
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
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.
Looks good. Paolo, please commit v3 (along with the new icon, which has to be renamed to redeye-removal-16.png when saving). - Mike
Woops - I just realized in my 'fix' of the available screen height, I multiplied by 10/9, should have been 9/10
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...
Patch applied to CVS HEAD. Thanks everyone! - Mike
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.
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
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.