best downsampling method for DSLR photographs

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?".
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: best downsampling method for DSLR photographs

Post by NicolasRobidoux » 2012-09-26T06:05:12-07:00

henrywho wrote:...I have always been advocating the direct use of EWA-Lagrange or even EWA-Catrom down-sampling instead of downsampling-then-USM. 8)
Have you experimented with various numbers of EWA-Lagrange lobes, and compared with using unwindowed (meaning Box) Jinc and Sinc, the latter orthogonally or radially?

henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: best downsampling method for DSLR photographs

Post by henrywho » 2012-09-26T19:20:33-07:00

I wanna speak the same language with you and so I am trying to compile ImageMagick v7 under mingw x64. But it's not as easy as I thought.... :(

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: best downsampling method for DSLR photographs

Post by NicolasRobidoux » 2012-09-27T04:15:31-07:00

@Henry:
I can't help you with this (linux snob) but there is very little difference between the HDRI versions IM6 and IM7 as far as resampling and sigmoidizing and colorspace conversions go.
And if you stick to EWA, basically none.
Cristy et al are pretty disciplined about porting back everything that can.
-----
This being said, you're probably more likely to get assistance by having a "Compiling IM7 under MinGW" post in Users.
P.S. Sigmoidization is done with a LUT in IM6 and directly in IM7, but this is 1-bit difference in 8-bit sRGB unless you push things really far. Impossible to see.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: best downsampling method for DSLR photographs

Post by NicolasRobidoux » 2012-10-02T16:26:34-07:00

My opinions RE: the best downsampling methods, applicable to DSLR photographs, are found here: http://www.imagemagick.org/Usage/resize ... downsample
This is a work in progress, but the "recommended downsampling techniques" section should be pretty stable.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: best downsampling method for DSLR photographs

Post by NicolasRobidoux » 2012-10-03T07:44:44-07:00

@Henry:
If you want a fairly sharp scheme without a second halo, RobidouxSharp, to my eye, looks pretty good.
Have you tried it? You find it too soft?
P.S. Actually, it does not suppress moire quite well enough. Forget that.

henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: best downsampling method for DSLR photographs

Post by henrywho » 2012-10-03T08:43:35-07:00

RobidouxSharp? Yes, we tested it some time ago.

henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: best downsampling method for DSLR photographs

Post by henrywho » 2012-10-04T05:57:50-07:00

And I suggest giving LanczosRadius3 another name when it is made a built-in filter..... coz it is actually sharper than LanczosSharp. :lol:

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: best downsampling method for DSLR photographs

Post by NicolasRobidoux » 2012-10-04T06:11:26-07:00

henrywho wrote:And I suggest giving LanczosRadius3 another name when it is made a built-in filter..... coz it is actually sharper than LanczosSharp. :lol:
It's the weight of history:
Lanczos2Sharp (the "classic" version of the "new" one found in Adam Turcotte's upcoming thesis) is significantly sharper than Lanczos2. Lanczos2Sharp came first. Applying the same design rule to Lanczos (3-lobe) gives something which is barely sharper than plain Lanczos 3 (blur=.98 with the classic version, .99 with the new version). But same rules -> same naming pattern.
-----
What it is, really, is that EWA Lanczos (without tweaking) is almost "perfect" as is. Not quite the case with EWA Lanczos2.
-----
BTW, I've broken my back trying to improve on LanczosRadius3. So far, no good.
Actually, I've broken my back trying to improve on anything EWA, and I pretty much only get schemes that basically give identical results to existing ones, just more complicated and expensive.
I'm approaching the tail of the logistic curve ;)
Last edited by NicolasRobidoux on 2012-10-04T11:10:28-07:00, edited 1 time in total.

User avatar
fmw42
Posts: 25556
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: best downsampling method for DSLR photographs

Post by fmw42 » 2012-10-04T11:01:09-07:00

LanczosR3sharp?

henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: best downsampling method for DSLR photographs

Post by henrywho » 2012-10-05T01:50:40-07:00

btw, would you mind adding a few line explaining "interpolatory" and "non-interpolatory" methods?

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: best downsampling method for DSLR photographs

Post by NicolasRobidoux » 2012-10-05T04:13:12-07:00

henrywho wrote:btw, would you mind adding a few line explaining "interpolatory" and "non-interpolatory" methods?
I will.
Also: The advice for "ratio almost 1" that's in there is almost certainly non-optimal. I'm pretty sure that Lanczos and Cosine are not the best when barely resizing. Ginseng is about as sharp as it should go. And sigmoidizing is probably better than not. And tensor Triangle is probably a good choice. And I need to test things more.
Work in progress...

henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: best downsampling method for DSLR photographs

Post by henrywho » 2012-10-08T04:12:21-07:00

NicolasRobidoux wrote:
henrywho wrote:...I have always been advocating the direct use of EWA-Lagrange or even EWA-Catrom down-sampling instead of downsampling-then-USM. 8)
Have you experimented with various numbers of EWA-Lagrange lobes, and compared with using unwindowed (meaning Box) Jinc and Sinc, the latter orthogonally or radially?
Just did some tests:

Code: Select all

convert backpack.jpg -set colorspace srgb -colorspace rgb -define filter:filter=Jinc -define filter:window=Jinc -define filter:lobes=2 -define filter:blur=0.8 -distort resize 1733x1163! -colorspace srgb -quality 95% backpack_EWA_Lanczos2US.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -define filter:filter=Jinc -define filter:window=Jinc -define filter:lobes=3 -define filter:blur=0.8 -distort resize 1733x1163! -colorspace srgb -quality 95% backpack_EWA_Lanczos3US.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -define filter:filter=Jinc -define filter:window=Jinc -define filter:lobes=4 -define filter:blur=0.8 -distort resize 1733x1163! -colorspace srgb -quality 95% backpack_EWA_Lanczos4US.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -filter Catrom    -distort resize 1733x1163!                            -colorspace srgb -quality 95% backpack_EWA_Catrom.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -filter Lagrange  -distort resize 1733x1163!                            -colorspace srgb -quality 95% backpack_EWA_Lagrange.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -filter Robidoux  -distort resize 1733x1163!                            -colorspace srgb -quality 95% backpack_EWA_Robidoux.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -filter Robidoux  -distort resize 1733x1163! -unsharp 1.5x1+0.7+0.02    -colorspace srgb -quality 95% backpack_EWA_Robidoux_USM_a.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -filter Robidoux  -distort resize 1733x1163! -unsharp 0x0.75+0.75+0.008 -colorspace srgb -quality 95% backpack_EWA_Robidoux_USM_b.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -filter Quadratic -distort resize 1733x1163!                            -colorspace srgb -quality 95% backpack_EWA_Quadratic.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -filter Quadratic -distort resize 1733x1163! -unsharp 1.5x1+0.7+0.02    -colorspace srgb -quality 95% backpack_EWA_Quadratic_USM_a.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -filter Quadratic -distort resize 1733x1163! -unsharp 0x0.75+0.75+0.008 -colorspace srgb -quality 95% backpack_EWA_Quadratic_USM_b.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -filter Spline    -distort resize 1733x1163!                            -colorspace srgb -quality 95% backpack_EWA_Spline.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -filter Spline    -distort resize 1733x1163! -unsharp 1.5x1+0.7+0.02    -colorspace srgb -quality 95% backpack_EWA_Spline_USM_a.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -filter Spline    -distort resize 1733x1163! -unsharp 0x0.75+0.75+0.008 -colorspace srgb -quality 95% backpack_EWA_Spline_USM_b.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -define filter:window=Quadratic -define filter:lobes=3 -distort resize 1733x1163!                            -colorspace srgb -quality 95% backpack_EWA_QuadraticJinc.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -define filter:window=Quadratic -define filter:lobes=3 -distort resize 1733x1163! -unsharp 1.5x1+0.7+0.02    -colorspace srgb -quality 95% backpack_EWA_QuadraticJinc_USM_a.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -define filter:window=Quadratic -define filter:lobes=3 -distort resize 1733x1163! -unsharp 0x0.75+0.75+0.008 -colorspace srgb -quality 95% backpack_EWA_QuadraticJinc_USM_b.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -define filter:window=Spline -distort resize 1733x1163!                            -colorspace srgb -quality 95% backpack_EWA_SplineJinc_USM.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -define filter:window=Spline -distort resize 1733x1163! -unsharp 1.5x1+0.7+0.02    -colorspace srgb -quality 95% backpack_EWA_SplineJinc_USM_a.png
convert backpack.jpg -set colorspace srgb -colorspace rgb -define filter:window=Spline -distort resize 1733x1163! -unsharp 0x0.75+0.75+0.008 -colorspace srgb -quality 95% backpack_EWA_SplineJinc_USM_b.png
The two USM parameters are taken from ImageMagick pages. BTW, I think USM should be done under Linear RGB otherwise it will greatly affect the overall brightness of some feature patterns

=> EWA/QuadraticJinc/USM does a wonderful job, giving nice perceived sharpness without (or with minimal) moire patterns.
=> EWA/Lagrange and EWA/Lanczos4/blur=0.8 closely follow, with slight moire patterns.
=> EWA/Catrom and EWA/Robidoux are giving worse moire pattern, barely acceptable.
=> EWA/Lanczos2/blur=0.8 and EWA/Lanczos3/blur=0.8 are generating far too much moire.
=> Others are not sharp enough.

henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: best downsampling method for DSLR photographs

Post by henrywho » 2012-10-08T04:29:30-07:00

Another test case (a dog photo taken using IPhone5): http://www.dcfever.com/phones/viewsampl ... cture=7632

Code: Select all

convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -define filter:filter=Jinc -define filter:window=Jinc -define filter:lobes=2 -define filter:blur=0.8 -distort resize 1021x769! -colorspace srgb -quality 95% dog_ip5_EWA_Lanczos2US.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -define filter:filter=Jinc -define filter:window=Jinc -define filter:lobes=3 -define filter:blur=0.8 -distort resize 1021x769! -colorspace srgb -quality 95% dog_ip5_EWA_Lanczos3US.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -define filter:filter=Jinc -define filter:window=Jinc -define filter:lobes=4 -define filter:blur=0.8 -distort resize 1021x769! -colorspace srgb -quality 95% dog_ip5_EWA_Lanczos4US.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -filter Catrom    -distort resize 1021x769!                            -colorspace srgb -quality 95% dog_ip5_EWA_Catrom.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -filter Lagrange  -distort resize 1021x769!                            -colorspace srgb -quality 95% dog_ip5_EWA_Lagrange.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -filter Robidoux  -distort resize 1021x769!                            -colorspace srgb -quality 95% dog_ip5_EWA_Robidoux.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -filter Robidoux  -distort resize 1021x769! -unsharp 1.5x1+0.7+0.02    -colorspace srgb -quality 95% dog_ip5_EWA_Robidoux_USM_a.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -filter Robidoux  -distort resize 1021x769! -unsharp 0x0.75+0.75+0.008 -colorspace srgb -quality 95% dog_ip5_EWA_Robidoux_USM_b.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -filter Quadratic -distort resize 1021x769!                            -colorspace srgb -quality 95% dog_ip5_EWA_Quadratic.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -filter Quadratic -distort resize 1021x769! -unsharp 1.5x1+0.7+0.02    -colorspace srgb -quality 95% dog_ip5_EWA_Quadratic_USM_a.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -filter Quadratic -distort resize 1021x769! -unsharp 0x0.75+0.75+0.008 -colorspace srgb -quality 95% dog_ip5_EWA_Quadratic_USM_b.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -filter Spline    -distort resize 1021x769!                            -colorspace srgb -quality 95% dog_ip5_EWA_Spline.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -filter Spline    -distort resize 1021x769! -unsharp 1.5x1+0.7+0.02    -colorspace srgb -quality 95% dog_ip5_EWA_Spline_USM_a.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -filter Spline    -distort resize 1021x769! -unsharp 0x0.75+0.75+0.008 -colorspace srgb -quality 95% dog_ip5_EWA_Spline_USM_b.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -define filter:window=Quadratic -define filter:lobes=3 -distort resize 1021x769!                            -colorspace srgb -quality 95% dog_ip5_EWA_QuadraticJinc.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -define filter:window=Quadratic -define filter:lobes=3 -distort resize 1021x769! -unsharp 1.5x1+0.7+0.02    -colorspace srgb -quality 95% dog_ip5_EWA_QuadraticJinc_USM_a.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -define filter:window=Quadratic -define filter:lobes=3 -distort resize 1021x769! -unsharp 0x0.75+0.75+0.008 -colorspace srgb -quality 95% dog_ip5_EWA_QuadraticJinc_USM_b.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -define filter:window=Spline -distort resize 1021x769!                            -colorspace srgb -quality 95% dog_ip5_EWA_SplineJinc_USM.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -define filter:window=Spline -distort resize 1021x769! -unsharp 1.5x1+0.7+0.02    -colorspace srgb -quality 95% dog_ip5_EWA_SplineJinc_USM_a.png
convert dog_ip5.jpg -set colorspace srgb -colorspace rgb -define filter:window=Spline -distort resize 1021x769! -unsharp 0x0.75+0.75+0.008 -colorspace srgb -quality 95% dog_ip5_EWA_SplineJinc_USM_b.png
This test case demonstrates another "feature" of USM: It enhances the "3D" look of the grass. EWA/Catrom and EWA/Lagrange can also simulate this effect. EWA/LanczosN/blur=0.8 cannot.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: best downsampling method for DSLR photographs

Post by NicolasRobidoux » 2012-10-08T07:13:35-07:00

@Henry:
As usual, useful and to the point.
I will think.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: best downsampling method for DSLR photographs

Post by NicolasRobidoux » 2012-10-08T07:29:37-07:00

The first thing I'll add is that the Keys methods are only truly recommended if you really cannot have more than two halos.
I really don't recommend them over any of the methods listed before them in "The Recommendations", so I should make this clearer in the text.
This being said, some people like some of them, a lot.

Post Reply