Page 1 of 1
Direct resampling vs zero order hold + convolution
Posted: 2012-09-21T13:09:44-07:00
by BryantMoore
Re: Direct resampling vs zero order hold + convolution
Posted: 2012-09-21T13:19:45-07:00
by fmw42
a triangle filter does a linear interpolation in x and in y between pixels in the input image to find the correct color to assign to each output pixel based upon the scale factor.
There is much on this and more discussed at:
http://www.imagemagick.org/Usage/resize/#filter
http://www.imagemagick.org/Usage/distorts/#summary
Re: Direct resampling vs zero order hold + convolution
Posted: 2012-09-21T13:42:08-07:00
by BryantMoore
I guess what I should ask is if the direct resampling or the convolution is a more accurate representation of how the final image should look.
Re: Direct resampling vs zero order hold + convolution
Posted: 2012-09-21T15:23:40-07:00
by fmw42
sumawo13 wrote:I guess what I should ask is if the direct resampling or the convolution is a more accurate representation of how the final image should look.
You will have to tell us what the resampling filter is and what the convolution kernel is?
In general, resampling filters are nearestneighbor, bilinear (triangle), cubic convolution, lanczos, etc as described in the reference I provided. Whereas, convolution is just a blurring of the resulting enlargement. Typically a good resampling filter will beat a blurring convolution.
On the other hand, for example, photoshop does a bilinear or cubic convolutoin resampling followed by a hidden unsharp (misnomer) sharpening convolution. In this case there has been quite some discussion on the forum recently and tests by Professor Nicolas Robidoux suggesting that a properly designed filter can do as well or better than the photoshop process. See
http://www.imagemagick.org/Usage/resize/#nicolas
"Adjusting the blur (between about 0.7 and 1.0) or B parameters (between 0.0 and 1.0) should obviate any need for USM (Unsharp) Sharpening. You may also want to try sigmoidizing."
Re: Direct resampling vs zero order hold + convolution
Posted: 2012-09-29T13:45:30-07:00
by BryantMoore
fmw42 wrote:You will have to tell us what the resampling filter is and what the convolution kernel is?
In general, resampling filters are nearestneighbor, bilinear (triangle), cubic convolution, lanczos, etc as described in the reference I provided. Whereas, convolution is just a blurring of the resulting enlargement. Typically a good resampling filter will beat a blurring convolution.
Code: Select all
$ convert rose: -sample 2000% +repage -define filter:verbose=1 -define filter:blur=20 -filter triangle -resize 100% 00-rose-blur-triangle.png
# Resize Filter (for graphing)
#
# filter = Triangle
# window = Box
# support = 1
# window-support = 1
# scale-blur = 20
# practical-support = 20
Code: Select all
$ convert rose: -define filter:verbose=1 -filter triangle -resize 2000% 00-rose-resize-triangle.png
# Resize Filter (for graphing)
#
# filter = Triangle
# window = Box
# support = 1
# window-support = 1
# scale-blur = 1
# practical-support = 1
And as far as my version.
Code: Select all
$ identify
Version: ImageMagick 7.0.0-0 2012-09-29 Q32 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP HDRI
Re: Direct resampling vs zero order hold + convolution
Posted: 2012-09-29T13:53:25-07:00
by BryantMoore
Code: Select all
$ convert rose: -sample 2000% +repage -define filter:verbose=1 -define filter:blur=20 -filter mitchell -resize 100% 00-rose-blur-mitchell.png
# Resize Filter (for graphing)
#
# filter = Cubic
# window = Box
# support = 2
# window-support = 2
# scale-blur = 20
# practical-support = 40
# B,C = 0.333333,0.333333
EWA Jinc Lanczos
It seems to have a similar edge case with less ripple.
Re: Direct resampling vs zero order hold + convolution
Posted: 2012-09-29T16:01:41-07:00
by BryantMoore
Code: Select all
$ magick rose: -sample 2000% -define filter:verbose=1 -define filter:blur=20 -filter lanczos -resize 100% rose-lanczos.png
# Resize Filter (for graphing)
#
# filter = SincFast
# window = SincFast
# support = 3
# window-support = 3
# scale-blur = 20
# practical-support = 60
Gives similar results to EWA Jinc Lanczos.
It seems to be more "true" to the original image.
Re: Direct resampling vs zero order hold + convolution
Posted: 2012-09-30T12:44:36-07:00
by BryantMoore
rose-blur-box.png (1400×920)
http://ompldr.org/vZnBhMw/rose-blur-box.png
rose-blur-triangle.png (1400×920)
http://ompldr.org/vZnBhNA/rose-blur-triangle.png
rose-blur-mitchell.png (1400×920)
http://ompldr.org/vZnBhNQ/rose-blur-mitchell.png
rose-blur-catrom.png (1400×920)
http://ompldr.org/vZnBhNg/rose-blur-catrom.png
rose-blur-lanczos.png (1400×920)
http://ompldr.org/vZnBhNw/rose-blur-lanczos.png
Code: Select all
#!/bin/sh
for f in box triangle mitchell catrom lanczos;
do
magick rose: -colorspace rgb +sigmoidal-contrast 8 -sample 2000% -define filter:blur=20 -filter $f -resize 100% -sigmoidal-contrast 8 -colorspace srgb rose-blur-"$f".png
done
It seems with convolution, the box filter creates an effect similar to direct resampling with a triangular filter.