function [ handles ] = genCFAPlot( handles )
% Makes a color filter array unit cell for RBG filter arrays and outputs an
% associated .tikz file.

totFilt = zeros(handles.ySizeD,handles.xSizeD,3);

for k = 1:handles.numFiltersD
    C = handles.filtColor{k};
    totFilt(:,:,1) = totFilt(:,:,1) + flipud(handles.filtVal{k}).*C(1);
    totFilt(:,:,2) = totFilt(:,:,2) + flipud(handles.filtVal{k}).*C(2);
    totFilt(:,:,3) = totFilt(:,:,3) + flipud(handles.filtVal{k}).*C(3);
end

maxVal = max(max(max(totFilt)));
totFilt = totFilt./maxVal;

figure(handles.colorArrayPlot);
set(handles.colorArrayPlot,'Name','CFA Unit Cell','NumberTitle','off');
image(totFilt);

axis square;
ax = gca;
% ax.YDir = 'normal';   
ax.XTick = [];
ax.YTick = [];
ax.YDir = 'normal';
assignin('base', 'CFA_RGB', totFilt);
genCFATikzUC('CFA.tikz', round(totFilt.*255) );
end

