6

I need to find the regional maxima of an image to obtain foreground markers for watershed segmentation. I see in matlab use the function imregionalmax(). 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.

Shai
  • 111,146
  • 38
  • 238
  • 371
user30985
  • 573
  • 1
  • 6
  • 19

2 Answers2

9

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.

Shai
  • 111,146
  • 38
  • 238
  • 371
4

I am new to Python but I spent a lot of time to find the 100% equivalent of Matlab's imregionalmax(). For me, the above, msk = (img == lm) did NOT work because of my huge 3D arrays. I instead used scikit-images.peak_local_max as follows:

1) define conn_26 to be 3x3x3 array of one's.

2) coordinates = peak_local_max(3D_img, footprint=conn_26,indices=False,exclude_border=0)

is similar to coordinates = imregionalmax(3D_img,26)

Hope this helps :)

Claudia
  • 41
  • 1