There was a popular thread a while ago with a similar title, only referring to up-sampling.
http://www.luminous-landscape.com/forum/index.php?topic=77949.0
In doing some testing of downsampling algorithms as reducers of image noise, I found some interesting -- at least to me; I should get out more -- properties of power-of-two ratios for downsampling.
http://blog.kasson.com/?p=7101
http://blog.kasson.com/?p=7123
On Bart's website, there is a post that indicates that AA filtering with a Gaussian kernel with sigma = 0.2 or 0.3 over the magnification ratio is a reasonable compromise between sharpness and aliasing.
It's clear that there are some downressing percentages that are more effective at reducing noise in the image than other percentages that are very close. In fact, it looks like there are some discontinuities in the curves.
In the past, I have, when faced with down resing with big ratios, done it in factor of two stages. I dunno why, it just seemed like a good idea. Maybe better than I knew?
Noise reduction is IMHO not the primary goal (losing resolution may be worse than a bit of organic looking noise), but noise should not be made worse by the other artifacts (like aliasing) either.
Well, Gaussian blur is a relatively crude filter and more blurry (for spatial frequencies that need to remain resolvable after down-sampling) than needed, if we can use better methods.
I would also not only look at the noise effects in isolation (unless one needs to down-sample images of random noise). Do also check whether other attributes of image quality, e.g. resolution and ringing take a hit, which may explain some of the dips in RMS noise near integer fractions of scale.
Maybe there is also some explanation to be found in the exact implementation of the algorithm. Also be aware of image edge artifacts that may skew the total image metrics. Photoshop for example produces artifacts at image edges because it doesn't account for 'virtual pixels' when the filter window reaches the edge of the image data).
I would also not only look at the noise effects in isolation (unless one needs to down-sample images of random noise). Do also check whether other attributes of image quality, e.g. resolution and ringing take a hit, which may explain some of the dips in RMS noise near integer fractions of scale.
Here's where I got the idea:
http://bvdwolf.home.xs4all.nl/main/foto/down_sample/down_sample.htm
I'm extending the images symmetrically before filtering. I'll try cropping after filtering, They are 4000x4000 images, so he edge effects should get buried.
I'm still puzzled by the dips in your noise data. I have attached a summary of EWA down-sampled Gaussian noise images (AdobeRGB gamma 2.2 precompensated), using the adjusted Keys Cubic filter with default deconvolution sharpening as implemented in my script (http://www.luminous-landscape.com/forum/index.php?topic=91754.0). I made an extra effort of sampling near the 50% scale point, and found no evidence of a dip ...
The noise reduction is almost perfectly in line with the (EWA) averaging window size.
Bart, that is one beautiful curve! I have been resisting adding one more image processing tool to my toolbox, but you've convinced me. I'll download ImageMagick, run your script to verify, then look at it for clues as to how to call ImageMagick from Matlab, and report results. Then I'll look at integrating ImageMagick downsampling into my camera model. That'll take a while.
I will also report on how the Ps (and maybe Lr) downsampling tools work wrt noise -- maybe there's a problem with the Matlab imresize code. For extra credit, maybe QImage, too.
...If you are interested in implementing EWA with a Keys cubic, you can also look at the implementation of the downsampling component of the LoHalo image resampling function: https://git.gnome.org/browse/gegl/tree/gegl/buffer/gegl-sampler-lohalo.c (https://git.gnome.org/browse/gegl/tree/gegl/buffer/gegl-sampler-lohalo.c) There is some amount of obfuscation resulting from optimization through the use of mipmaps, which you can skip. And things are bit more complicated given that the resampler can handle arbitrary warps; with aspect ratio preserved, all ellipses are trivially computed discs. (The ImageMagick EWA implementation also handles arbitrary warps.)
Jim, alternatively you could have a look at the 'resize.c' source file from the ImageMagick code distribution, and see if you can implement some of the functionality as Matlab functions.
...
Then I tried again with version 122. This time I got a 16-bit RGB TIFF, but the histogram was centered on zero, not expected the half-scale, and I lost half the noise (the left half).
Suggestions?
Thanks,
Jim
Bart, I downloaded ImageMagick (x64, dynamic), installed it, and ran the test successfully. I downloaded V101 of your script, ran it against a 4000x4000 16-bit sRGB TIFF, each plane of which had a dc level of half-scale with superimposed Gaussian noise with standard deviation one-tenth scale. I told it to downsample to 50%. I got back a 2000x2000 gamma 2.2 grayscale image with the correct dc value, and what looked like the right histogram in Ps. I read it into Matlab, scaled it down to [0,1], and read the sigma as 0.0457160595991501. So far so good.
Then I tried again with version 122. This time I got a 16-bit RGB TIFF, but the histogram was centered on zero, not expected the half-scale, and I lost half the noise (the left half).
Suggestions?
Bart, I modified your V122 script so all the options are in the command line. That's better for when I call it from other programs.
I think this is similar to the graph you posted above in this thread. I'm not sure why I'm getting slightly less noise now, but I don't think it's important at this point.
Note that I have verified the lack of a discontinuity near 0.5 magnification.
I will do some artifact testing with this and the Lr export processing, and then I'll try to incorporate your script into my camera simulator.
...a deconvolution sharpening amount of 50 is 'neutral', the default of 100 is sharpening more than required and is chosen to add some additional punch to the image.
Yet 100 doesn't add an actual peak to the frequency response, it just holds it at about the dc level for a bit longer. That's why I picked it.
I suppose that depends on how it's evaluated. When I use ImageJ to produce a logarithmic (!) FFT power spectrum of the down-sampled Gaussian noise image, it does reveal the boosted frequencies in a radial profile plot.
Bart, I found and fixed a bug in my version of your script. Now I think our results agree. Please have a look and tell me if you see anything wonky.
This looks plausible.
My question, what would be to best way to do the down sampling for my pano rendered @100% in APP?
One thing I've found with rendering @100% in APP is that the image seems much cleaner with less artifacts as well as better sharpness than the same image rendered @50% in APP.
My question, what would be to best way to do the down sampling for my pano rendered @100% in APP?
The problem with this file is its size, over 4GB, can't save it as a tiff.
Qimage would be a possibility as its not that expensive at $70, but will it work with PSB files?
Your math and graphs are beyond my pay grade, but for quite some time now I have used a down sampling method I learned from Jack Flesher which ends up with better small files for the web ... basically stepping down at exactly 50% increments to obtain the final size. I resize the original file to 8 times what I want the final size to be. sometimes this is a pretty big step up, but most of the time it is a very small step down. I then downsample 50% 3 consecutive times (adding a very slight amount of sharpening in 2 of the steps).
The end result is visually better than a single resize down in Photoshop. I’m sure if I understood the process better this could be refined even further (and I’ll try using something other than bi-cubic to see what happens). but it’s simple (in an action) and does give me better results.
In doing some testing of downsampling algorithms as reducers of image noise, I found some interesting -- at least to me; I should get out more -- properties of power-of-two ratios for downsampling.Since this thread was brought back anyways:
Since this thread was brought back anyways:
I think that it is ill-adviced to even consider downsampling for reducing noise. Downsampling (or any conventional resampling) conceptually consists of linear filtering combined with "upsamplers" (inserting M zeros between each sample) and "downsamplers" (dropping every n-th sample). Of these 3 components, only the linear filtering part can sensibly affect image noise.
So why not use a linear filter directly if you prefer that to dedicated noise reduction? MATLAB allows you to design highly complex linear 2-d filters.
I was also assuming that the photographer might have neither the ability, the pocketbook, nor the desire to use Matlab as part of their normal workflow, although Matlab was a convenient tool for me to use to compare algorithms, modulo the complicating difficulty that the Matlab implementations of some downsizing algorithms do not match that of similarly-named algorithms in Ps and other image editing programs.I assume that a skilled Photoshop operator (I am not) can apply complex LTI filters?
I assume that a skilled Photoshop operator (I am not) can apply complex LTI filters?