I have a grayscale image that has a lot of gradients. I'm only interested in the local "high spots" and want to get rid of everything that isn't the brightest nearby pixel. Specifically what I'm trying to do is erase (set to 0) any pixel where any of it's neighbors (preferably within a specified distance) have a higher value. It's okay if the check area is some sort of kernel (e.g. a 5x5 square) and not a circular area.
Is there some built-in way of doing this in OpenCV short of just looping over every pixel and doing the check myself?
Also if there's an existing term for what I'm asking for I would love to know what it is. I've been searching for answers to this but keep running into stuff about background removal because my search terms don't seem to be right.