# GenerateEgretFigure

## PURPOSE

GenerateEgretFigure - Generate the egret-pelican figure: a single figure with all detection results for egrets and pelicans.

## SYNOPSIS

This is a script file.

## DESCRIPTION

     GenerateEgretFigure - Generate the egret-pelican figure: a single figure with all detection results for egrets and pelicans.
       The figure is located at "./pelican_egret_matching.eps".
       The shape script is found at "result/egret/egret_template.eps" or "result/egret/template.png".

## CROSS-REFERENCE INFORMATION

This function calls:

- displayImages displayImage - display a set of images of the same size (bx, by) on

This function is called by:

## SOURCE CODE

    0001 % GenerateEgretFigure - Generate the egret-pelican figure: a single figure with all detection results for egrets and pelicans.
    0002 %   The figure is located at "./pelican_egret_matching.eps".
    0003 %   The shape script is found at "result/egret/egret_template.eps" or "result/egret/template.png".
    0004
    0005 Iname = {'pelican 2_big.jpg','pelican3.jpg',...
    0006     'pelican4.jpg','pelican5.jpg','pelican6.jpg',...
    0007     'pelican7.jpg','pelican8.jpg','pelican9.jpg',...
    0008     'pelican10.jpg'};
    0009 Iname_pelican = Iname;
    0010 imScale = [0.25 0.4 0.4 0.4 ...
    0011     0.22 0.36 0.5 0.4 0.3];
    0012
    0013 category = 'pelican';
    0014 overlay_pelican = cell(length(imScale),1);
    0015 j_detection = 1;
    0016 for i = 1:length(imScale)
    0017     load(sprintf('result/%s/detectionResult%d_%s.mat',category,j_detection,Iname{i}),...
    0018                 'im','mask','S3Map','M2Map');
    0019     overlay_pelican{i} = im + 400 * mask;
    0020 end
    0021
    0022 Iname = {'l1.jpg','l2.jpg','l3.jpg','l4.jpg','l5.jpg',...
    0023     'l6.jpg','l7.jpg','l8.jpg','l9.jpg','l10.jpg',...
    0024     'l11.jpg','l12.jpg','l13.jpg','l14.jpg','l15.jpg',...
    0025     'l16.jpg','l17.jpg','l18.jpg','l19.jpg','l20.jpg',...
    0026     'l21.jpg', 'l22.jpg','l23.jpg','l24.jpg','l25.jpg',...
    0027     'l26.jpg','l27.jpg','l28.jpg','l29.jpg','l30.jpg',...
    0028     'l4_dup.jpg', 'l12_dup.jpg', 'l12_dup2.jpg'};
    0029 Iname_egret = Iname;
    0030 imScale = [1.2 1.2 1 2 1,...
    0031     1 1.2 0.9 0.9 1,...
    0032     0.95 1 1.1 1 1,...
    0033     1.1 0.8 1.2 1.2 0.9,...
    0034     .55 .3,.3 .25 .3 ...
    0035     .3 .4,.3 .35 .3,...
    0036     1.15 1.1 1.2];
    0037 category = 'egret';
    0038 overlay_egret = cell(length(imScale),1);
    0039 j_detection = 1;
    0040 for i = 1:length(imScale)
    0041     load(sprintf('result/%s/detectionResult%d_%s.mat',category,j_detection,Iname{i}),...
    0042                 'im','mask','S3Map','M2Map');
    0043     overlay_egret{i} = im + 400 * mask;
    0044 end
    0045
    0046 %%
    0047 % selected_egret = setdiff(1:33,[6 7 9 11 13 16 19 20 21 23 24 25 27 28 29 30]);
    0048 selected_egret = 1:33; % select all of them
    0049 % selected_pelican = [7:9];
    0050 selected_pelican = 1:9; % select all of them
    0051
    0052 overlay = [overlay_egret(selected_egret);overlay_pelican(selected_pelican)];
    0053 Iname = [Iname_egret(selected_egret) Iname_pelican(selected_pelican)];
    0054
    0055 frames = cell(2*length(overlay),3);
    0056 % now interleve original image with overlay
    0057 for k = 1:length(overlay)
    0058     if k <= length(selected_egret)
    0059         im = imread(sprintf('image/egret/%s',Iname{k}));
    0060     else
    0061         im = imread(sprintf('image/pelican/%s',Iname{k}));
    0062     end
    0063
    0064     for c = 1:3
    0065         frames{2*(k-1)+1,c} = im(:,:,c); % source image
    0066         frames{2*(k-1)+2,c} = overlay{k}; % overlay
    0067     end
    0068 end
    0069
    0070 addpath common
    0071 for c = 1:3
    0072     channel{c} = displayImages(frames(:,c),10,200,200);
    0073 end
    0074 towrite = zeros(size(channel{1}),'uint8');
    0075 for c = 1:3
    0076     towrite(:,:,c) = channel{c};
    0077 end
    0078 figure; imshow(towrite);
    0079 saveas(gcf,'pelican_egret_matching.eps','epsc');
    0080