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!