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 324849 - Request for Lense distort plugin inclusion.
Request for Lense distort plugin inclusion.
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
unspecified
Other All
: Normal enhancement
: 2.4
Assigned To: GIMP Bugs
GIMP Bugs
: 103941 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-12-23 00:14 UTC by Campbell Barton
Modified: 2007-04-18 18:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Lense distort plugin (26.15 KB, text/x-csrc)
2006-09-11 12:15 UTC, Aurimas Juška
  Details
Lense correction plugin (26.43 KB, text/x-csrc)
2006-09-13 08:06 UTC, Aurimas Juška
  Details
Lense correction plugin (26.40 KB, text/x-csrc)
2006-09-13 08:21 UTC, Aurimas Juška
  Details
lens correction (zoom preview) (20.23 KB, patch)
2006-09-14 16:37 UTC, Aurimas Juška
none Details | Review
pattch to move this to Enhance menu as above. (943 bytes, patch)
2006-09-27 13:33 UTC, gg
none Details | Review

Description Campbell Barton 2005-12-23 00:14:38 UTC
 
Comment 1 Campbell Barton 2005-12-23 00:15:47 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
Comment 2 Joao S. O. Bueno 2005-12-23 03:26:26 UTC
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.
Comment 3 Michael Schumacher 2005-12-24 00:24:55 UTC
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.
Comment 4 Sven Neumann 2006-01-03 16:51:11 UTC
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.
Comment 5 Sven Neumann 2006-01-05 15:42:24 UTC
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.
Comment 6 Aurimas Juška 2006-09-10 12:28:41 UTC
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"?
Comment 7 Aurimas Juška 2006-09-11 12:15:12 UTC
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.
Comment 8 Sven Neumann 2006-09-11 19:26:26 UTC
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.
Comment 9 Aurimas Juška 2006-09-12 06:41:09 UTC
> 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.
Comment 10 Sven Neumann 2006-09-12 07:05:26 UTC
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?
Comment 11 Aurimas Juška 2006-09-12 14:32:57 UTC
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.
Comment 12 Sven Neumann 2006-09-13 05:58:25 UTC
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.
Comment 13 Aurimas Juška 2006-09-13 08:06:03 UTC
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.
Comment 14 Aurimas Juška 2006-09-13 08:21:47 UTC
Created attachment 72680 [details]
Lense correction plugin

Replaced "lense" to "lens" in some places.
Comment 15 Sven Neumann 2006-09-13 14:39:31 UTC
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?
Comment 16 Aurimas Juška 2006-09-13 17:58:04 UTC
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.
Comment 17 Aurimas Juška 2006-09-13 19:56:49 UTC
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.
Comment 18 Sven Neumann 2006-09-14 06:06:58 UTC
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.
Comment 19 Aurimas Juška 2006-09-14 13:35:11 UTC
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.
Comment 20 Sven Neumann 2006-09-14 16:03:30 UTC
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.
Comment 21 Aurimas Juška 2006-09-14 16:37:00 UTC
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_
Comment 22 Sven Neumann 2006-09-17 13:39:24 UTC
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).
Comment 23 gg 2006-09-26 21:51:04 UTC
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.
Comment 24 Sven Neumann 2006-09-27 06:53:00 UTC
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).
Comment 25 Aurimas Juška 2006-09-27 08:41:58 UTC
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

Comment 26 gg 2006-09-27 13:05:46 UTC
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.

Comment 27 gg 2006-09-27 13:33:34 UTC
Created attachment 73496 [details] [review]
pattch to move this to Enhance menu as above.
Comment 28 Sven Neumann 2007-04-18 18:27:07 UTC
*** Bug 103941 has been marked as a duplicate of this bug. ***