how to connect all points in a image
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
shivu kumar
el 9 de Abr. de 2017
Respondida: Image Analyst
el 11 de Abr. de 2017
i am plotting the points on image, but i want to connect the all points on the image please give me code or method to connect all the points.
clc;
clear all;
close all;
X=imread('math.jpg');
imfinfo('math.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','Markersize',8)
% hold off
r = imread('empty.jpg'); %Reading empty white blank image for plotting purpose
re = imresize(r,[100,100]);
figure,imshow(re)
% hold on
hold on
plot(CYY,CXX,'.k','Markersize',10);
hold off

help me to connect the all points on the image.
2 comentarios
Image Analyst
el 11 de Abr. de 2017
All the points in each letter are already "connected". Perhaps you should just threshold and call bwlabel() to give the pixels in each letter the same class (ID) number.
Respuesta aceptada
Image Analyst
el 9 de Abr. de 2017
I don't know what your code does because (1) it's uncommented, (2) the indentation is messed up, and (3) it's an alphabet soup with no indication what variables like U1, U2, T, B, J, kl, etc. mean. It's unmaintainable code.
So all I can tall you is how I'd tackle the image. I'd get the distance of every point to every other point using either pdist2() (in the Stats toolbox) or a double for loop. Then for all pairs of points that are less than some predetermined distance, I'd draw a line between them. I have attached demo code for burning lines into a image.
3 comentarios
Image Analyst
el 9 de Abr. de 2017
If you already know the points you want to connect, simply see my demo where I do exactly that. Basically use imline() to create a binary image then use that as a mask to set a value in your original image.
Más respuestas (1)
Image Analyst
el 11 de Abr. de 2017
Regarding your new image written with a felt marker, see the attached code.

0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


