How to use "gplot" function?

5 次查看(过去 30 天)
Hey Every body;
I want to graph a matrix using "gplot" function, i had get the each object boundary in the image using the following:
[B L N A]=bwboundaries(bw,'noholes');
through that function i got 4 output: L for label matrix / N is no. of object found/ A is adjacent matrix...
To graph that labeled image i have 2 thoughts :
1- consider each boundray as a separate matrix a get it's coordinates and plot
as follow
[i j]=find(cell2mat(B(2,:));
gplot(B(2,:), [i j]);
but the result is a separate straight line!!
2- consider each connected component in the labeled matrix as anode then get it's coordinate and plot graph connecting those nodes
(i think that the second option is more reliable but i don't know how to implement regarding my poor )
Thanks A lot

采纳的回答

Kelly Kearney
Kelly Kearney 2013-7-5
I assume you want to plot based on the adjacency matrix A? You'll have to figure out exactly how to define an objects coordinates... an edge point? The centroid?
In the example below, I've just chosen the first point of each boundary. Is this similar to what you're looking for?
BW = imread('blobs.png');
[B, L, N, A] = bwboundaries(BW,'noholes');
xy = cell2mat(cellfun(@(x) [x(1,2) x(1,1)], B, 'uni', 0));
figure;
imshow(BW)
hold on
plot(xy(:,1), xy(:,2), 'b.')
gplot(A, xy, 'r');
  2 个评论
Mariam Sheha
Mariam Sheha 2013-7-6
yes it's very near to what i am looking for,thanks alo0ot
but unfortunately their is still problem that i can't apply to the target point, where that way I link the boundries to each other , but what i mainly have to implement is considering the connected component whatever using boundary or not (i.e: each boundary may have no. of connected components ) and represent it as a node.. brief explanation is listed below.
Regarding the binary image of the connected components (the edges of the images) :
1- Each pixel in the connected component is a node of Gi . (How can i annotate that connected component to be a node?)
2- Each node has a unique label according to its coordinate. (That coardinate is suppose to be used for the gplot function i think)..
I think i am too near but i can't reach...
if you do understand what i miss, please repot me..
Thanks in advance
Kelly Kearney
Kelly Kearney 2013-7-8
Sorry, I really don't understand what you're trying to do. Are you trying to identify a single object in a binary image, and then graph the connectivity of the pixels that make up that single object (i.e. 4-way or 8-way connectedness used to identify an object)? Or are you looking for the connectivity of multiple object in an image, as returned by bwboundaries (i.e. whether one object is within another)?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by