pythonmatlabimage-processingcomputer-visionimage-segmentation

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 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.


Solution

  • 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. Then do

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

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