# How to find whether the position is a Peak position in a kernel window?

I am searching for an OpenCV function that replicates the function of peak_local_max in scikit-image. What this function does is, It compares the values over a window of mentioned size whether the anchor point value is greater than or equal to the maximum of other positions or not. If the case satisfies, it considers it as a local peak.

Example of what I want,

Consider my image is 5x5 and I want to find the local peaks in the window size of 3x3. If you could apply the criteria I explained in the question(It compares the values over a window of mentioned size whether the anchor point value is greater than or equal to the maximum of other positions or not), only one value satisfies 10.79. But in the case of minmaxloc it will find first 10.79 later after the mask is updated it will give 10.6 but 10.6 is definitely not the local peak and we wont know when to stop.

Is there a OpenCV function that could do this job? I know about minmaxLoc and minmaxIdx but it calculates for global frame which I am not interested. I am thinking of taking the filter2D function as reference and create my own functionality to do this. On the parallel side I want your suggestions to go about this problem?

Any help could be really appreciated. Thanks in advance!

may this post will help you

I mentioned in the question itself, I know about the minMaxLoc but that is not what I expected. Thanks for your help

" but it calculates for global frame" no there is a mask. You have to adjust mask relative to the window size you need

Got your point! Firstly I don't wan to find the maximum in the window. I want to find the peak whether the anchor point contains the maximum value or not. Secondly My window size is 5x5. For the image of 1280x720 how efficient is this thing?

anchor ? filter2D is convolution so anchor is everywhere. I don't understand. A small example is welcome

@LBerger: updated my question and I got my answer as well thanks for your help