I need to find local peaks on the depth image to generate the markers for a watershed algorithm in C++.
My Python implementation uses skimage.feature.peak_local_max to generate the markers for a watershed algorithm.
Can't find a C++ implementation or C++ analogue of the skimage.feature.peak_local_max function.
Some algorithm to find a local maximum for a matrix also could be helpful.
distance = scipy.ndimage.distance_transform_edt(image)
local_maxi = skimage.feature.peak_local_max(distance, indices=False, footprint=np.ones((3, 3)), labels=image)
markers = scipy.ndimage.label(local_maxi)[0]
labels = skimage.segmentation.watershed(-distance, markers, mask=image)
Any ideas on C++ implementation of the local peak finder, please? Thank you!
If you want a pure C++ implementation, I would suggest taking a look at ITK. The RegionalMaximalImageFilter
class from ITK will produce a binary image with the foreground representing local maxima. It even works for "flat" regions where the local maximum is constant. This link shows an example: RegionalMaximal
Original Image:
Local Maxima Image: