Questo dovrebbe essere un esempio, nel Bayer Pattern:
%Bayer Pattern
%V R
%B V
clear all;
close all;
A=double(imread('lena.jpg'));
[m,n,t]=size(A);
B=A;
for i=1:m
for j=1:n
if mod(i,2)==0 & mod(j,2)==0 || mod(i,2)~=0 & mod(j,2)~=0
B(i,j,1)=0;
B(i,j,3)=0;
else if mod(i,2)==0 & mod(j,2)~=0
B(i,j,2)=0;
B(i,j,3)=0;
else
B(i,j,1)=0;
B(i,j,2)=0;
end
end
end
end
BP=B(:,:,1)+B(:,:,2)+B(:,:,3);
figure,
subplot(1,3,1), imshow(uint8(A),[]),title('Originale');
subplot(1,3,2), imshow(uint8(B),[]),title('Bayer Pattern falsi colori');
subplot(1,3,3), imshow(uint8(BP),[]),title('Bayer Pattern reale');