1
$\begingroup$

I have a skeleton image. I am able to detect branchpoints, endpoints and able to label image using BWMorph, BWLabel. Now I want to differntiate between skeleton center line and branches. In short I want to detect branches in skeleton. I want to perform operations on skeleton branches and I do not want to consider center line in these operations. Can someone help? Following is skeleton image. http://www.flickr.com/photos/92388309@N03/8397759970/in/photostream/ Arrows in following image show center line of skeleton. http://www.flickr.com/photos/92388309@N03/8404495186/in/photostream/

Following is code I have used.

mn=bwmorph(y,'branchpoints');
[row column] = find(mn);
branchPts    = [row column];
endImg    = bwmorph(y, 'endpoints');
[row column] = find(endImg);
endPts       = [row column];
figure;imshow(y);
hold on ; 
plot(branchPts(:,2),branchPts(:,1),'rx');
hold on; plot(endPts(:,2),endPts(:,1),'*');
% Labeling the Branches
branches = imsubtract(y,mn); % set branch points to zero
figure; imshow(branches);title('no bp')
branchesLabeled = bwlabel( branches); % label connected components
vislabels(branchesLabeled);
% Calculation of Length of Branches and Circular Neighbourhood Method for
% for detection of normal and abnormal branches.
sts = regionprops( branchesLabeled,'Area', 'Perimeter','MajorAxisLength','Centroid' );
figure
imshow(branchesLabeled)
hold on
% Loop for circles
for i=1:size(sts)
r= sts(i).MajorAxisLength/2 ; %desired radius
centerx = sts(i).Centroid(1);  
centery = sts(i).Centroid(2);
th = 0:pi/50:2*pi;
xunit = r * cos(th) + centerx;
yunit = r * sin(th) + centery;
plot(xunit, yunit);
end 
$\endgroup$

migrated from stackoverflow.com Jan 24 '13 at 15:04

This question came from our site for professional and enthusiast programmers.

  • $\begingroup$ What are these operations on the skeleton that you want to perform ? It might be possible to recover the main branches in its entirety after you perform these operations. $\endgroup$ – mmgp Jan 24 '13 at 15:18
  • $\begingroup$ Thank you for your reply. I want to draw circle on each branch with branch lengh/2 as a redius. And I do not want circle on the center line of skeleton. $\endgroup$ – user1984451 Jan 24 '13 at 17:07
  • $\begingroup$ may i take your code to detect branchpoints, endpoints and label image using BWMorph, BWLabel? thanks for ur respon :) $\endgroup$ – user9045 May 28 '14 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.