non-maximum suppression on detection windows

Jono Brogan picture Jono Brogan · Apr 3, 2013 · Viewed 8.5k times · Source

In object detection literature it is common to use a classifier and a sliding window approach to detect the presence of objects in an image, this method returns a set of detection windows and detection overlaps are resolved using non-maximum suppression.

Can someone explain the algorithm for performing non-maximum suppression on these detection windows.

Thanks

Answer

entropiece picture entropiece · Apr 3, 2013

Quoting from http://www.di.ens.fr/willow/events/cvml2012/materials/practical-detection/

Scanning-window style classification of image patches typically results in multiple responses around the target object. A standard practice to deal with this is to remove any detector responses in the neighborhood of detections with the locally maximal confidence score (non-maxima suppression or NMS). NMS is usually applied to all detections in the image with confidence above a certain threshold. Try NMS face detection for different threshold values and in different images:

Also here http://www.ens-lyon.fr/LIP/Arenaire/ERVision/detection_exercise_solution.m you can find a matlab program that does everything - detections and NMS on detection windows

The code that does the non-maximum suppression on detection windows is

%%%%%%%%%%%%%%% **************************************************************
%%%%%%%%%%%%%%% **************************************************************
%%%%%%%%%%%%%%% *                                                            *
%%%%%%%%%%%%%%% *                       EXERCISE 3:                          *
%%%%%%%%%%%%%%% *                                                            *
%%%%%%%%%%%%%%% *        Non-maxima suppression of multiple responses        *
%%%%%%%%%%%%%%% *                                                            *
%%%%%%%%%%%%%%% **************************************************************
%%%%%%%%%%%%%%% **************************************************************
%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%% Scanning-window style classification of image patches typically
%%%%%%%%%%%%%%% results in many multiple responses around the target object.
%%%%%%%%%%%%%%% A standard practice to deal with this is to remove any detector
%%%%%%%%%%%%%%% responses in the neighborhood of detections with locally maximal
%%%%%%%%%%%%%%% confidence scores (non-maxima suppression or NMS). NMS is
%%%%%%%%%%%%%%% usually applied to all detections in the image with confidence
%%%%%%%%%%%%%%% above certain threshold.
%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%% TODO:
%%%%%%%%%%%%%%% 3.1 Try out different threshold values to pre-selected windows
%%%%%%%%%%%%%%%     passed to the NMS stage, see parameter 'confthresh' below.
%%%%%%%%%%%%%%% 3.2 Try out different threshold values for NMS detections,
%%%%%%%%%%%%%%%     see parameter 'confthreshnms'
%%%%%%%%%%%%%%% 3.3 Try detection and with different thresholds for different
%%%%%%%%%%%%%%%     included images: 'img1.jpg', 'img2.jpg', 'img3.jpg', 'img4.jpg'
%%%%%%%%%%%%%%% 
confthresh=0;
indsel=find(conf>confthresh);
[nmsbbox,nmsconf]=prunebboxes(bbox(indsel,:),conf(indsel),0.2);


%%%%%%%%%%%%%%% display detections above threshold after non-max suppression
%%%%%%%%%%%%%%% 
confthreshnms=1;
clf, showimage(img)
indsel=find(nmsconf>confthreshnms);
showbbox(nmsbbox(indsel,:),[1 1 0],regexp(num2str(nmsconf(indsel)'),'\d+\.\d+','match'));
title(sprintf('%d NMS detections above threshold %1.3f',size(nmsbbox,1),confthreshnms),'FontSize',14)
fprintf('press a key...'), pause, fprintf('\n')

You can find all the related functions in the first link.