0001
0002
0003
0004
0005 clear
0006 close all
0007 addpath('common');
0008
0009 category = 'neg';
0010
0011
0012 load template_params
0013 load result/transformedS2Template.mat
0014 load result/egret/shapescript.mat
0015
0016
0017
0018 This can also be the comment
0019
0020
0021 Iname = {'neg04.jpg','neg05.jpg','neg06.jpg','neg07.jpg','neg08.jpg',...
0022 'neg21.jpg','neg22.jpg','neg23.jpg','neg24.jpg','neg25.jpg'};
0023 imScale = [.5 .5 .5 .5 .5,...
0024 0.3 .5 .5 .5 .5];
0025 binCenterS3 = [-100:20:400];
0026
0027 subsampleM1 = 1;
0028 S3Hist = zeros(1,length(binCenterS3));
0029 for iImage = 1:length(Iname)
0030 im = imread( sprintf('image/%s/%s',category,Iname{iImage}) );
0031 im = imresize( im,imScale(iImage),'nearest' );
0032
0033 if size(im,3) == 3
0034 im = rgb2gray(im);
0035 end
0036
0037 im = single(im);
0038 S1Map = applyfilterMultiScale({im},GaborFilter, nGaborOri);
0039
0040
0041 nImage = 1;
0042 heightS1Map = zeros(length(S1Map),1,'single');
0043 widthS1Map = zeros(length(S1Map),1,'single');
0044 for i = 1:length(S1Map)
0045 heightS1Map(i) = size(S1Map{i},1);
0046 widthS1Map(i) = size(S1Map{i},2);
0047 end
0048 tmpNGaborOri = 1;
0049 for i = 1:length(S1Map)
0050 Csigmoid(nImage, heightS1Map(i), widthS1Map(i), tmpNGaborOri, GaborSaturation, S1Map(i));
0051 end
0052
0053
0054 sizeGaborPerScale = zeros(nGaborScale,1,'single');
0055 for iS = 1:nGaborScale
0056 sizeGaborPerScale(iS) = size( GaborFilter{(iS-1)*nGaborOri+1}, 1 );
0057 end
0058 locationShift = .2;
0059 oriShift = 1;
0060 [M1Map M1Trace M1RowShift M1ColShift M1OriShift] = ...
0061 CcomputeMAX1( nGaborOri, S1Map, locationShift, oriShift, sizeGaborPerScale, subsampleM1 );
0062
0063
0064 S2Map = CcomputeSUM2( nGaborOri, M1Map, TransformedTemplate, subsampleS2 );
0065
0066
0067 locationPerturbationFraction = 0.2; subsampleM2 = 1;
0068 M2Map = cell(nTransform, nS2);
0069 M2LocationTrace = cell(nTransform, nS2);
0070 M2TransformTrace = cell(nTransform, nS2);
0071 for iS2 = 1:nS2
0072 sizeTemplate = zeros(nTransform,1);
0073 for iT = 1:nTransform
0074 sizeTemplate(iT) = sqrt( ...
0075 size(TransformedTemplate{iT,iS2}.sym,1)...
0076 * size(TransformedTemplate{iT,iS2}.sym,2) ) / subsampleS2;
0077 end
0078 [M2Map(:,iS2) M2LocationTrace(:,iS2) M2TransformTrace(:,iS2) storedM2LocationShift] = ...
0079 CcomputeMAX2( templateAffMat, S2Map((iS2-1)*nTransform + (1:nTransform)), locationPerturbationFraction, ...
0080 int32(sizeTemplate), subsampleM2 );
0081 storedSizeS2Template{iS2} = sizeTemplate;
0082 end
0083 disp('done with computing M2');
0084
0085
0086 subsampleS3 = 1;
0087
0088
0089
0090 S3Map = CcomputeSUM3_loglinear( M2Map, S3Template, subsampleS3, nTransform );
0091 for ii = 1:numel(S3Map)
0092 tmp = hist(S3Map{ii}(:),binCenterS3);
0093 S3Hist(:) = S3Hist(:) + tmp(:);
0094 end
0095 clear S2Map;
0096 clear M2Map;
0097 clear S3Map;
0098 clear M1Map;
0099 clear S1Map;
0100 end
0101
0102
0103
0104
0105
0106 count = 1;
0107
0108 Iname = {'pelican 2_big.jpg','pelican3.jpg',...
0109 'pelican4.jpg','pelican5.jpg','pelican6.jpg',...
0110 'pelican7.jpg','pelican8.jpg','pelican9.jpg',...
0111 'pelican10.jpg'};
0112 Iname_pelican = Iname;
0113
0114 category = 'pelican';
0115 for i = 1:length(Iname)
0116 load(sprintf('result/%s/detectionResult%d_%s.mat',category,1,Iname{i}),...
0117 'im','mask','S3Map','M2Map');
0118 tmp = -1e10;
0119 for j = 1:numel(S3Map)
0120 tmp = max(tmp, max(S3Map{j}(:)));
0121 end
0122 S3Pos(count) = tmp;
0123 count = count + 1;
0124 end
0125
0126 Iname = {'l1.jpg','l2.jpg','l3.jpg','l4.jpg','l5.jpg',...
0127 'l8.jpg','l10.jpg',...
0128 'l13.jpg','l14.jpg','l15.jpg',...
0129 'l17.jpg','l18.jpg','l19.jpg','l20.jpg',...
0130 'l21.jpg', 'l22.jpg',...
0131 'l26.jpg','l30.jpg',...
0132 'l4_dup.jpg'};
0133 Iname_egret = Iname;
0134 category = 'egret';
0135 for i = 1:length(Iname)
0136 load(sprintf('result/%s/detectionResult%d_%s.mat',category,1,Iname{i}),...
0137 'im','mask','S3Map','M2Map');
0138 tmp = -1e10;
0139 for j = 1:numel(S3Map)
0140 tmp = max(tmp, max(S3Map{j}(:)));
0141 end
0142 S3Pos(count) = tmp;
0143 count = count + 1;
0144 end
0145
0146 S3PosHist = hist(S3Pos,binCenterS3);
0147
0148
0149 figure; plot(binCenterS3,S3Hist/sum(S3Hist(:)),'b--','LineWidth',3);
0150 hold on;
0151 plot(binCenterS3,S3PosHist/sum(S3PosHist(:)),'r-','LineWidth',3);
0152
0153 set(gca,'FontSize',12);
0154 set(get(gca,'XLabel'),'String','S3 score','FontSize',18);
0155 set(get(gca,'YLabel'),'String','Frequency','FontSize',18);
0156 legend( {'natural','positive'},'FontSize',16,0);
0157
0158 saveas(gcf,'S3histogram.eps','epsc')
0159 saveas(gcf,'S3histogram.png')