RSS/Atom feed Twitter
Site is read-only, email is disabled

possble replacement(s) for Gimp Lanczos

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

4 of 6 messages available
Toggle history

Please log in to manage your subscriptions.

9342061.8431219327050629.Ja... 07 Oct 20:26
  possble replacement(s) for Gimp Lanczos Nicolas Robidoux 21 Aug 16:01
   possble replacement(s) for Gimp Lanczos Øyvind Kolås 21 Aug 23:09
   possble replacement(s) for Gimp Lanczos Sven Neumann 21 Aug 23:21
10662972.14141219609331563.... 07 Oct 20:26
  possble replacement(s) for Gimp Lanczos Nicolas Robidoux 24 Aug 22:42
Nicolas Robidoux
2008-08-21 16:01:51 UTC (over 16 years ago)

possble replacement(s) for Gimp Lanczos

Someone kindly pointed out that the subject line of my last email made it likely to be caught by a filter.

In case you missed it:

http://web.cs.laurentian.ca/robidoux/misc/

contains the tarred and gzipped folder gimptests.tgz which contains code for four suggested plug-ins which implement possible replacements for Lanczos.

The README file gives details.

-----

Of the four, IBFNBQH (a brand new method analogous to global cubic splines, but with a slightly different variational principle and boundary conditions) is the most likely candidate to replace Lanczos.

If you look at the kingfisher enlargements, you will notice that Lanczos, as currently implemented in the Gimp, produces artifacts in the top row. None of the plug-ins have such artifacts. Actually, they have been tested inside and out, qualitatively and quantitatively, on a variety of images, and are almost certainly free of "bugs."

Because the top row is cropped out of the enlargement of the other image, this artifact is not visible.

In addition, although this is of course a matter of taste, I prefer the "crispness" of IBFNBQH (and EANBQH) to the slight blurriness of Lanczos.

------

At this point, the plug-ins only enlarge.

I imagine that in order for, say, IBFNBQH to replace Lanczos, it would have to be fixed so it can resize to arbitrary dimensions. I should be able to do this in a reasonable amount of time.

David Gowers has suggested using LittleCMS (or GeGL) to linearize colour profiles during the computation. In our experience, our plug-ins produce good results when used in a "gamma OBLIVIOUS way." This being said, back of the envelope computations suggest that "light" haloing is likely to decrease if the colour profile is properly taken into account (because sRGB has a linear component near black, "dark" haloing is probably not going to change much for such images; again, this is from a very rough back of the envelope reasoning). Given that GeGL will perform all the heavy lifting for the Gimp in the future, I am not sure that fixing the gamma correction at this point is really something I want to do. However, I will try to integrate profile information in the profile if it is felt that it is important.

The current "gamma" versions of the plug-ins use "naive" gamma correction (and do not take into account the linear piece of sRGB). David's plan is a much better one.

Let me know what you think.

Nicolas Robidoux Laurentian University/Universite Laurentienne nrobidoux@cs.laurentian.ca

Øyvind Kolås
2008-08-21 23:09:39 UTC (over 16 years ago)

possble replacement(s) for Gimp Lanczos

On Thu, Aug 21, 2008 at 3:01 PM, Nicolas Robidoux wrote:

David Gowers has suggested using LittleCMS (or GeGL) to linearize colour profiles during the computation. In our experience, our plug-ins produce good results when used in a "gamma OBLIVIOUS way." This being said, back of the envelope computations suggest that "light" haloing is likely to decrease if the colour profile is properly taken into account (because sRGB has a linear component near black, "dark" haloing is probably not going to change much for such images; again, this is from a very rough back of the envelope reasoning). Given that GeGL will perform all the heavy lifting for the Gimp in the future, I am not sure that fixing the gamma correction at this point is really something I want to do. However, I will try to integrate profile information in the profile if it is felt that it is important.

The current "gamma" versions of the plug-ins use "naive" gamma correction (and do not take into account the linear piece of sRGB). David's plan is a much better one.

A summary of image resampling in GEGL:

GEGL is being designed to operate correctly on images, the current samplers operate on "RaGaBaA float" buffers, which is the babl notation for premultiplied alpha linear light RGB with opacity. This causes a resampling and resumming of the buffer behaving like phyiscal light, ray tracing and compositing operations are other operations that give the most correct result when operated upon in linear light.

http://www.4p8.com/eric.brasseur/gamma.html details some of the problems with correcting sRGB data directly.

Sampling types in GEGL are subclasses of a generic base class providing a a cache. This is less efficient than having the different samplers directly in the scaling code, but allows reusing them for all affine transformations, displacement maps, iwarp or other similar image deformations. Fast paths for scaling with specific samplers could probably be added later and tested against the generic extendable sampler framework for correctness at a later point.

The cache that is used is a 64x64 linear circular buffer guaranteed to contain the entire needed spatial context of pixels.

To see how the current samplers are implemented see:

http://svn.gnome.org/viewvc/gegl/trunk/gegl/buffer/gegl-sampler-linear.c?revision=2489&view=markup

Currently nearest, linear, cubic and lanczos scalers have been implemented.

Scaling down is currently not handled correctly by the implementation, but for equal scaling on both x and y axis the sampling API should be sufficient to express the needs.

/Øyvind K.

Sven Neumann
2008-08-21 23:21:11 UTC (over 16 years ago)

possble replacement(s) for Gimp Lanczos

Hi,

first of all, thanks for your efforts to implement better scaling for GIMP. I am sure that the plug-in will be quite useful for GIMP users that need to enlarge images. Have you already added the plug-ins to the GIMP plug-in registry?

However I don't think we are likely going to add another scaling algorithm to the legacy GIMP code base or even replace the Lanczos scaling method. At this point we are concentrating on porting more and more of the GIMP core to GEGL. So if you want to convince us to use your scaling algorithms, your best bet is implement them as GEGL operations. You might even consider to contribute them to the GEGL code base. Using GEGL you also have the advantage that you can work with linearized floating point data.

Sven

Nicolas Robidoux
2008-08-24 22:42:11 UTC (over 16 years ago)

possble replacement(s) for Gimp Lanczos

Hello Sven and Oyvind:

Have you already added the plug-ins to the GIMP plug-in registry?

I will when I have rewritten the code to my satisfaction. The current versions are perfectly useable (and bug free), but I'd rather release the final versions right of the bat.

At this point we are concentrating on porting more and more of the GIMP core to GEGL.

It is unlikely that I will port EANBQH and IBFNBQH to GEGL, because programming them so that they can be used analogously to bilinear, bicubic and lanczos is a substancial programming project.

I have looked around the GEGL code, and it is very likely that I will program a novel "co-convex resampling scheme" following the lanczos model found there. This will take a while.

One good thing about the co-convex scheme is that the results are not overly affected by what I understand is the current GEGL "abyss" policy (set pixel values outside of the physical extent of the image to 0): only if the sampling point is outside of the rectangle defined by the boundary pixels will the value be negatively affected.

Quick comment:

If the default GEGL abyss policy was "smear," this would have the following general consequence:

Any linear method/filter (blur, resampling...) which is exact on constant intensity data will still be exact on constant intensity data without special handling within the filter. This does not mean that the results are the same as if the filter carefully handles the boundary, just that the dirty hack of using "ghost values" and then implementing the filter in a boundary independent way will not give absurd results.

This has two consequences:

Implementing filters can be done in two passes: first, ignore boundary issues; build in boundary handling into the filter, using the x, y, width and height information to determine the position relative to the boundary and perform appropriate branching.

If speed/more compact code is desired, ignore boundary branching, confident that the results are still reasonable.

This being said, changing to "smear" will not make the results with the co-monotone method any different, which is why I don't particularly care. The co-monotone method is not linear.

I suspect that for some filters it is impossible to define an abyss policy which is equivalent to careful handling of the boundary within the filter. The ImageMagick trick of masking and normalizing the coefficients is another way of getting reasonable results (and preserving the "exact on constants" property), but again it only approximates careful boundary handling for most schemes. If I was to choose, I'd rather (approximately) fix things with a smear abyss policy (even though, in the particular case of my next pet scheme, it makes no difference).

Thank you all for your comments,

Nicolas Robidoux Laurentian University/Universite Laurentienne