MATLAB code for non-maximum suppression

44 visualizzazioni (ultimi 30 giorni)
FARHAD
FARHAD il 10 Giu 2014
Risposto: Manuel Dominguez il 27 Nov 2019
Hi, I have a set of bounding boxes with score. Now I want to apply non-maximum suppression on that set for my detection task. Could you kindly give me matlab code for non-maximum suppression? Thanks in advances.
Reserveboxes=[score box] % Reserveboxes is a 5920x5 array

Risposte (1)

Manuel Dominguez
Manuel Dominguez il 27 Nov 2019
%% Nonmaxmimum Suppression
function imgResult = nonmaxsup2d(imgHough)
imgResult = zeros(size(imgHough));
for y = 2:size(imgHough, 1)-1
for x = 2:size(imgHough, 2)-1
offx = [1 1 0 -1 -1 -1 0 1];
offy = [0 1 1 1 0 -1 -1 -1];
val = imgHough(y, x);
is_max = true;
for i=1:8
if y == 2 && offy(i) == -1
continue
end
if y ==size(imgHough,1)-1 && offy(i) == 1
continue
end
if x ==2 && offx(i) == -1
continue
end
if x ==size(imgHough,2)-1 && offx(i) == 1
continue
end
if val < imgHough(y+offy(i), x+offx(i))
is_max = false;
break;
end
end
if is_max
imgResult(y, x) = val;
end
end
end
end

Categorie

Scopri di più su Computer Vision Toolbox in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by