skimage - TypeError: peak_local_max() got an unexpected keyword argument 'num_peaks_per_label'

2.6k Views Asked by At

The following code gives me the error present in the title :

from skimage.feature import peak_local_max
local_maxi = peak_local_max(imd,labels=iml, 
                            indices=False,num_peaks_per_label=2)

Where imd is a "distance transformed image" which was obtained with :

from scipy import ndimage
imd = ndimage.distance_transform_edt(im) 

im is the input binary image that I would like to later on segment with the watershed function of scikit-image. But to use this function properly, I first need to find the markers which will serve as the starting flooding points : that's what I'm trying to do with the 'peak_local_max' function.

Also, iml is the labeled version of im, that I got with :

from skimage.measure import label
iml = label(im)

I don't know what I've been doing wrong. Also, I've noticed that, the function seems to totally ignore its num_peaks argument. For instance, when I do :

local_maxi = peak_local_max(imd,labels=iml,
                            indices=True,num_peaks=1)

I always get the same number of peaks detected as when I set num_peaks=500 or num_peaks=np.inf. What am I missing here please ?

1

There are 1 best solutions below

1
On BEST ANSWER

As @a_guest pointed out, my version of skimage wasn't matching with the version of the documentation I was referring to. The num_peaks_per_label argument is currently only available in the v0.13dev version. Updating my version to the dev version also fixed my problem with the num_peaks argument.