MATLAB: How to mark the pixel whose intensity is greater than at least one of its neighbors in a given image

Image Processing Toolboximregionalmaximregionalmin()

imregionalmax(grayImage, 8) gives the pixel which is greater than all the 8 surrounding neighbors but I need it to be greater than at least one neighbor. And I also want to mark them in the given image.

Best Answer

assuming monochrom image:
if any(I(x,y) - I(x-1:y-1,x+1:y+1) > 0)
I = insertMarker(I, [x,y]);
end
Related Question