% Plot the results of routine FD_EIT_2D_demoE_recon9x9smallcontrast_comp.m
%
% Samuli Siltanen August 2026

% Load results from file
load data/FD_EIT_2D_demoE_recon9x9smallcontrast

% Record minimum and maximum conductances
scaleMIN = min([min(condmatH(:)),min(condmatV(:)),min(condmatH_recon(:)),min(condmatV_recon(:))]);
scaleMAX = max([max(condmatH(:)),max(condmatV(:)),max(condmatH_recon(:)),max(condmatV_recon(:))]);

% Show original conductivity in colors
EIT_FD_demo2D_recon_colors_plot(n,condmatH,condmatV,1,scaleMIN,scaleMAX)
% Initial image
im1 = print('-r500','-RGBImage');
[row1,col1] = size(im1(:,:,1));
% Crop
imN = 1500;
im2 = im1(640+[1:imN],1250+[1:imN],:);
% Save
imwrite(im2,'images/FD_EIT_2D_demoE_cond9x9smallcontrast_orig.png')

% Show reconstructed conductivity in colors
EIT_FD_demo2D_recon_colors_plot(n,condmatH_recon,condmatV_recon,2,scaleMIN,scaleMAX)
% Initial image
im1 = print('-r500','-RGBImage');
[row1,col1] = size(im1(:,:,1));
% Crop
imN = 1500;
im2 = im1(640+[1:imN],1250+[1:imN],:);
% Save
imwrite(im2,'images/FD_EIT_2D_demoE_cond9x9smallcontrast_recon.png')


% Show reconstructed conductivity in colors
EIT_FD_demo2D_recon_colors_plot(n,condmatH_recon2,condmatV_recon2,3,scaleMIN,scaleMAX)
% Initial image
im1 = print('-r500','-RGBImage');
[row1,col1] = size(im1(:,:,1));
% Crop
imN = 1500;
im2 = im1(640+[1:imN],1250+[1:imN],:);
% Save
imwrite(im2,'images/FD_EIT_2D_demoE_cond9x9smallcontrast_recon2.png')


% Show reconstruction as a graph
figure(2641)
clf
% Plot true conductivities in black
plot([condmatH(:);condmatV(:)],'k')
hold on
plot([condmatH_recon2(:);condmatV_recon2(:)],'r')
title('True conductances (black) and reconstruction (red)')
