user30985 user30985 - 3 months ago 57
Python Question

What is the difference between imregionalmax() of matlab and scipy.ndimage.filters.maximum_filter

I need to find the regional maxima of an image to obtain foreground markers for watershed segmentation. I see in matlab use the function

. As I don't have the matlab software, I use the function
scipy.ndimage.filters.maximum_filter()
instead. However, the results from
imregionalmax()
and
scipy.ndimage.filters.maximum_filter()
are different.

Please help me how to find out the regional maxima of an image. Thanks very much for your help.

Answer

It appears as if scipy's maximum_filter returns the actual local max values, while Matlab's imregionalmax returns a mask with the locations of the local maxima.
I would expect

 lm = scipy.ndimage.filters.maximum_filter( img, ... )
 msk = (img == lm) #// convert local max values to binary mask

should give you similar results to Matlab's.