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 »

I just had to try it. Starting a new thread: viewtopic.php?f=22&t=21415
Last edited by NicolasRobidoux on 2012-07-13T05:02:36-07:00, edited 1 time 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 »

Dane Vandeputte wrote:
NicolasRobidoux wrote: I wager that Eric Brasseur, in his famous post http://www.4p8.com/eric.brasseur/gamma.html, could have fixed things so that the Dalai Lama disappears when downsized through linear light, but looks fine when processed through sRGB.
Yes, this is possible, and just as the Dalai Lama disappears from the downsized linear light image, so too has he disappeared from the unscaled image.
Dane: The Brasseur posting avoids filters with significant negative lobes, and only uses non-sharpening convolutions. I have not worked out the details yet so I'm not sure, but I believe that I may be able make the Dalai Lama disappear from the downsample through linear light without it disappearing from the full size image or the image processed in sRGB. Same, possibly, if I sharpen it.
This hunch is related to the "Sigmoidal resampling" idea. More about this later.
User avatar
Pictus
Posts: 13
Joined: 2012-05-12T11:52:50-07:00
Authentication code: 13
Location: Teresópolis - Rio de janeiro - Brasil

Re: best downsampling method for DSLR photographs

Post by Pictus »

NicolasRobidoux wrote:Henry and Luiz and whoever else feels like testing and posting opinions:
Could you please let me know what you think of EWA Lanczos2Sharpest, Lanczos3Sharpest and Lanczos4Sharpest as downsampling schemes, ideally through linear light?
Sorry for the delay, I need to set my forum options to monitor this thread.
There are millions of Luiz around, but not much Pictus...
So can call me Pictus, if you wish... :D

The Lanczos4 creates too much ringing, but it is useful when the others still left some moiré, see the
backpack test viewtopic.php?f=1&t=20992&start=105#p85248

The Lanczos3 is the safest bet, a good balance between artifacts and acutance.

The Lanczos2 the acutance is a bit low and not noiré free as the Lanczos3, the good part is very low ringing.
Check with the WindMill http://www.mediafire.com/?49ahiwm5ukfu6c9

I bet that most DSLR users will prefer the EWA Catrom or EWA Lanczos3.
The crazy pixel peepers will load one layer with Catrom and another with Lanczos2
and mask the Catrom areas where there is too much halos. :lol:

Here http://www.mediafire.com/i/?rzm5jf4pq3i4ql7 (I do not know who is the owner)
a Sony a900 photo, very good to do some tests...

For anyone interested, here http://dl.dropbox.com/u/4686872/1200_EWA.bat a batch file
I use to resize using many different settings, it is made for ImageMagick V6.
It process TIFF to avoid JPG artifacts...

The batch file creates many files, I load them into Photoshop with Dr. Brown’s Services 2.2.9
Stack-A-Matic
to compare the results, can get at http://www.russellbrown.com/scripts.html
To use go to Photoshop menu File>Scripts>Load files into Stack

Update, Dr. Brown’s Services 2.2.9 is not needed to load files into Stack, sorry!
http://digidelights.blogspot.com.br/201 ... orial.html
Last edited by Pictus on 2012-07-16T12:12:44-07:00, edited 2 times in total.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: best downsampling method for DSLR photographs

Post by Bonzo »

So are all these conversions still relying on what dcraw converts when converting from a CR2 file?

My call to dcraw has been changed as all the images were coming out a bit bright from memory and I changed the -4 to a -6 I think :?
<delegate command="dcraw.exe -6 -w -O "%u.ppm" "%i"" stealth="True" decode="dng:decode"/>

Did dcraw used to be Ufraw?

Anyway I did a test with the batch file and I ended up with alternate too dark files and slightly over exposed files to my eye.
User avatar
Dane Vandeputte
Posts: 14
Joined: 2012-07-01T18:26:53-07:00
Authentication code: 13
Location: Illinois, USA

Re: best downsampling method for DSLR photographs

Post by Dane Vandeputte »

NicolasRobidoux wrote: Dane: The Brasseur posting avoids filters with significant negative lobes, and only uses non-sharpening convolutions. I have not worked out the details yet so I'm not sure, but I believe that I may be able make the Dalai Lama disappear from the downsample through linear light without it disappearing from the full size image or the image processed in sRGB. Same, possibly, if I sharpen it.
This hunch is related to the "Sigmoidal resampling" idea. More about this later.
Since the human eye performs optical lowpass filtering in linear light, I would imagine that any downsampling method seeking to mimic the filtering performed by our eyes (the "holy grail" of downsampling?) would also use linear light (at least initially, and perhaps followed later by nonlinearities). Aside from all the math, this is why I believe that what you seek is impossible, but even as far as the math is concerned, I am still very skeptical that it can be done. Let's just say that I would be extremely impressed if you manage to pull this off. I certainly wish you all the best in your endeavors! :D
Digital image processing and photography enthusiast :)
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 »

@Pictus: Just to make sure, your last comments have to do with orthogonal (-resize) Lanczos or EWA (-distort resize)?
User avatar
Pictus
Posts: 13
Joined: 2012-05-12T11:52:50-07:00
Authentication code: 13
Location: Teresópolis - Rio de janeiro - Brasil

Re: best downsampling method for DSLR photographs

Post by Pictus »

EWA :D

I used the batch file, it got this

Code: Select all

convert %1 -filter Catrom -distort resize 1200x1200 "%~n1_EWAcatromSRGB.tif
convert %1 -colorspace RGB -filter Catrom -distort resize 1200x1200  -colorspace sRGB "%~n1_EWAcatrom.tif

convert %1 -colorspace RGB -filter Lanczos2 -define filter:blur=0.88826421508540347 -distort Resize 1200x1200 -colorspace sRGB "%~n1_EWALanczos2Sharpest.tif
convert %1 -filter Lanczos2 -define filter:blur=0.88826421508540347 -distort Resize 1200x1200 "%~n1_EWALanczos2SharpestSRGB.tif

convert %1 -colorspace RGB -filter Lanczos -define filter:blur=0.88549061701764 -distort Resize 1200x1200 -colorspace sRGB "%~n1_EWALanczos3Sharpest.tif
convert %1 -filter Lanczos -define filter:blur=0.88549061701764 -distort Resize 1200x1200 "%~n1_EWALanczos3SharpestSRGB.tif

convert %1 -colorspace RGB -filter Lanczos -define filter:lobes=4 -define filter:blur=0.88451002338585141 -distort Resize 1200x1200 -colorspace sRGB "%~n1_EWALanczos4Sharpest.tif
convert %1 -filter Lanczos -define filter:lobes=4 -define filter:blur=0.88451002338585141 -distort Resize 1200x1200 "%~n1_EWALanczos4SharpestSRGB.tif
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 »

@Pictus: All clear now.
Thank you very much for these impressions. Adding to my small collection of "opinions" (which pretty much all agree, esp. if one takes into account pixel peepers' sharpness addition).
I also really like standard orthogonal Lanczos 3. I'm not surprised it's so popular.
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 HO: There are many factors at play here, but in one reasonable variant of the "rankings" of filters as enlargement methods for "subcritical" images (well filtered: most likely not much going on near the Nyquist limit), EWA Catmull-Rom comes out at the top of all 3- and 2- and "1"-lobe method. The only ones that beat it are orthogonal Welsh4, Cosine4, Lanczos4 and Hamming4.
I'm shocked! But I figure you may be pleased.
When you enlarge sharper images, EWA Catmull-Rom gets a fairly "ordinary" rank. Which is not surprising.
More details when I put the draft of my student Adam Turcotte's thesis online. (Give it a week.)
Last edited by NicolasRobidoux on 2012-07-24T16:42:33-07:00, edited 1 time in total.
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 »

Just following this last post from Nicolas, so I tried some 2x enlarging experiments with the zelda3.png image.

Image

Ranking in order of increasing sharpness with some ties in the list (shown by color):

convert zelda3.png -filter mitchell -resize 200% zelda3_200_mitchell.png (supposedly the default for magnification)
convert zelda3.png -interpolate bilinear -resize 200% zelda3_200_bilinear.png
convert zelda3.png -interpolate bilinear -filter point -resize 200% zelda3_200_point_bilinear.png
convert zelda3.png -filter lanczos -define filter:lobes=4 -distort resize 200% zelda3_200_distort_lanczos4.png
convert zelda3.png -interpolate filter -filter catrom -resize 200% zelda3_200_filter_catrom.png
convert zelda3.png -interpolate filter -filter lagrange -resize 200% zelda3_200_filter_lagrange.png
convert zelda3.png -filter catrom -distort resize 200% zelda3_200_distort_catrom.png
convert zelda3.png -filter lagrange -distort resize 200% zelda3_200_distort_lagrange.png

The best two in terms of sharpness only were:
-filter catrom -distort resize
-filter lagrange -distort resize.

Both were imperceptibly different in sharpness to my eyes.

The both were noticeably better than -filter lanczos -define filter:lobes=4 -distort resize. Even -interpolate filter -filter catrom/lagrange -resize were better than -filter lanczos -define filter:lobes=4 -distort resize.
Last edited by fmw42 on 2012-07-24T16:43:31-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 »

Fred:
Thank you. Very much.
I'm even more shocked!
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 »

Warning: 200% is not enough to have the ugly artifacts show up.
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 »

NicolasRobidoux wrote:Warning: 200% is not enough to have the ugly artifacts show up.
Yes, I understand. That was why I just ranked them by apparent sharpness and used 2x. I have not tried 8x or anything like that. I was just interested in visual sharpness for modest size increases.

Note my edits to rank the filters in my previous post.
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 »

Nicolas,

Just a side note. The results above parallel what my earlier experiences with image processing showed years ago at the time when resampling was very simple. We had only 3 (orthogonal, non-windowed) methods at the time used for both minification and magnification: nn, bilinear and Key's cubic convolution (Catmull-Rom). The latter was clearly the best in both magnification and minification. At one point I did some experiments with Lagrange resampling and found that it was nearly identical in sharpness to the Key's results. At that time sharpness was more important to our clients than other artifacts.

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.

I just did one more experiment with EWA mitchell and Robidouxsharp:

convert zelda3.png -filter mitchell -distort resize 200% zelda3_200_distort_mitchel.png
convert zelda3.png -filter robidouxsharp -distort resize 200% zelda3_200_distort_robidouxsharp.png

And the Catrom and Lagrange again win out. But that does not surprise me as the Catrom is so far to the extreme of the Mitchell-Netravali Filter Family compared to Mitchell and the Robidoux family.
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: 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.
Post Reply