function LinearBayerPatch(filename)

I = im2double(imread(filename));

%%Linear Interpolation 
tic
Rmask = repmat([1,0;0,0],size(I,1)/2,size(I,2)/2);
Gmask = repmat([0,1;1,0],size(I,1)/2,size(I,2)/2);
Bmask = repmat([0,0;0,1],size(I,1)/2,size(I,2)/2);

Rchannel = double(Rmask) .* I;
Gchannel = double(Gmask) .* I;
Bchannel = double(Bmask) .* I;

Bmask = [0.25,0.5,0.25;0.5,1,0.5;0.25,0.5,0.25];
Gmask = [0,0.25,0;0.25,1,0.25;0,0.25,0];
Rmask = [0.25,0.5,0.25;0.5,1,0.5;0.25,0.5,0.25];

newR = imfilter(Rchannel,Rmask);
newG = imfilter(Gchannel,Gmask);
newB = imfilter(Bchannel,Bmask);

img = [];
img(:,:,1) = newR;img(:,:,2) = newG;img(:,:,3) = newB;
z = toc
imshow(img)
figure
newI = newR + newG + newB;
newI = newI ./ 3;
newI = (newI - I).^2;
max(max(newI))
median(median(newI))
imagesc(newI);

%average((newI))
%imshow(max(newI))
%%Cubic Interpolation