Find branches in a skeleton?

When you make a skeleton from a binary image you can extract branch points. However I m trying to find out which branch points are connected to which. I can find the index of the branch points. So I have a skeleton with labeled branch points and I can physically view the nodes that are connected to one another but I cannot seem to generate these connections in code? eg branch point 3 is connected to branch point 5.

댓글 수: 6

Ronan
Ronan 2015년 9월 15일
it really would have helped if the bmorph(bw, 'branchpoints')function returned more information. Basically my guess is that because the branch points were found from a mask that just iterates through each pixel, it doesn't record the order of the branch connections.
Image Analyst
Image Analyst 2015년 9월 15일
Can you give the pixel layout where you'd have two branchpoints that are next to each other (connected to each other). If it was like a T then you'd have only one branchpoint in isolation - not touching any other branchpoint.
Ronan
Ronan 2015년 9월 15일
편집: Walter Roberson 2015년 9월 15일
pic = imread('boo.bmp');
pic = rgb2gray(pic);
I = im2bw(pic);
BW3_skel = bwmorph(I,'skel',inf);
figure(1);
imshow(BW3_skel);
BW3_branchpoints = bwmorph(BW3_skel, 'branchpoints');
the_r = pic;
the_g = pic;
the_b = pic;
the_r(BW3_skel) = 255;
the_g(BW3_skel) = 0;
the_b(BW3_skel) = 255;
the_out = cat(3,the_r,the_g,the_b);
figure(2)
imshow(the_out);
[node_x,node_y] = find(BW3_branchpoints == 1);
hold on
%imshow(myImage);
nodes = [(1:length_node_x); the_nodes]';
plot(nodes(:,2), nodes(:,3),'b.');
length_node_x = length(node_x);
the_nodes = zeros(2,length_node_x);
the_nodes(1,1:end) = node_y(1:end);
the_nodes(2,1:end) = node_x(1:end);
for s = 1:length_node_x
text(nodes(s,2),nodes(s,3),[' ' num2str(s)], 'Color', 'r');
%plot(nodes(segments(s,2:3)',2),nodes(segments(s,2:3)',3),'c');
end
disp(nodes);
The out put of the nodes is in the format [index, x, y].
I have also attached the two outputs from the code that displays the skeleton image with the labeled nodes.
1 2 245
2 4 2
3 25 119
4 60 119
5 70 2
6 71 11
7 132 128
8 139 230
9 143 17
10 320 12
karishma singh
karishma singh 2017년 8월 6일
Hi, I tried running this code..it gave me below error - Error using fopen File name must be a vector of type char.
Error in isdicom (line 9) fid = fopen(filename, 'r');
Error in images.internal.getImageFromFile (line 44) if (isdicom(filename))
Error in images.internal.imageDisplayParseInputs (line 74) images.internal.getImageFromFile(common_args.Filename);
Error in imshow (line 222) images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
Error in Preprocess (line 52) imshow(the_out);
Walter Roberson
Walter Roberson 2017년 8월 6일
karishma singh: which code was it that you ran? None of the code that is posted in this Question calls Preprocess or defines a variable named the_out ?
karishma singh
karishma singh 2017년 8월 8일
Preprocess.m is just my file name. I ran the code posted by Ronan using my skeleton image.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2015년 9월 15일

0 개 추천

I think you'll need to get an image of just the branch points. Then an image of just the branches with the branchpoints removed. Then pick two branchpoints to test and make an image with just those two. Then put in each branch one at a time and call bwdistgeodesic() to see if they're connected by that branch.

댓글 수: 1

Ronan
Ronan 2015년 9월 15일
I was hoping to do it without the bwdistgeodesic function because my version of matlab doesn't have that function. I was thinking of trying to traverse the skeleton path and while traversing keep checking if the skeleton pixel is one of the nodes. It would probably involve a mask for checking if adjacent pixels are the skeleton however this solution is tricky and maybe computationally expensive. also it seems like reinventing the wheel because thats how some of the bwmorph operations work. Do you know is there an open source or alternative version to bwdistgeodesic?

댓글을 달려면 로그인하십시오.

질문:

2015년 9월 15일

댓글:

2017년 8월 8일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by