- No windowing with 3 lobes or more is no good for sinc and jinc (which Anthony, if not "everyone", knew already);
- No windowing is OK with 2 lobes, at least with distort (EWA), if you value sharpness above most everything else;
- "Matching" resize and distort filters often give results which are similar (which Anthony had mentioned before but that I had not seen with my own eyes);
- Two lobe methods can be pretty good;
- If you don't want noticeable haloing, resize Mitchell is hard to beat; [/*]
- My hope that some of the new distort (EWA) methods would OBVIOUSLY blow resize (tensor) out of the water when downsampling did not realize itself: the differences, at least with this test, are subtle. However, near diagonal interfaces and lines, EWA appears to do slightly better: lanczos 3 haloing, esp., is considerably smoother and has smaller amplitude when using the EWA (Jinc) version instead of the usual tensor (Sinc) version, and it's not obvious that there is something to be paid for this (at least when downsampling). EWA Lanczos 2 and variants (distort robidoux, lanczos2sharp, mitchell) also give good results.
no filter windowing when making an image smaller
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: no filter windowing when making an image smaller
Possible conclusions:
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: no filter windowing when making an image smaller
More or less, the conclusions so far match those of
http://imagemagick.org/discourse-server ... =1&t=17926
http://imagemagick.org/discourse-server ... =1&t=17926
Last edited by NicolasRobidoux on 2011-03-16T16:17:18-07:00, edited 1 time in total.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: no filter windowing when making an image smaller
Here is an attractive solution without any halo:It is pretty good when upsampling too. Pretty small support: the disk of diameter 3 (smaller than the support of resize lanczos2, which is the square of diameter 4, for example).
(=sqrt(2)/1.5) also works well, although it is a bit too jaggy for my taste when upsampling.
Code: Select all
convert 69543104.bHSz3aSK.Downsampletestimage.jpg \
-filter quadratic \
+distort affine '0,0,0,0 %w,0 800,0' \
quadratic_distort.png
Code: Select all
-define filter:blur=.9428090415
Last edited by NicolasRobidoux on 2011-03-16T16:16:22-07:00, edited 5 times in total.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: no filter windowing when making an image smaller
Amazing, EWA triangle (which sucks for upsampling), does a good job for this test image:
With a support equal to the disk of diameter 2, this is most likely the fastest EWA (save nearest neighbour EWA, which I'm pretty sure will give dreadful results). On my crusty laptop, it runs in 1.720s compared to 1.523s for plain vanilla resize.
Honestly, I find extremely pleasing the result with EWA triangle. It is remarkably artifact-free.
Yes, EWA lanczos (or resize lanczos) is "snappier," but it does have obvious haloing, and it does have the "saturated" sharpened look, which EWA triangle escapes.
So, although my "no windowing needed when downsampling" hunch did not quite work out for sinc and jinc, it turns out that it does work for EWA triangle: there is no trace in the resulting image of the fact that the triangle basis function is not smooth (only continuous).
This also holds if using -filter triangle -resize, which gives slightly blurrier results which are otherwise fine.
(Most likely, I just rediscovered what some know already, namely that filtering with the hat function gives good results if one is far enough from upsampling. triangle, and quadratic, are approximations of Gaussian blur, esp. when used with distort, so the above is not that different from some of what is recommended here: http://www.imagemagick.org/Usage/resize/#best_filter.)
Code: Select all
convert 69543104.bHSz3aSK.Downsampletestimage.jpg \
-filter triangle \
+distort affine '0,0,0,0 %w,0 800,0' \
triangle_distort.png
Honestly, I find extremely pleasing the result with EWA triangle. It is remarkably artifact-free.
Yes, EWA lanczos (or resize lanczos) is "snappier," but it does have obvious haloing, and it does have the "saturated" sharpened look, which EWA triangle escapes.
So, although my "no windowing needed when downsampling" hunch did not quite work out for sinc and jinc, it turns out that it does work for EWA triangle: there is no trace in the resulting image of the fact that the triangle basis function is not smooth (only continuous).
This also holds if using -filter triangle -resize, which gives slightly blurrier results which are otherwise fine.
(Most likely, I just rediscovered what some know already, namely that filtering with the hat function gives good results if one is far enough from upsampling. triangle, and quadratic, are approximations of Gaussian blur, esp. when used with distort, so the above is not that different from some of what is recommended here: http://www.imagemagick.org/Usage/resize/#best_filter.)
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: no filter windowing when making an image smaller
Have you tried Hermite It is a 'smoothed' triangle filter.
Also you may like to try Gaussian with a 0.75 blur (sharpen) factor, which also generates a Hermite-like curve.
See http://www.imagemagick.org/Usage/resize/#filter_blur
Also you may like to try Gaussian with a 0.75 blur (sharpen) factor, which also generates a Hermite-like curve.
See http://www.imagemagick.org/Usage/resize/#filter_blur
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: no filter windowing when making an image smaller
My hunch was that Hermite would not give a good EWA filter (at least for downsampling).anthony wrote:Have you tried Hermite It is a 'smoothed' triangle filter.
I just tried, and hermite looks pretty good. However, hermite has the worst moire (in the shingles) of any scheme I've tried. This is not particularly surprising, because the hermite filter is heavily concentrated near the center (more so than triangle or the others) and consequently is "close" to "tight" box filtering.
This appears to confirm my rule of thumb that filter smoothness is not so important when downsampling.
(There was actually a theoretical logic to trying triangle: getting from box to B-Splines all the way to Gaussian by repeated box filtering, triangle is the second in the series, quadratic is the third, and cubic (B-Spline smoothing) is the fourth. I posited that when downsampling I could let go of one level of smoothness, which meant downgrading from quadratic to triangle, without paying a price. It appears I was right. Hermite is not directly an approximation of Gaussian.)
Last edited by NicolasRobidoux on 2011-03-16T21:31:11-07:00, edited 2 times in total.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: no filter windowing when making an image smaller
Sounds like Lagrange filters!
Though Lagrange is not smooth.
Though Lagrange is not smooth.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: no filter windowing when making an image smaller
Lagrange is an approximation to a sinc function, as I recall and so has large extent and would likely need windowing.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: no filter windowing when making an image smaller
... more stuff to try.
At some point, I'll have to try to put up a web site with a buch of tests results.
(Initial tests suggest that, at least with large support, Lagrange does not downsample well because of the sharp interfaces. With small support, it's OK. Also, with EWA, Jinc is the target, not Sinc.)
(And yes, Gaussian, with the right blur, should give good results.)
At some point, I'll have to try to put up a web site with a buch of tests results.
(Initial tests suggest that, at least with large support, Lagrange does not downsample well because of the sharp interfaces. With small support, it's OK. Also, with EWA, Jinc is the target, not Sinc.)
(And yes, Gaussian, with the right blur, should give good results.)
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: no filter windowing when making an image smaller
Lagrange is self windowing as it is a piece-wise function. In fact it is its support size (window size) that determines what its order (number of pieces) it has. A support of 0.5 is a box, support 1.0 is a triangle, support 1.5 which is like a discontinuous quadratic (3 pieces) and support 2.0 is Mitchell like (actually it is equivalent to bi cubic interpolation).fmw42 wrote:Lagrange is an approximation to a sinc function, as I recall and so has large extent and would likely need windowing.
http://www.imagemagick.org/Usage/resize/#lagrange
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: no filter windowing when making an image smaller
I agree that a tight Gaussian will also give good results.anthony wrote:...
Also you may like to try Gaussian with a 0.75 blur (sharpen) factor
...
"Quadratic EWA" is a cheap approximation of it.
Note that I like quadratic a lot, for a variety of theoretical reasons, even when using -resize---but it certainly is not very sharp. Sharpness can be restored with quadratic EWA by using, for example, blur=sqrt(2)/1.5, which appears to strike a good balance between sharpness and aliasing. In addition, quadratic resize and quadratic EWA give results which are very close, which should not be surprising since they both approximate Gaussian, the only method which is (if one ignores the different truncation) the same as an EWA or orthogonal method.