使用最小生成树向节点添加边

时间:2017-03-31 05:01:08

标签: matlab image-processing pattern-matching

帮助我,我想使用最小生成树为节点添加边缘

   %clc;
%clear all;
close all;
X=imread('d3.jpg');
imfinfo('d3.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
 %CYY(isnan(CYY)) = [];
 %CXX(isnan(CXX)) = [];
  end

I=I+w;
U1=U1+h;
J=1;
U2=h;

end
%kl(isnan(kl(:,1)),:) = [];
imshow(R)
hold on

hold on
plot(CYY,CXX,'.c')
hold off
r = imread('empty.jpg');
re = imresize(r,[100,100]);
figure,imshow(re)
hold on
hold on
plot(CYY,CXX,'.k','Markersize',8);
hold off

这是我的代码我正在获取节点,但我想使用最小跨度连接到节点 this is my output image i want to add edges to this image using minimum spanning tree

0 个答案:

没有答案