% File created by Yuandong Tian, Oct. 5, 2009
% Email: yuandong@andrew.cmu.edu

% generate Figure 10 in the paper

%% initial best result images
sampleImgs = {};
reconImg1s = {};
reconImg2s = {};
meanImgs = {};
medianImgs = {};

distortedComp1 = {};
distortedComp2 = {};

load warp.mat;
tsel = 1:61;

%% most distorted images
distortedIndices = [57, 28, 4, 43, 45, 4];

%% Large letters
i = 1;
load expdata_large.mat;
load exp_computed_large.mat;
putResults;

%% Middle letters
i = 2;
load expdata_middle.mat;
load exp_computed_middle.mat;
putResults;

%% Small letters
i = 3;
load expdata_small.mat;
load exp_computed_small.mat;
putResults;

%% Tiny letters
i = 4;
load expdata_tiny.mat;
load exp_computed_tiny.mat;
putResults;

%% Checkboard
i = 5;
load expdata_checkboard.mat;
load exp_computed_checkboard.mat;
putResults;

%% 100-200 brick
i = 6;
load expdata_brick.mat;
load exp_computed_brick.mat;
putResults;

%% then show these result in a matrix
nResult = length(sampleImgs);
count = 1;
for i = 1:nResult
    subplot(nResult, 5, count);
    imshow(sampleImgs{i});

    subplot(nResult, 5, count+1);
    imshow(meanImgs{i});

    subplot(nResult, 5, count+2);
    imshow(medianImgs{i});

    subplot(nResult, 5, count+3);
    imshow(reconImg1s{i});
    
    subplot(nResult, 5, count+4);
    imshow(reconImg2s{i});
    
    count = count + 5;
end;