Image Blob Detection Using Recursive Flood Fill
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Image Analyst
2018 年 12 月 9 日
See my magic wand demo, which tries to copy the Photoshop magic wand tool.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!