Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hey I found my answer. I used the logic behind dilate operation to find the peak local maximum. It would be very simple than minmaxloc.

Quick background of Dilate operation

As the kernel is scanned over the image, we compute the maximal pixel value overlapped by the kernel and replace the image pixel under the anchor point with that maximal value.

I used this to my advantage, so the maximum value around the window remains the same even when dilation operation is happening, which is our peak value. I did dilation followed by equality comparison to extract the peak positions alone.

//Threshold operation
threshold_frame(input_frame, threshold_frame, threshold_value, max_value, THRESH_BINARY)

//Finding the peak locals 
dilate(threshold_frame, dilate_frame, dilateKernel, Point(-1,-1), 1);
peak_local_frame = (dilate_frame == threshold_frame);