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.

66 lines
1.7 KiB
Matlab

function stats=stats_hough_lines(imNoise)
thresholds=[1:2:24]; %defined in terms of number of pixels
method{1}='Hough';method{2}='PC/BC-DIM';
numTest=250;
rhoResolution=1;
thetaResolution=5;
imSize=150;
if nargin<1 || isempty(imNoise)
imNoise=0 %0.01
end
%FOR EACH TEST IMAGE PERFORM HOUGH TRANSFORM
disp(['Processing Images (',int2str(numTest),')'])
W=[];
for i=1:numTest
fprintf(1,'Image %i\n',i);
[I,theta_rho_true{i}]=image_dot_lines(imSize,imNoise);
[param{i}{1},param{i}{2},W]=hough_lines_compare_methods(I,rhoResolution,thetaResolution,W);
drawnow;
end
%FOR EACH METHOD AND THRESHOLD TEST ACCURACY WITH WHICH LINES ARE LOCATED
for m=1:length(method)
disp(' ');
disp(method{m});
disp('Testing Accuracy for threshold:')
t=0;
for thres=thresholds.*m
t=t+1;
fprintf(1,'.%i.',thres);
stats{m}(t,:)=[0,0,0];
for i=1:numTest
%find coordinates for which the votes exceed the threshold
index=find(param{i}{m}(3,:)>thres);
theta_rho_est=param{i}{m}(1:2,index);
stats{m}(t,:)=lines_detection_accuracy(stats{m}(t,:),theta_rho_est,theta_rho_true{i});
end
f1score{m}(t)=calc_f1score(stats{m}(t,:));
end
end
%PLOT THE RESULTS
disp(' ');
max_error=0;
for m=1:length(method)
max_error=max(max_error,max(sum(stats{m}(:,2:3),2)));
disp(['f1score ',method{m}]);
disp(f1score{m})
end
lineStyle{1}='b-s';lineStyle{2}='r-d';lineStyle{3}='g-o';lineStyle{4}='m-x';
figured(11),clf
for m=1:length(method)
subplot(1,length(method),m),plot_errors(thresholds.*m,stats{m},max_error);title(method{m})
end
figured(12),clf
for m=1:length(method)
plot_precision_recall(stats{m},lineStyle{m}), hold on
end
legend(method,'Location','southeast')