% function [out] = bayerInterp(in)
% returns simplest bayer interpolation of image in
% Just copy values.

function [out] = bayerInterp(in)
rows=size(in,1);
cols=size(in,2);
out = zeros(size(in,1),size(in,2),3);

% Pattern looks like this:
% From trial and error.
% GB
% RG

g1 = in(1:2:rows,1:2:cols);
g2 = in(2:2:rows,2:2:cols);
b  = in(1:2:rows,2:2:cols);
r  = in(2:2:rows,1:2:cols);

% Now copy into color planes

out(1:2:rows,1:2:cols,1)=r;
out(1:2:rows,2:2:cols,1)=r;
out(2:2:rows,1:2:cols,1)=r;
out(2:2:rows,2:2:cols,1)=r;
out(1:2:rows,1:2:cols,2)=g1;
out(1:2:rows,2:2:cols,2)=g1;
out(2:2:rows,1:2:cols,2)=g2;
out(2:2:rows,2:2:cols,2)=g2;
out(1:2:rows,1:2:cols,3)=b;
out(1:2:rows,2:2:cols,3)=b;
out(2:2:rows,1:2:cols,3)=b;
out(2:2:rows,2:2:cols,3)=b;

