Somehow my code doesn't work and I don't know why
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm writing an algorithm to succesfully segment 3D images of roots in soil. I have to seperate the main root from the first order branches and so on. In order to do so I have made a skeleton, which I used to find the junctions between branches. I use these points as the centre of a growing logical sphere which I multiply with the original binary (tresholded) image. As soon as there are 2 objects in my image, the sphere needs to stop growing so I can segment the image.
I wrote this code to do this:
mid_point = {31,38,39};
number_of_objects = 1;
count = 1;
while(number_of_objects < 2)
volume = zeros(dimx,dimy,dimz);
volume(mid_point{:})=1;
B = imdilate(volume,strel('sphere', count) );
new_im = (g_thres.*abs(1-B));
[a number_of_objects] = bwlabeln(new_im);
count = count+1;
end
The dimensions are 100*100*80, however it will also be used on way bigger images (1000*1000*1000), so using a for loop isn't really an option I think.
When I run the code, after 30 minutes there are still no results and than I terminate it, since it isn't usefull if it is that slow. Can somebody please explain to me why this code doesn't work (or is at least very slow).
Thank you very much,
Charles
0 commentaires
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 2 Sep 2017
Try attaching a small data file so we wan start working on solving this for you. And let us know whether the foreground is black or white, because the algorithm doesn't make sense to me. And add some comments.
One way might be to identify endpoints, then use a shortest path algorithm, bwdistgeodesic(), to find the longest root. See Steve's 5 part blog series on this: http://blogs.mathworks.com/steve/2011/11/01/exploring-shortest-paths-part-1/
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!