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 »

Fred: And yes: In my back of the envelope mind, there was no way that anything past RobidouxSharp could be any good. My grad student and Henry and you sure are blowing my back of the envelope off the table :(
User avatar
fmw42
Posts: 25562
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 »

Some more experiments:

1)
convert zelda3.png -filter catrom -define filter:blur=0.7 -distort resize 200% zelda3_200_distort_catrom_b0p7.png

2)
convert zelda3.png -define filter:support=2.5 -filter lagrange -distort resize 200% zelda3_200_distort_lagrange_order4.png
convert zelda3.png -define filter:support=3 -filter lagrange -distort resize 200% zelda3_200_distort_lagrange_order5.png
convert zelda3.png -define filter:support=3.5 -filter lagrange -distort resize 200% zelda3_200_distort_lagrange_order6.png

The catrom with filter:blur=0.7 is sharper than the default catrom (filter:blur=1). But it shows stair-stepped artifacts

The lagrange of order 4 (filter:support=2.5) is even sharper, but has far less artifacts, though there is some in comparison to the default order 3 (filter:support=2) lagrange. This is to be expected as the even order lagrange filters have discontinuous slopes. See (http://www.imagemagick.org/Usage/resize/#lagrange).

The order 5 lagrange is only slightly sharper at best than the order 3 (default) lagrange.

There seems to be no or little increase in sharpness or difference, when using lagrange of order 6 in comparison to order 4.

3)
convert zelda3.png -filter catrom -define filter:lobes=2 -distort resize 200% zelda3_200_distort_catrom_lobes2.png (default)
convert zelda3.png -filter catrom -define filter:lobes=3 -distort resize 200% zelda3_200_distort_catrom_lobes3.png
convert zelda3.png -filter catrom -define filter:lobes=4 -distort resize 200% zelda3_200_distort_catrom_lobes4.png

Catrom with lobes=3,4 are not any sharper than with lobes=2.
User avatar
fmw42
Posts: 25562
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 »

The last few post here have gone off track from the subject about downsampling and have turned into upsampling. Perhaps this topic should be linked to viewtopic.php?f=22&t=21435&start=15
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 »

fmw42 wrote:...
What surprised me about my experiments with IM above was that the EWA versions of Catrom and Lagrange were noticeably better than the orthogonal ones.
...
(Gasp!)
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 »

Anthony: If downsampling through Lab or actually anything else than linear RGB or XYZ turns out to be better than these last two, you'll shock more than just me.
henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: best downsampling method for DSLR photographs

Post by henrywho »

NicolasRobidoux wrote:Fred: Your observations jive with "why" Henry tried EWA Catmull-Rom: To give "pixel peepers" all the sharpness they crave. His context was downsampling, but still.
Hey, I thought I had made myself clear in some posts that I prefer EWA Lagrange over EWA Catrom for downsizing in place of unsharpening. 8)
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 »

henrywho wrote:...
Hey, I thought I had made myself clear in some posts that I prefer EWA Lagrange over EWA Catrom for downsizing in place of unsharpening.
Message received: I was so certain that EWA Catmull-Rom would never amount to anything that I did not even bother to try it even though the code was right there.
Actually, I was even more certain that EWA Lagrange had to be junk, so I did not record that I should consider it, despite yours (and Fred's) strong hints.
I thought I had shades on, but they were blinders.
-----
Plain unwindowed Jinc has to be given another look. They have been visited before I believe, but only in the context of enlarging. Reducing is a different ball o'wax.
When downsampling, the raison d'etre of windowing, namely reducing slope discontinuities, is not so important. Getting rid of the window function thus seems reasonable.
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 »

henrywho wrote:...
Hey, I thought I had made myself clear in some posts that I prefer EWA Lagrange over EWA Catrom for downsizing in place of unsharpening.
@Henry: Thank you, very much, for the clarification. Sometimes I do things too quickly. For this reasons, messages that clearly dot the i's are a friend.
User avatar
fmw42
Posts: 25562
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 »

henrywho wrote:Hey, I thought I had made myself clear in some posts that I prefer EWA Lagrange over EWA Catrom for downsizing in place of unsharpening.
Henry, in my quick tests, I did not see any significant difference. I would appreciate hearing from you what differences you saw and was this downsampling, upsampling or both. I presume these were very high quality or perhaps raw images that you processed, something with which I really have no experience.
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 »

Here is an example of downsampling with sigmoidization, compared to downsampling through linear RGB (linear light being better at tonal faithfulness). It's the backpack image which Pictus (Luiz E. Vasconcellos) has used for tests earlier in this thread, and which Henry HO pointed us to.
Downsampled with EWA LanczosSharp through linear RGB:
Image
Downsampled with EWA LanczosSharp sigmoidized with contrast = 6, pretty much the reasonable limit when downsampling:
Image
The code:

Code: Select all

magick BackPack.jpg -colorspace RGB -filter LanczosSharp -distort resize 1200x1200 -colorspace sRGB EWALanczosSharp.0.png
for the first, and

Code: Select all

magick BackPack.jpg -colorspace RGB +sigmoidal-contrast 6 -filter LanczosSharp -distort resize 1200x1200 -sigmoidal-contrast 6 -colorspace sRGB EWALanczosSharp.6.png
for the second.
To see clearly the differences, you should flicker between the two images. To see the difference in haloing, enlarge and follow sharp boundaries, for example where wood meets sky.
The sigmoidized version not only has decreased halos, but it also has slightly sharper and less jaggy thin features. Look at the zipper track.
But there is no question that sigmoidization affects tonal faithfulness in areas where pixels with midtones mixed in with more extreme values.
henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: best downsampling method for DSLR photographs

Post by henrywho »

Yup, there are fewer halos; unfortunately, it also reduces the reflection of the nylon fibre vastly. May we use a 2-lobe downsizer with lower sigmoidization value?

The backpack photo is a special use-case. EWA Catrom, "Cub-grange" (cubic @ c=0.4846), Lagrange and Lanczos2VerySharp (blur=0.88826421508540347), in decreasing order of acutance, are actually preserving the nylon texture better than "gently-sharp" schemes like GinSeng under such a big down-sampling operation.
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 »

@Henry: As usual, you bring some very interesting observations and ideas to the table.
Thank you.
P.S. You tried Ginseng (-resize with Jinc-windowed Sinc)?
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 »

I am starting to get the hint that sigmoidization is indeed a bad idea when downsampling if there are fine textures. It may only be a general recommendation when dealing with "synthetic" images (like line drawings).
This backpack test image is wonderful. Sigmoidization makes everything look at least as good EXCEPT on the backpack itself.
It looks like when there is actual, real, natural moire that one wants to preserve, sigmoidization messes it up.
Even the webbing straps are affected.
-----
When downsizing, linear light strikes again.
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 »

Here is Ginseng through linear light (no sigmoidization):
Image
Code:

Code: Select all

magick BackPack.jpg -colorspace RGB -define filter:window=Jinc -define filter:lobes=3 -resize 1200x1200 -colorspace sRGB Ginseng.0.png
Yes, there is halo when one pixel-peeks. But the textures are nicely preserved.
Last edited by NicolasRobidoux on 2012-09-19T06:32:22-07:00, edited 2 times in total.
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 »

Isn't it funny? I spend all this time trying to minimize (artificial) moire, and then fall in love with a scheme that preserves (natural) moire.
Post Reply