You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.4 KiB
Matlab
62 lines
1.4 KiB
Matlab
function test_ism_norb(imageNum,threshold)
|
|
if nargin<1 || isempty(imageNum) || imageNum<0
|
|
imageNum=1;
|
|
end
|
|
if nargin<2 || isempty(threshold) || threshold<0
|
|
threshold=1
|
|
end
|
|
spread=2;
|
|
|
|
method{1}='Hough';method{2}='PC/BC-DIM';
|
|
|
|
%DEFINE CODEBOOK
|
|
load('ISM_codebook_NORB.mat');
|
|
Locations=postprocess_codebook(Locations,patchClassList,spread);
|
|
|
|
%DEFINE TEST IMAGE
|
|
[images,classes,numClasses]=load_data_norb(2);
|
|
I=reshape(images(imageNum,:),96,96)';
|
|
|
|
figured(2),clf, imagesc(I), hold on, axis('equal','tight'); title(' ');
|
|
set(gca,'FontSize',24);
|
|
set(gca,'XTick',[],'YTick',[]);
|
|
set(gcf,'PaperSize',[20 15],'PaperPosition',[0 0 20 15]);
|
|
colormap('gray');
|
|
drawnow;
|
|
|
|
%APPLY METHODS
|
|
[param{1},param{2}]=ism_compare_methods(I,patches,patchClassList,Locations,similarityThres);
|
|
|
|
class=classes(imageNum)
|
|
for m=1:length(method)
|
|
disp(method{m});
|
|
|
|
%analyse results as a detection tasks
|
|
for c=1:numClasses
|
|
index=find(param{m}{c}(3,:)>threshold);
|
|
coords{c}=param{m}{c}(1:2,index);
|
|
amplitude{c}=param{m}{c}(3,index);
|
|
end
|
|
num_per_class(coords)
|
|
|
|
%analyse results as a classification task
|
|
prob=zeros(1,numClasses);
|
|
for c=1:numClasses
|
|
maxAmplitude=max(param{m}{c}(3,:));
|
|
if ~isempty(maxAmplitude)
|
|
prob(c)=maxAmplitude;
|
|
end
|
|
end
|
|
prob
|
|
[~,predictedClass]=max(prob)
|
|
end
|
|
|
|
|
|
function num=num_per_class(param)
|
|
numClasses=length(param);
|
|
|
|
num=zeros(1,numClasses);
|
|
for c=1:numClasses
|
|
num(c)=size(param{c},2);
|
|
end
|