Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
why am I getting this error
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
function [Results]=ComputeFMeasureMultiSeg(DBpath,SegResultsSubPath,SysType)
%Compute the F-score for multi segments
%Syntax:
% [Results]=ComputeFMeasure(DBpath,SegResultsSubPath,SysType)
%Input:
% DBpath - The directory of the entire evaluation Database
% SegResultsSubPath - The name of the sub-directory in which the results of
% the algorithm to be evaluated are placed.
% SysType - The type of system in use, this determines the path
% separation char. There are two optional values 'win' or 'unix'
% if no value is specified the default is set to 'win'.
%
%Output:
% Results - An 100X4 matrix where Results(i,1) holds the best f-score for a single segment.
% Results(i,2) and Results(i,3) holds the corresponding Recall and Precision scores.
% Results(i,4) holds the amount of fragmentation.
%
%The evaluation function is given as is without any warranty. The Weizmann
%institute of science is not liable for any damage, lawsuits,
%or other loss resulting from the use of the evaluation functions.
%Written by Sharon Alpert Department of Computer Science and Applied Mathematics
%The Weizmann Institute of Science 2007
Lpath={'_5161812'... %the entire DB paths
'_mg_5707'...
'000_4009'...
'2_horses_cropped'...
'100_1219'...
'00000155'...
'77200701'...
'11257554021'...
'109300481333'...
'110932821430'...
'111876273311'...
'112224059330'...
'alanmort_p1010058'...
'atlasredstone'...
'b7nature_animals_sea000'...
'b8vehicles_water015'...
'b9vehicles_air015'...
'b9vehicles_air016'...
'b9vehicles_air018_cropped'...
'b10mechanics037'...
'b10nature_trees000'...
'b13vehicles_land000'...
'b17leon000'...
'b17maartent719'...
'b17maartent850'...
'b17paul1444'...
'b19nature_trees071'...
'b20vehicles_water065'...
'babyandmom'...
'bi_planes'...
'birdhouse_003'...
'black_an_white'...
'black_and_white'...
'boatscn2174'...
'by_the_north_sea15'...
'c'...
'chaom69'...
'cocotort'...
'crw_5052'...
'decorwall'...
'dsc_7742'...
'dsc_18501299'...
'dsc00103_h'...
'dscf1479_c'...
'dscf3208a'...
'dscn0969'...
'dscn1205_cropped'...
'dscn5449'...
'dualwindows'...
'eagle052607__20_'...
'elke_p9270005'...
'fair_gforce_003'...
'fishing_on_water'...
'footprints10morguejpg'...
'frankfurt_img_2243'...
'frosty_thyme'...
'hotblack_20070901_cows'...
'hpim0242_cropped'...
'hpim1928'...
'img_0121'...
'img_1159_i'...
'img_3733_modif'...
'img_7103r'...
'img_7121sepiar'...
'imgp1883'...
'istambulminaret'...
'jarndt_100_0021'...
'kata_beach_phuket'...
'kumarnm_100_1263'...
'ireland_62_bg_061502'... %70
'mf_3379'...
'mont_st_michel'...
'moon_and_a_tree'...
'ninetyeight'...
'nopeeking'...
'p5014757_cropped'...
'p5067537'...
'pb134930'...
'pc250176'...
'pc302982'... %80
'per__02_cropped'...
'photo_sanary_19-03-05_083'...
'photo-026'...
'pic1077114394'...
'pic108459418417'...
'pic108891392790'...
'pic1091719254143'...
'reverendb_563667_59178524'...
'rollingroscoe__9231871'...
'roman-pot-31-01-07-02842'... %90
'sakurag060521_dysn34'...
'sh-med-bandages-082404-01'...
'sunday_6-24_003'...
'swan_and_friend'...
'thailand-bangkok-building_02'...
'toplessmonument'...
'whitby-pier'...
'yack1'...
'yokohm060409_dyjsn266'...
};
l=dir(DBpath); %#ok<NASGU>
C=1; %#ok<NASGU>
Results=zeros(length(Lpath),3);
switch lower(SysType)
case 'win'
Sep='\';
case 'unix'
Sep='/';
otherwise
Sep='\';
end;
for i=1:length(Lpath)
Hmask=GetHSeg(strcat(DBpath,Sep,Lpath(i),Sep,'human_seg',Sep));
fprintf('Working on image:%s\n',cell2mat(Lpath(i)));
[Pmax Rmax Fmax Frag]=CalcCandScore(cell2mat(strcat(DBpath,Sep,Lpath(i),Sep,SegResultsSubPath,Sep)),Hmask);
Results(i,1)=Fmax;
Results(i,2)=Rmax;
Results(i,3)=Pmax;
Results(i,4)=Frag;
end;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Get the Human binary segmentation %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [mask]=GetHSeg(Hpath)
% Get the human segmentation by considering the votes from each human
% subject
l=dir(cell2mat(Hpath));
for k=1:length(l)
if (l(k).isdir)
continue;
end;
im=im2double(imread(cell2mat(strcat(Hpath,l(k).name))));
if (exist('mask','var'))
mask=mask+double((im(:,:,1)==1)&(im(:,:,2)==0));
else
mask=double((im(:,:,1)==1)&(im(:,:,2)==0));
end;
end;
if (~exist('mask') || max(mask(:))<2)
error('Error reading human segmentations please check path.');
end;
mask=mask>=2;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calcuate the F-score %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [p r f]=CalcPRPixel(GT,mask)
if (sum(GT(:)&mask(:))==0)
p=0;r=0;f=0;
return;
end;
r=sum(GT(:)&mask(:))./sum(GT(:));
c=sum(mask(:))-sum(GT(:)&mask(:));
p=sum(GT(:)&mask(:))./(sum(GT(:)&mask(:))+c);
f=(r*p)/(0.5*(r+p));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calcuate the F-score of the evaluated method %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Pmax Rmax Fmax Frag]=CalcCandScore(SegPath,human_seg)
Fmax=0;
Pmax=0;
Rmax=0;
Frag=0;
k=dir(SegPath);
cd(SegPath);
for i=1:length(k);
if (k(i).isdir)
continue;
end;
Segmap=imread(k(i).name);
NumOfSegs=unique(Segmap(:)); %find out how many segments
FragCounter=0;
FragMap= false(size(Segmap));
for j=1:length(NumOfSegs)
t=(Segmap==NumOfSegs(j));
if (sum(t(:)&human_seg(:))/sum(t(:))>0.5)%if a more then 50% of the pixels are in the foreground then
%it is considered as part of the total foreground.
FragCounter=FragCounter+1; %fragmentation counter
FragMap=FragMap|t;
end;
end;%Go over all segments in the image
[p r f]=CalcPRPixel(FragMap,human_seg);%Calculate the F-score
if (f>Fmax)
Fmax=f;
Pmax=p;
Rmax=r;
Frag=FragCounter;
end;
Matrix dimensions must agree.
??? Error using ==> and
Error in ==> ComputeFMeasureMultiSeg>CalcCandScore at 202
if (sum(t(:)&human_seg(:))/sum(t(:))>0.5)%if a more then 50% of the pixels are in the
foreground then
Error in ==> ComputeFMeasureMultiSeg at 138 [Pmax Rmax Fmax Frag]=CalcCandScore(cell2mat(strcat(DBpath,Sep,Lpath(i),Sep,SegResultsSubPath,Sep)),Hmask);
1 comentario
Respuestas (1)
Jan
el 9 de Mzo. de 2015
Editada: Jan
el 9 de Mzo. de 2015
The error message tells you, that in t(:)&human_seg(:) the number of elements of t and human_seg are different.
Set a break point in this line, or let Matlab stop automatically, when an error occurs:
dbstop if error
Then run the code again and check the sizes of the variables.
1 comentario
La pregunta está cerrada.
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!