MATLAB Answers


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

Asked by ARUN SAI on 15 Apr 2013

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




end end abc=a+b+c; figure,imshow(abc); m3=mean2(abc(mask)) SD3=std2(abc(mask)) 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




end end

abc1=a1+b1+c1; figure,imshow(abc1); m4=mean2(abc1(mask)) SD4=std2(abc1(mask)) var4=SD4^2 snrofbilinearinterpolatedimage=(m4/sqrt(var4))


Log in to comment.

0 Answers

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today