MATLAB Answers

0

Image Blob Detection Using Recursive Flood Fill

Asked by Brent Vaalburg on 8 Dec 2018 at 15:28
Latest activity Answered by Image Analyst
on 9 Dec 2018 at 0:38
I am trying to detect blobs in an image using recursive flood fill but it seems I am in an infinite loop but cannot figure out why. My input image is only 20x15 pixels but it has been siiting here for at least 10 minutes trying to finish. It seems as though it is stuck in the flood_fill function but I cant figure out why? Is there something wrong with my test?
blobs = im2bw(imread('Week6Image.jpg'),0.1);
[W, H] = size(blobs);
set(0,'RecursionLimit',100000)
out = region_labeling(blobs,W,H);
function I = region_labeling(I,W,H)
label = 2;
for u = 1 : W
%For loop vertical Axis
for v = 1 : H
if I(u,v) == 1
I = flood_fill(I,u,v,label,W,H);
label = label + 1;
end
end
end
end
function I = flood_fill(I,u,v,label,W,H)
if u >= 1 && u <= W && v >= 1 && v <= H && I(u,v) == 1
I(u,v) = label;
I = flood_fill(I,u+1,v,label,W,H);
I = flood_fill(I,u,v+1,label,W,H);
I = flood_fill(I,u,v-1,label,W,H);
I = flood_fill(I,u-1,v,label,W,H);
end
end

  0 Comments

Sign in to comment.

1 Answer

Answer by Image Analyst
on 9 Dec 2018 at 0:38

See my magic wand demo, which tries to copy the Photoshop magic wand tool.

  0 Comments

Sign in to comment.