i have CXX and CYY values in a matrix using this values i want draw a graph and i want to add edges using minimum spanning tree approach

3 visualizzazioni (ultimi 30 giorni)
i have CXX 20x20 matrix and CYY 20x20 matrix am using the plot function plot(CXX,CYY,'c*');
after plotting this am getting image like this
after this i want to consider all the plotted points as a node and i want to add edges to this nodes using minimum spanning tree approach please give me some code.
clc;
clear all;
close all;
X=imread('a.jpg');
imfinfo('a.jpg')
figure,imshow(X)
b = imresize(X,[100,100]);
si = size(b,1);
sj = size(b,2);
figure;imshow(b);
% Binarization
th = graythresh(b);
I = im2bw(b,th);
w = 5;
h = 5;
c=si/w;
r=sj/h;
kl=bwmorph(~I,'thin',inf);
figure,imshow(kl)
R(:,:)=kl(:,:);
I=1;
U1=w;
J=1;
U2=h;
E=1;
for i=1:r
for j=1:c
B(I:U1,J:U2)=R(I:U1,J:U2);
[x,y]=find(B==1);
CX=mean(x);
CY=mean(y);
CXX(E)=CX;
CYY(E)=CY;
T(I:U1,J:U2)=B(I:U1,J:U2);
J=J+w;
U2=U2+h;
E=E+1;
clear B x y
end
I=I+w;
U1=U1+h;
J=1;
U2=h;
end
imshow(R)
hold on
hold on
plot(CYY,CXX,'.c')
input image

Risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by