I have a set of greyscale images where I need to locate the local minima. I'm writing my code in Matlab and I'm looking for suggestions on how to structure the algorithm: do I need to calculate the gradient or can I just use the watershed
function?
This is the code I used to do a first analysis (images below):
IM_c = imcomplement(IM);
L = watershed(IM_c);
Lrgb = label2rgb(L);
figure; hold on;
subplot(3,1,1); imshow(IM_c); hold on;
subplot(3,1,2); imshow(Lrgb);hold on;
subplot(3,1,3); imshow(imfuse(IM_c,Lrgb));
Intuitively, I expect to find regional minima in the pixels pointed by arrows:
I guess the solution would be to use a gradient image, following the algorithm described in this paper. The procedure is quite complicated, so instead I
imerode
and imdilate
;IM_bin
) of the image and used it as a filter, so that
if IM_bin(x,y) > 0imerode
again;imregionalmax
.