Page 1 of 1

Difference between resize/distort ?

Posted: 2012-07-06T00:13:12-07:00
by Nicolas P. Rougier
Hi all,

I've been trying to modify the "lupe" script by adding a point filter to the distort operation but it does not seem to work. More generally, these two commands differ on my machine:

convert rose: -filter point -resize 200% show:
convert rose: -filter point +distort SRT '2 0' show:

The first one is the result I want (no interpolation) while the second one does not seem to take the filter into account (resulting in an interpolated magnification). Did I miss something obvious ?


Nicolas

---

ImageMagick version: LIB_VERSION_NUMBER 6,7,7,6
os : darwin11.4.0

Re: Difference between resize/distort ?

Posted: 2012-07-08T17:28:45-07:00
by anthony
-filter point in -resize means just use nearest neighbour interpolation for the color lookup. You can not select what type of lookup you want.

That is equivalent to using -sample.
See, Filter Point...
http://www.imagemagick.org/Usage/resize/#point

In -distort however it means use a single point interpolative lookup of color, which uses the -interpolate setting, defaulting to "bilinear"
See Distort, Interpolated, or Direct Color Lookup
http://www.imagemagick.org/Usage/distor ... nterpolate
And Interpolation
http://www.imagemagick.org/Usage/misc/#interpolation

If you would like to use 'point' interpolation for resizing, you can use the operator -interpolative-resize. Added sometime around IM v6.7.7-3 for easier testing of new interpolation methods and changes.

WARNING: interpolation works for enlargements, but will cause server aliasing when shrinking image by more than 50% as it is NOT an 'area weighted averaging' or 'filtered' resampling technique (both have the same meaning, just a different way of viewing the calculation of color lookup).

Actually reading the first part of the distort page, and later the Resize filters page will give you a good understanding of how all distortion/resize operators work in ANY image processing package, regardless of if orthogonal resize filtering, or elliptical area resampling (or perhaps something else in the future).