Correct resize

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".

Re: Correct resize

Postby NicolasRobidoux » 2011-03-31T11:49:10+00:00

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.
NicolasRobidoux
 
Posts: 1937
Joined: 2010-08-28T11:16:00+00:00
Location: Copenhagen, Denmark

Re: Correct resize

Postby anthony » 2011-03-31T17:07:07+00:00

NicolasRobidoux 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).

The rose: image is a reduction of another image which you can get from
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
http://www.imagemagick.org/Usage/
User avatar
anthony
 
Posts: 8731
Joined: 2004-05-31T19:27:03+00:00
Location: Brisbane, Australia

Re: Correct resize

Postby anthony » 2011-03-31T17:22:02+00:00

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.


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...
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
http://www.imagemagick.org/Usage/
User avatar
anthony
 
Posts: 8731
Joined: 2004-05-31T19:27:03+00:00
Location: Brisbane, Australia

Re: Correct resize

Postby NicolasRobidoux » 2011-03-31T17:36:54+00:00

anthony wrote:...
Actually I think Hermite may be better!
...

I gathered this from some previous "thinking out louds."

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.
NicolasRobidoux
 
Posts: 1937
Joined: 2010-08-28T11:16:00+00:00
Location: Copenhagen, Denmark

Re: Correct resize

Postby anthony » 2011-03-31T18:55:09+00:00

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)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
http://www.imagemagick.org/Usage/
User avatar
anthony
 
Posts: 8731
Joined: 2004-05-31T19:27:03+00:00
Location: Brisbane, Australia

Re: Correct resize

Postby NicolasRobidoux » 2011-04-01T04:48:12+00:00

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)

I have compared Jinc VS Sinc for downsampling, and the preliminary results are that Jinc is (slightly) better.

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.
NicolasRobidoux
 
Posts: 1937
Joined: 2010-08-28T11:16:00+00:00
Location: Copenhagen, Denmark

Re: Correct resize

Postby anthony » 2012-03-28T19:18:25+00:00

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...
Code: Select all
   convert   image.png  -colorspace RGB  -resize 50%  -colorspace sRGB  image_half.png


See IM Examples, Resize with Colorspace Correction.
http://www.imagemagick.org/Usage/resize ... colorspace

Note Gamma correction remains unchanged!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
http://www.imagemagick.org/Usage/
User avatar
anthony
 
Posts: 8731
Joined: 2004-05-31T19:27:03+00:00
Location: Brisbane, Australia

Re: Correct resize

Postby NicolasRobidoux » 2012-03-30T06:03:38+00:00

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?
NicolasRobidoux
 
Posts: 1937
Joined: 2010-08-28T11:16:00+00:00
Location: Copenhagen, Denmark

Re: Correct resize

Postby magick » 2012-03-30T07:19:37+00:00

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).
User avatar
magick
Site Admin
 
Posts: 9662
Joined: 2003-05-31T11:32:55+00:00

Previous

Return to Users

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Google Adsense [Bot], Majestic-12 [Bot] and 12 guests