function [] = compareImages(X, y) % This function draws the input and output figures for comparison purposes. [n,m] = size(X); %Draw inputs: figure subplot(1,2,1); for i = 1:n for j = 1:m if X(i,j) == 0 %if pixel is white fill([j-1; j-1; j; j], [n-i; n+1-i; n+1-i; n-i], [1 1 1]); hold on; else %if pixel is gray fill([j-1; j-1; j; j], [n-i; n+1-i; n+1-i; n-i], [0.5 0.5 0.5]); hold on; end end end grid on; title('Input image'); xlim([0 5]); % Draw outputs: subplot(1,2,2); idx = find(y == max(y)); if idx == 1 fig_out = [0 1 1 0 0; 0 0 1 0 0; 0 0 1 0 0; 0 0 1 0 0; 0 1 1 1 0]; %1 elseif idx == 2 fig_out = [1 1 1 1 0; 0 0 0 0 1; 0 1 1 1 0; 1 0 0 0 0; 1 1 1 1 1]; %2 elseif idx == 3 fig_out = [1 1 1 1 0; 0 0 0 0 1; 0 1 1 1 0; 0 0 0 0 1; 1 1 1 1 0]; %3 elseif idx ==4 fig_out = [0 0 0 1 0; 0 0 1 1 0; 0 1 0 1 0; 1 1 1 1 1; 0 0 0 1 0]; %4 else fig_out = [1 1 1 1 1; 1 0 0 0 0; 1 1 1 1 0; 0 0 0 0 1; 1 1 1 1 0]; %5 end [n,m] = size(fig_out); for i = 1:n for j = 1:m if fig_out(i,j) == 0 %if pixel is white fill([j-1; j-1; j; j], [n-i; n+1-i; n+1-i; n-i], [1 1 1]); hold on; else %if pixel is gray fill([j-1; j-1; j; j], [n-i; n+1-i; n+1-i; n-i], [0.5 0.5 0.5]); hold on; end end end grid on; title('Network output'); xlim([0 5]); end