Now for a nice theoretical surprise:
EWA triangle (that is, Clamped Elliptical Weighted Averaging resampling with the bilinear filter kernel) should be a decent scheme in any situation for which downsamling is occuring "all around" (that is, no resizing by making one dimension smaller and the other larger).
And it will be fast.
Correct resize
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Correct resize
The rose: image is a reduction of another image which you can get fromNicolasRobidoux wrote:No matter how much I like it, I'm not sure rose is the very best test image for enlargements because it appears that this thumnail was produced with some sharpening or most likely a ringing scheme (I'd guess (tensor) Lanczos 3 lobes).
http://www.imagemagick.org/Usage/img_ph ... e_orig.png
This I recieved from Cristy, but I do not know if this was the original or where he got it from. It has been around as long a IM has.
I just happen to like using it for examples as it is the only 'photo' built-in image. I mean other than mostly bitmap 'patterns' you really only have a choice of rose: logo: netscape: granite:
Hold we now have a new addition -- wizard:
Though it seems to have a little too much white space for my liking. Would have been better off in portrait orientation too.
I'll submit that to Cristy.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Correct resize
While the filter is triangle, it isn't really bilinear, which is purely orthogonal use of the triangle filter. An EWA Triangle is more of a 'Cone' Filter. See table at the bottom of...NicolasRobidoux wrote:Now for a nice theoretical surprise:
EWA triangle (that is, Clamped Elliptical Weighted Averaging resampling with the bilinear filter kernel) should be a decent scheme in any situation for which downsamling is occuring "all around" (that is, no resizing by making one dimension smaller and the other larger).
And it will be fast.
http://www.imagemagick.org/Usage/resize ... terpolated
Actually I think Hermite may be better!
I would like to see Hermite implemented as a fast, direct, unscaled point lookup, interpolation filter too.
Same with Catrom. The current 'Bicubic' interpolation filter is actually a Lagrange-3 cubic filter.
The very old bi-cubic interpolator 'Spline' is actually based on the B-Spline filter.
I probably should create a table of equivalences between Unscaled Interpolators vs Interpolated Resize Filters.
Perhaps I should actually move the whole 'interpolation' examples to just before Resize Filters. Or even split Filters as a separate page to resize. Great another ToDo! (don't mind me -- I'm just mumbling out loud!)
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: Correct resize
I gathered this from some previous "thinking out louds."anthony wrote:...
Actually I think Hermite may be better!
...
I agree that Hermite may be better when, for example, enlarging in one direction and shrinking in the other.
However, I suspect that resize or distort triangle will be less aliased (less moire, in particular) than Hermite when "downsampling all around." But I may be wrong.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Correct resize
For upsampling hermite, and triangle is probably good.
ASIDE: A Resized upscale produce the same as there equivelent interpolations as the resize filter becomes 'unscaled'.
For downsampling a Sinc filter works better.
I have not compared Resize Sinc-based filters against Distort Jinc-based filters for downsampling.
Only the upsampling test with the rose which clearly shows the removal of 'jaggies' (block artifacts)
ASIDE: A Resized upscale produce the same as there equivelent interpolations as the resize filter becomes 'unscaled'.
For downsampling a Sinc filter works better.
I have not compared Resize Sinc-based filters against Distort Jinc-based filters for downsampling.
Only the upsampling test with the rose which clearly shows the removal of 'jaggies' (block artifacts)
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: Correct resize
I have compared Jinc VS Sinc for downsampling, and the preliminary results are that Jinc is (slightly) better.anthony wrote:For upsampling hermite, and triangle is probably good.
ASIDE: A Resized upscale produce the same as there equivelent interpolations as the resize filter becomes 'unscaled'.
For downsampling a Sinc filter works better.
I have not compared Resize Sinc-based filters against Distort Jinc-based filters for downsampling.
Only the upsampling test with the rose which clearly shows the removal of 'jaggies' (block artifacts)
So you know what I'm after w.r.t. using filters without negative lobes for downsampling:
I have a nonlinear ("adaptive") scheme, named Nohalo, which is good for upsampling and which, as the name indicate, does not produce any ringing. It is better than Hermite, for example. Nohalo is already implemented in VIPS/NIP2; also in a GEGL branch, in an outdated prototype version (I need to crack the whip on one of my grad students )
For GEGL and VIPS/NIP2 ("competitors" of ImageMagick, kind of), I want to blend Nohalo with a scheme good for downsampling, with blending weights that depend on the transformation being applied (locally: when warping or doing perspective, one can switch from upsampling to downsampling within the same image).
So: I agree that a windowed Sinc (Jinc) is better when downsampling in general, but there are situations (certain types of art, for example: think old-style serigraphs or Matisse scissor art; apparently, some scientific-medical situations as well) in which ringing is a no-no. I'm hoping to set up Nohalo with the chosen downsampler as the preferred option in such situations. For this to be the case across the board I need to figure out what the best downsampling scheme with no (or almost no) ringing is.
At this point, my hunch is that it's going to be resize or distort triangle, quadratic or cubic (not Hermite), possibly but probably not with some blur < 1, or some version of Gaussian blur.
I'll keep you posted on what I find, and will read your comments with interest.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Correct resize
A year has passed, and I though I better add an update to this discssion, as it is being referenced from IM examples.
In ImageMagick version 6.7.5 the colorspace handling was changed (rather than waiting for IMv7)
Images are now assumed to be in sRGB (as per web conventions) when created or read in, and -colorspace RGB converts the time to linear-RGB. however when images are save both sRGB or RGB will save the image as is JPEG and PNG image file formats (no automatic conversion).
NOTE: converting to CMYK also now removes the non-linear component from sRGB colorspace.
Because of the resizing images using corrected colorspace now requires the colorspace arguments to be swaped.
As such this is now the way to do colorspace correction...
See IM Examples, Resize with Colorspace Correction.
http://www.imagemagick.org/Usage/resize ... colorspace
Note Gamma correction remains unchanged!
In ImageMagick version 6.7.5 the colorspace handling was changed (rather than waiting for IMv7)
Images are now assumed to be in sRGB (as per web conventions) when created or read in, and -colorspace RGB converts the time to linear-RGB. however when images are save both sRGB or RGB will save the image as is JPEG and PNG image file formats (no automatic conversion).
NOTE: converting to CMYK also now removes the non-linear component from sRGB colorspace.
Because of the resizing images using corrected colorspace now requires the colorspace arguments to be swaped.
As such this is now the way to do colorspace correction...
Code: Select all
convert image.png -colorspace RGB -resize 50% -colorspace sRGB image_half.png
http://www.imagemagick.org/Usage/resize ... colorspace
Note Gamma correction remains unchanged!
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: Correct resize
When TIFF 16 bit three channel is read (and there is no embedded profile), is it assumed to be sRGB?
Same when there is a profile but import is not used?
Same when there is a profile but import is not used?
Re: Correct resize
All images are assumed sRGB unless the metadata says otherwise (e.g. gamma 1.0 or embedded profile). We could assume that only 8-bit images are sRGB but its difficult to justify since almost all devices (cameras, LCD, etc.) have adopted the sRGB standard. You can override this assumption, by specifying otherwise on the command-line (e.g. -set colorspace RGB for linear RGB).