whether the code written is correct for interpolation,and the snr of interpolated image calculated is correct?.and the snr calculation should include mask.

3 vues (au cours des 30 derniers jours)
clc; clear all; close all; I = imread('mandi.tif'); imshow(I); %demosaic of image rgb = demosaic(I,'bggr'); figure,e=imshow(rgb); h = imrect(gca,[1 1 3039 2014]); f = makeConstrainToRectFcn('imrect',get(gca,'XLim'),get(gca,'YLim')); setPositionConstraintFcn(h,f); % masking mask = createMask(h,e); % SNR calculation of cfa bayer pattern image (I) m1=mean2(I(mask)) SD1=std2(I(mask)) var1=SD1^2 snrofbayerpatternimage=(m1/sqrt(var1)) % SNR calculation of true color image (J) m2=mean2(rgb(mask)) SD2=std2(rgb(mask)) var2=SD2^2 snroftruecolorimage=(m2/sqrt(var2)) [M N]=size(mask) % SNR calculation of nearest neighbor interpolated image a=rgb; b=rgb; c=rgb; a(:,:,2)=0; a(:,:,3)=0; b(:,:,1)=0; b(:,:,3)=0; c(:,:,1)=0; c(:,:,2)=0;
for i=2:1:M-1 for j=2:1:N-1
a(i,j)=a(i,j-1);
b(i,j)=b(i,j-1);
c(i,j)=c(i,j-1);
end end abc=a+b+c; figure,imshow(abc); m3=mean2(abc) SD3=std2(abc) var3=SD3^2 snrofnearestneighborinterpolation=(m3/sqrt(var3))
% SNR calculation of bilinear interpolated image a1=rgb; b1=rgb; c1=rgb; a1(:,:,2)=0; a1(:,:,3)=0; b1(:,:,1)=0; b1(:,:,3)=0; c1(:,:,1)=0; c1(:,:,2)=0; for i=2:1:M-1 for j=2:1:N-1
a1(i,j)=(a1(i-1,j)+a1(i,j-1)+a1(i,j+1)+a1(i+1,j))/4;
b1(i,j)=(b1(i-1,j)+b1(i,j-1)+b1(i,j+1)+b1(i+1,j))/4;
c1(i,j)=(c1(i-1,j)+c1(i,j-1)+c1(i,j+1)+c1(i+1,j))/4;
end end
abc1=a1+b1+c1; figure,imshow(abc1); m4=mean2(abc1) SD4=std2(abc1) var4=SD4^2 snrofbilinearinterpolatedimage=(m4/sqrt(var4))

Réponses (0)

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by