GNOME Bugzilla – Bug 324849
Request for Lense distort plugin inclusion.
Last modified: 2007-04-18 18:27:07 UTC
As discussed on the developer mailing list. Hi, have been using daves lense distortion plugin. it realy usefull for > making tiled textures and seems a good plugin to include for any app > that works with photos. > > http://members.ozemail.com.au/~hodsond/gimp.html
Please, try to make all pertinent information to the bug available on the report. The original mail to the developers list is this: ------------- Hi, have been using daves lense distortion plugin. it realy usefull for making tiled textures and seems a good plugin to include for any app that works with photos. http://members.ozemail.com.au/~hodsond/gimp.html It compiles with Gimp CVS also. - Cam ----------- The actual plug-in URL is this: http://members.ozemail.com.au/~hodsond/wideangle.html And this is the description of the plug-in in that URL: The Wideangle filter is used to correct (or simulate) the distortion typically seen on photographs taken with a wideangle lens. There are six controls.
See also bug 103941 - if we don't want more than this plug-in provides, we should resolve the older bug as a duplicate of this one.
Before we can accept this plug-in for inclusion in the GIMP source tree it needs to undergo a couple of changes. First of all the GIMP coding style needs to be applied to the source code. Then the user interface needs to be changed to be more similar to the other plug-ins we ship. The preview should definitely be done using a GimpPreview widget instead of the deprecated GtkPreview. If someone wants to do these changes and if the plug-in author doesn't disagree, we will happily include it.
Adding the gnome-love keyword. Porting an existing plug-in to the GIMP coding style and making it use recent GIMP widgets is probably a nice job for someone who wants to get into GIMP development and doesn't know where to start.
I will port this. I've made it to work with GimpPreview, just some code styling and interface improvements left. Shouldn't we call it "Lens correction" instead of "wideangle"?
Created attachment 72545 [details] Lense distort plugin I tested this on win32 and linux (64 bit). Hopefully, this could go to gimp source tree without code modifications.
Didn't you mean to rename the plug-in to "Lens correction"? Is that what the plug-in is doing? Correcting for lens distortions? Or does it rather simulate a wide angle lens? The code looks basically OK, even though I would give it another round of coding style and cleanup.
> Didn't you mean to rename the plug-in to "Lens correction"? Is that what the > plug-in is doing? Correcting for lens distortions? Or does it rather simulate a > wide angle lens? Plugin author says: Photos taken with wideangle lenses tend to show some degree of barrel distortion. This plugin is designed specifically to correct (or create) lens distortion. Name "wideangle" doesn't give me any associations to what is said above. Although there is more than one variant how the plugin can be called, "Lens correction" seems short enough and quite intuitive. > The code looks basically OK, even though I would give it another round of > coding style and cleanup. I took another look at the code and found few tabs and in one place there was commented code. All other ifdefs are necessary to be able to build with statistics analisis, so I don't they should be removed. If you think another round is needed before adding plugin to gimp, please give me more information what you don't like about it.
The plug-in only deals with a very specific kind of lens distortion then (barrel). That should probably show up in the name. Or do you think it can be extended to deal with other lens distortions such as pincushion?
As I understand, it handles pincushion correction as well. Negative values of Main slider correct barrel distortions, while positive values correct pincushion distortion. I found out that digiCam have ported the same plugin and they called it "Lens Distortion Correction". There is a nice explanation and screenshots on their page. http://docs.kde.org/stable/en/extragear-graphics/digikamimageplugins/lensdistortion.html#using-plugin-lensdistortion By the way, they don't use Shift X and Shift Y sliders. In our plugin, Shift X and Shift Y go first in the slider list, but they don't have effect until Main slider's value is set nonzero. I suggest we move them to the end of the slider list so that Main slider becomes first.
Can you make a new version called "Lens Correction" then? Please do also change the function names, perhaps use something shorter like "lens" as the namespace. Moving the X,Y sliders down sounds like a good idea as well.
Created attachment 72679 [details] Lense correction plugin Hopefully fixed all the problems that we discussed about. Binary & source name are currently "lens". They probably need to be changed to something more descriptive.
Created attachment 72680 [details] Lense correction plugin Replaced "lense" to "lens" in some places.
I went over it once more, fixed some coding style issues and applied some more polishing to the UI. The plug-in is now in CVS: 2006-09-13 Sven Neumann <sven@gimp.org> * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/lens.c: added Lens Distortion plug-in. Written by David Hodson and ported to newer GIMP APIs by Aurimas Juška and me (bug #324849). I think however that this plug-in should use GimpZoomPreview. Aurimas, perhaps you want to try to port the preview code to GimpZoomPreview?
I will try to port this code to work with GimpZoomPreview. However, it looks to me like many changes will have to be made so this might take few days.
I have made the plugin work with GimpZoomPreview. It works just great with default zoom. However, if you zoom in it simply makes the correction on the zoomed in area. Waves plugin works in the same way, though. If this is allright, I will clean it up and bring to you.
The plug-in needs to adapt to the Zoom level. The preview should match the result as good as possible. The Waves plug-in seems buggy in this respect and needs to be fixed. Can the parameters be scaled according to the zoom level? I haven't tried but I think that this might work.
I don't see how zoom level could help me in this situation. Even if I had some more information, like scrollX and scrollY, it would be not an easy task to draw the correct preview. I took a look at other plugins, which use zoom preview (Distort > Polar coordinates, Distort > Waves, Distort > Wril and Pinch) and they all behave the same way. I think GimpZoomPreview is implemented incorrectly. I want to express my opinion on how I would like GimpZoomPreview to be implemented using the current interface, so that these plugins would work correctly. With default zoom level everything is simple: widget gives pixels of the thumbnail and plugin processes them. When user zooms in, widget should create larger thumbnail and plugin again would process it as if it were a small image. GimpZoomPreview would always have the whole zoomed-in image, so that it could display any required region and scrolling wouldn't require expensive calculations. I can hardly imagine any other way to use this widget. If some other widget would would be better please let me know. Otherwise I will continue my work with this one.
The point of a preview is that it's fast. If the widget would work as you describe, it would need lots of memory and would not be any faster than running the plug-in. Somehow I get the impression that David Odin never really finished the GimpZoomPreview implementation. If there's API missing, we can still add it. Someone needs to look at fixing the plug-ins you mentioned.
Created attachment 72795 [details] [review] lens correction (zoom preview) This is the result of my work. I don't know if it is still needed, but at least with default zoom it is convenient to adjust settings. * supports GimpZoomPreview * improved performance * removed some global variables * replaced LENSE_ to LENS_
Thanks a lot. I have committed this to CVS without further changes: 2006-09-17 Sven Neumann <sven@gimp.org> * plug-ins/common/lens.c: applied patch from Aurimas Juška which, among other changes, ports the plug-in to GimpZoomPreview (bug #324849).
do you have an example of a real camera image that has this defect? My first impression is that this is more of a special effect than a correction tool. I found a couple of anomolies that you may like to look into. 1/ with main>0 , brigthness control working backwards: more neg = brighter image. As a corrolary with main=0 brightness has no effect. 2/ with zoom around -50% , large negative 'edge' or 'main' shows strange effects. 3/ usability: what is "main" ? Although it did make changes I was unable to determine really what it did. 4/ Both main and edge seem to have very little effect over the positive range. Max is a light distortion, I was expecting a fish-eye lens. The negitive range seems to go too far , see comment 2. Interesting effects , thx.
Sure, the plug-in is pretty much targetted at simulating lens distortions. It is probably not very useful for actually correcting such distortions. IMO it would be a good idea to do something about the Main slider (see comment #23).
It really does distort correction. This plugin works in two directions, so it can create opposite effect instead. > do you have an example of a real camera image that has this defect? My first > impression is that this is more of a special effect than a correction tool. google > images > "lens distort before" > 2/ with zoom around -50% , large negative 'edge' or 'main' shows strange > effects. Main & edge sliders should be set in opposite directions for the best effect. Area around the image should be cropped after using this filter. > 4/ Both main and edge seem to have very little effect over the positive range. > Max is a light distortion, I was expecting a fish-eye lens. The negitive range > seems to go too far , see comment 2. You should have an image with defect to see the effect. This plugin is not meant to do fish-eye efect. See documentation of nearly identical plugin for other questions: http://docs.kde.org/stable/en/extragear-graphics/digikamimageplugins/lensdistortion.html#using-plugin-lensdistortion
thanks, here's a couple images to compare functionality with the equivalent PS filter. http://imagebank.digitalartist.com.my/PM/PTL-Before.jpg http://imagebank.digitalartist.com.my/PM/PTL-After.jpg Although I did not manage to straighten the image this well, it did do a fairly good job. After being corrected I would agree this is more a correction tool than a special effect. As such it realy should be in the Enhance menu and not Distortions menu. In that context is makes more sense to call it Lens correction than lens distortion. gimp_install_procedure (PLUG_IN_PROC, N_("Corrects lens distortion"), "Corrects barrel or pincushion lens distortion.", "David Hodson, ported by Aurimas Juska", "David Hodson", "Version 1.0.10", N_("Lens Correction..."), "RGB*, GRAY*", GIMP_PLUGIN, G_N_ELEMENTS (args), 0, args, NULL); gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Filters/Enhance"); } thanks for the port.
Created attachment 73496 [details] [review] pattch to move this to Enhance menu as above.
*** Bug 103941 has been marked as a duplicate of this bug. ***