Image Resampling and SNR

Started Jul 28, 2015 | Discussions thread
ForumParentFirstPrevious
Flat view
Joofa Senior Member • Posts: 2,791
Image Resampling and SNR

Hi,

The following is a simulation of what I wrote here:

http://www.dpreview.com/forums/post/56182609

(2) Simulation: This is what I'm thinking about, but I have not tried. Take a natural image. Assume it is noise free and pure signal. Prepare another layer of the same size with noise parameters of your choice, ideally suited to (i.e. derived from) the numbers in your 'signal' image. Now if you add them together you may consider them as a 'real' natural image that is a blend of signal + noise. Figure out SNR using both layers. Now, run your favorite resampling algorithm (linear one) on both layers. If you add them together again you may consider it the 'real' resampled image. Again do the SNR calc on both resampled layers. Compare it with the original number.

The following Lanczos 3 resampling kernel was used for resampling.

Lanczos 3 Resampling Kernel

An original image was downsampled and upsampled 2x:

Image Resampling and SNR

Image SNR

Original: 21.249

Upsampled: 22.227

Downsampled: 28.250

Upsampling SNR is slightly higher than the original. The downsampled SNR improves by about 7 db, a little higher than 6 db as in the case of binning.

I'm including the Octave / Matlab code I wrote for this. If anybody is interested they can use it for their own experiments, especially for different resampling ratios, and resampling kernels other than Lanczos.

# Image Resampling & SNR
# DJ Joofa

function r = downsample2d(s, f, k)
[m,n] = size(s);
r = conv2(s, (k'*k)/sum(sum(k'*k)), 'same');
r = r(1:f:m, 1:f:n);
endfunction

function r = upsample2d(s, f, k)
[m,n] = size(s);
r = zeros(f*[m,n]-(f-1));
r(1:f:m*f,1:f:n*f) = s;
r = conv2(r, (k'*k), 'same');
endfunction

function r = lanczos(x, a)
r = sinc(x) .* ((abs(x) <= a) .* sinc(x/a));
endfunction

function r = pow(x)
r = (x(:)' * x(:)) / length(x(:));
endfunction

function [dd2, du2, dn, dnd2, dnu2] = reseg(d)
[m,n] = size(d);

dp=randp(d)-d;     # Poisson Shot Noise
dg=randn(m,n)*5; # Gaussian Read Noise of 5e-
dn = dp + dg;       # Total noise

# Down & Up Sample Signal
dd2=downsample2d(d,2,lanczos([-3:1/2:3],3));
du2=upsample2d(d,2,lanczos([-3:1/2:3],3));

# Down & Up Sample Noise
dnd2=downsample2d(dn,2,lanczos([-3:1/2:3],3));
dnu2=upsample2d(dn,2,lanczos([-3:1/2:3],3));
endfunction

###############

d = double(imread('goofs.jpg'));
[dd2, du2, dn, dnd2, dnu2] = reseg(d);
10*log10([pow(d) pow(du2) pow(dd2)] ./ [pow(dn) pow(dnu2) pow(dnd2)])
21.249 22.227 28.250

-- hide signature --
ForumParentFirstPrevious
Flat view
ForumParentFirstPrevious
Keyboard shortcuts:
FForum PPrevious NNext WNext unread UUpvote SSubscribe RReply QQuote BBookmark MMy threads
Color scheme? Blue / Yellow