MATLAB code for non-maximum suppression

46 次查看(过去 30 天)
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

回答(1 个)

Manuel Dominguez
Manuel Dominguez 2019-11-27
%% 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

类别

Help CenterFile Exchange 中查找有关 Computer Vision Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by