Subversion Repositories seema-scanner

Rev

Rev 210 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 210 Rev 211
Line 47... Line 47...
47
% - random subsampling inspired by "Randomized Hough Transform for Ellipse Detection with Result Clustering"
47
% - random subsampling inspired by "Randomized Hough Transform for Ellipse Detection with Result Clustering"
48
%   (CA Basca, M Talos, R Brad / 2005)
48
%   (CA Basca, M Talos, R Brad / 2005)
49
%
49
%
50
% Update log:
50
% Update log:
51
% --------
51
% --------
-
 
52
% 1.2: Added more efficient distance calculation, less memory-usage, non-maximum suppression.
52
% 1.1: More memory efficient code, better documentation, more parameters, more solutions possible, example code.
53
% 1.1: More memory efficient code, better documentation, more parameters, more solutions possible, example code.
53
% 1.0: Initial version
54
% 1.0: Initial version
54
%
55
%
55
%
56
%
56
% Author: Martin Simonovsky
57
% Author: Martin Simonovsky
Line 172... Line 173...
172
            weights = img(sub2ind(size(img),Y(K),X(K)));
173
            weights = img(sub2ind(size(img),Y(K),X(K)));
173
        end
174
        end
174
        accumulator = accumarray(idxs, weights, [params.maxMajorAxis 1]);
175
        accumulator = accumarray(idxs, weights, [params.maxMajorAxis 1]);
175
 
176
 
176
        %a bit of smoothing and finding the most busy bin
177
        %a bit of smoothing and finding the most busy bin
177
        %accumulator = conv(accumulator,H,'same');
178
        accumulator = conv(accumulator,H,'same');
178
        accumulator(1:ceil(sqrt(aSq)*params.minAspectRatio)) = 0;
179
        accumulator(1:ceil(sqrt(aSq)*params.minAspectRatio)) = 0;
179
        [score, idx] = max(accumulator);
180
        [score, idx] = max(accumulator);
180
 
181
 
181
        %keeping only the params.numBest best hypothesis (no non-maxima suppresion)
182
        %keeping only the params.numBest best hypothesis
182
        if (bestFits(end,end) < score)
183
        if (bestFits(end,end) < score)
-
 
184
            %non-maximum suppression (based on center distance for now)
-
 
185
            squaredDists = (bestFits(:,1)-x0).^2 + (bestFits(:,2)-y0).^2;
-
 
186
            [minSqDist, minSqDistIdx] = min(squaredDists);
-
 
187
            if(minSqDist < 20^2 && score > bestFits(minSqDistIdx, 6))
-
 
188
                bestFits(minSqDistIdx,:) = [x0 y0 sqrt(aSq) (idx-1) atand((y1-y2)/(x1-x2)) score];
-
 
189
            elseif(minSqDist >= 10^2)
183
            bestFits(end,:) = [x0 y0 sqrt(aSq) (idx-1) atand((y1-y2)/(x1-x2)) score];
190
                bestFits(end,:) = [x0 y0 sqrt(aSq) (idx-1) atand((y1-y2)/(x1-x2)) score];
-
 
191
            end
184
            if params.numBest>1
192
            if params.numBest>1
185
                [~,si]=sort(bestFits(:,end),'descend');
193
                [~,si]=sort(bestFits(:,end),'descend');
186
                bestFits = bestFits(si,:);
194
                bestFits = bestFits(si,:);
187
            end
195
            end
188
        end
196
        end