See the large images at the bottom if you just want to see the results!
This is a major improvement in distort image results, but to understand the fix, you need to understand the problem.
This change will be part of IM version 6.6.4-2 releases and later.
----------------------------
A number of years ago, I added the Distort Operator to ImageMagick.
To make this filter work I includes EWA filtering (Elliptical Weighted Average) which used a Gaussian filter by default.
However at that time all the research papers and notes on EWA, always concerned itself with images involving distant horizons. That is correctly averaging large numbers of pixels that look very very 'distant' from the user, as generated by Perspective Distortions.
For example see Viewing Distant Horizons
Here is the image from IM examples of this 'typical' test image they used.
The problem with this 'typical' test of EWA, is that it does not really test the filter handling of images with low (near unity) distortions, only the handling of image sampling at high minification.
At the time I endeavoured to get distortion at near unity scaling to work well, and to some extent it did, but the results were always 'over blurry' in my thinking (and to many other people who reported that fact). however I was unable to fix this due to a lack of understanding of filters, and specifically cylindrical filters.
To compensate this blurriness I make EWA distort automatically switch to using 'interpolation' in situations of image magnification, and also a special switch "-filter point" which will turn off EWA filtering, and force the use of interpolation for the whole image (it also increases the speed, and allows the use of super sampling instead of filtering for improved results with near-unity scaled images.
Later I did a lot of research into filters and as a result of this re-designed the filter system used by 'resize'. See Resize Filters, but resize filters are orthogonal filters and that did not seem to match the cylindrical filter used by distort EWA filtering. All attempts to fix EWA filtering resulted in images become worse rather than better
With the on going discussions with Nicolas Robidoux in Cheaper sinc computation for resize.c however has spurred me on to take a fresh look at the EWA filters.
With this I was able to add a new special switch, that allowed me to actually look at the problem properly, rather than making (bad) guesses as to its cause. If you now set "-interpolate filter" you will turn off interpolated lookup for areas of the image that become 'enlarged'. that lets me used huge enlargement tests with the EWA filters, just like I did with resize, as shown in Ringing Resize Artefacts, and again in Gaussian Filter Support Examples.
With that switch and enlargement filter testing I was about to determine that I had two bugs, one of which roughly cancelled out the other. that was why fixing the more obvious bug (blurriness) only resulted in the results becoming worse, rather than better.
Both bugs have now been found and fixed. The resulting improvement are simply amazing.
Here is the results of a 'Rings' Aliasing Test (using perspective to get a range of scaling factors)
Code: Select all
convert rings_lg_orig.png -chop 1x1 -border 1 \
-virtual-pixel tile -distort perspective \
'0,0 0,200 1000,0 650,200 0,1000 0,700 1000,1000 1000,700' \
rings_test.png
http://www.imagemagick.org/Usage/img_ph ... g_orig.png
Yes it is a large image.
as you can see it is very blury, with many Moiré (aliasing) effects visible (which should not be present with a gaussian filtered result. However Much more of the detail of the rings are also visible showing that the resulting image is much less blurry than before.
The lowest part of the resulting image uses interpolation rather than EWA filtering, though it is hard to see when one finishes an the other begins.
After the fixes, we now get...
This image shows barely any Moiré (aliasing) effects (as you should get with Gaussian Filtering) but it also shows the sharp change from EWA Gaussian filtering to Bilinear Interpolation in the areas of image enlargement.
If you do not want this sudden change add a "-interpolate filter" switch to turn off the use of interpolation.
Because this change is now highly visible the automatic switching between the two modes may soon be turned off by default. For example in no -interpolate setting is set. -- Comments?
Comments are welcome.