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 552159 - Patch for YAFR sampler (was not broken, but is now better and faster)
Patch for YAFR sampler (was not broken, but is now better and faster)
Status: RESOLVED FIXED
Product: GEGL
Classification: Other
Component: core
git master
Other All
: Normal enhancement
: ---
Assigned To: Default Gegl Component Owner
Default Gegl Component Owner
Depends on:
Blocks:
 
 
Reported: 2008-09-13 20:25 UTC by Nicolas Robidoux
Modified: 2008-10-02 23:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Improved gegl-sampler-yafr.h, gegl-sampler-yafr.c and gegl-sampler.c (89.23 KB, patch)
2008-09-13 20:27 UTC, Nicolas Robidoux
none Details | Review
Improved gegl-sampler-yafr.h, gegl-sampler-yafr.c and gegl-sampler.c (109.75 KB, patch)
2008-09-20 19:06 UTC, Nicolas Robidoux
none Details | Review
Improved patch for gegl-sampler.c, gegl-sampler-yafr.h and gegl-sampler-yafr.c (108.79 KB, patch)
2008-09-29 22:40 UTC, Nicolas Robidoux
none Details | Review
Improved gegl-sampler-yafr.h, gegl-sampler-yafr.c and gegl-sampler.c (cosmetic improvements) (111.38 KB, patch)
2008-09-30 00:29 UTC, Nicolas Robidoux
none Details | Review

Description Nicolas Robidoux 2008-09-13 20:25:46 UTC
Improvements to YAFR (Yet Another Fast Resampler).

Files involved: gegl-sampler.c, gegl-sampler-yafr.h, gegl-sampler-yafr.c

I redesigned the scheme (which was my creation to start with).

Changes:

--YAFR correction is "on" for more pixels

--YAFR correction is milder (old version = French roast; new = Vienna roast)

--Catmull-Rom contribution to the overall scheme is larger than before

--bilinear contribution to the overall scheme is gone

--Code is cleaner

--Safer handling of the restrict keyword

--Runs about 10% faster than before (tested on year-old thinkpad t60p laptop running current Ubuntu)

Only complaints could be from people who may have liked the "stronger" straightening effect of the old YAFR. In my opinion, the balance between
straightening and nonlinear artifacts is closer to "just right" with the new
YAFR. I don't think anybody will complain.
Comment 1 Nicolas Robidoux 2008-09-13 20:27:32 UTC
Created attachment 118677 [details] [review]
Improved gegl-sampler-yafr.h, gegl-sampler-yafr.c and gegl-sampler.c
Comment 2 Nicolas Robidoux 2008-09-14 13:14:06 UTC
Based on the now outdated YAFR, Geert Jordaens has kindly suggested several improvements to the code which would improve its readability and make it shorter.

I'll refactor the new YAFR and submit a new path within a few days.

Nicolas Robidoux
Laurentian University/Universite Laurentienne
Comment 3 Nicolas Robidoux 2008-09-20 19:06:28 UTC
Created attachment 119047 [details] [review]
Improved gegl-sampler-yafr.h, gegl-sampler-yafr.c and gegl-sampler.c


This patch fixes the insertion of yafr into gegl-sampler.c and removes unneeded #includes. It also modifies gegl-sampler-yafr.* considerably.

Most importantly, the patch includes two different versions of yafr, which can be toggled by a #define in gegl-sampler-yafr.c (the toggle points to the standard version by default).

The "standard" version benefited a lot from educational comments of Geert Jordaens. It is now considerably shorter, faster (scale with yafr driven from xml now runs less than 10% longer than scale with linear), and easier to read. 

The "non-standard" version toggles more careful handling of the boundary, under the assumption that the left and top abyss end at position -1. This assumption is not generally true; for this reason, the "hidden" version should not be compiled by default.

The differences between the various schemes are made particularly obvious if one
starts gegl from the terminal, and either transform->shear with origin-x = 590, origin-y = -200, x (shear coefficient) = 0.1, y (shear coefficient) = -.2; or, say, transform->rotate by 7 degrees. Toggling between nearest, linear, cubic, lanczos and either versions of yafr is pretty striking.

As always, comments positive and negative are welcome.

Nicolas Robidoux
Laurentian University/Universite Laurentienne
Comment 4 Nicolas Robidoux 2008-09-21 12:17:27 UTC
Geert Jordaens has kindly (and quickly) emailed gegl-developer a patch for gegl-sampler.[c|h] which allows samplers to determine the extent of the valid pixel region.

I'll integrate this into yafr and submit yet another patch soon.

Also:

I may have figured out how to overcome the main shortcoming of YAFR, namely that
it boils down to Catmull-Rom when the image is locally "text like" (meaning that only two colour values are used). (Boiling down to Catmull-Rom is not that bad, it is just that I'd like to do better.) I'll give this a try before submitting the patch.

Nicolas Robidoux
Laurentian University/Universite Laurentienne
Comment 5 Nicolas Robidoux 2008-09-25 21:52:17 UTC
I found a small numerical bug in gegl-sampler-yafr.c, which effectively flips the corrections upside down, destroying the visual quality of the result. I'll fix it and post yet another patch.
Comment 6 Nicolas Robidoux 2008-09-29 22:40:20 UTC
Created attachment 119621 [details] [review]
Improved patch for gegl-sampler.c, gegl-sampler-yafr.h and gegl-sampler-yafr.c


This is a group of patches relevant to the YAFR sampler. The code, which greatly benefited from comments of Geert Jordaens, contains two versions of YAFR. One uses the 0/0/0/full transparency abyss policy like the other samplers. The other carefully implements boundary conditions, and "crosses" the boundary seamlessly (useful when rotating, for example: values from outside the original frame are need to be created) at the left and top. In order for this version to be fully functional, I'd need to know how to get the extent of the original image data (in other words, I'd need to know where the valid input pixel data starts and ends), and reprogram accordingly.

In my opinion, this is without question the best overall sampler currently programmed in GEGL, and it should be the default.

Try it!

Nicolas Robidoux
Laurentian University/Universite Laurentienne
Comment 7 Nicolas Robidoux 2008-09-30 00:29:35 UTC
Created attachment 119626 [details] [review]
Improved gegl-sampler-yafr.h, gegl-sampler-yafr.c and gegl-sampler.c (cosmetic improvements)


No code improvement this time: Typos in comments corrected.
Comment 8 Øyvind Kolås (pippin) 2008-10-02 23:09:47 UTC
2008-10-03  Øyvind Kolås  <pippin@gimp.org>

        Applied patch witch cosmetic improvements from  Nicolas Robidoux
        for bug #552159 cleaning up the YAFR code.

        * gegl/buffer/gegl-sampler-yafr.c: 
        * gegl/buffer/gegl-sampler-yafr.h:
        * gegl/buffer/gegl-sampler.c: