Will up sampling and down sampling process affect the PSNR of the image?
조회 수: 2 (최근 30일)
이전 댓글 표시
I got this script some where on web. Sorry i could not give credit to the author/s. Suppose i want to measure the PSNR in the script. How would it be possible? Because after applying wavelet and imresize, input and output images are differ in dimension, could not measure the PSNR value. Thanks in Advance. The script is given below:
clear all;
close all;
img1 = imread('cameraman.tif'); %original High resolution image
[height, width, dim] = size(img1);
%// Change - convert to [0,1]
img = im2double(img1);
% %%Downsampling the image by averaging
% avgfilter = fspecial('average', [2 2]);
% avgimg = filter2(avgfilter, img1);
% img = avgimg(1:2:end,1:2:end); %Input low resolution image
[LL,LH,HL,HH] = dwt2(img,'haar'); %Decomposing
%Bicubic interpolation by factor 2 on each subbands
LL1 = imresize(LL,2,'bicubic');
LH1 = imresize(LH,2,'bicubic');
HL1 = imresize(HL,2,'bicubic');
HH1 = imresize(HH,2,'bicubic');
% // Change - Vectorized operations
img3 = img - LL1;
LH13 = img3 + LH1;
HL13 = img3 + HL1;
HH13 = img3 + HH1;
%bicubic interpolation(Here alpha = 2;Hence alpha/2 = 1)
%// Change - commented out
%// Also, used ORIGINAL downsampled image, not the difference image
% img31 = imresize(img,1,'bicubic');
% LH131 = imresize(LH13,1,'bicubic');
% HL131 = imresize(HL13,1,'bicubic');
% HH131 = imresize(HH13,1,'bicubic');
%// Change - used original downsampled image
img4 = idwt2(img,LH13,HL13,HH13,'haar'); %IDWT
t = im2uint8(img4); %// Change - Convert back to uint8 when finished
imshow(t,[]);
[peaksnr, snr] = psnr(img4, img)
댓글 수: 0
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!