MATLAB Answers

Transform raster image (points) to vector line

6 views (last 30 days)
Iryna Goriainova
Iryna Goriainova on 17 Jan 2020
Edited: Sergey Kasyanov on 20 Jan 2020
I have a raster image. In this image black points form a line.
Which matlab function help me to transform this points(raster) to line( vector)?
Unit point in line.
Thanks for answer!


Sergey Kasyanov
Sergey Kasyanov on 17 Jan 2020
Can you describe what are you need in detail?
Iryna Goriainova
Iryna Goriainova on 18 Jan 2020
Yes. I have binary image (left image). I want to transform image to vector. I want to select linian object.
I used this function
I = imread('pdfplan_trans_bw.png');
BW = edge(I(:,:,1));
[H,T,R] = hough(BW);
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
P = houghpeaks(H,50,'threshold',1);
x = T(P(:,2)); y = R(P(:,1));
% Find lines and plot them
lines = houghlines(BW,T,R,P,'FillGap',10,'MinLength',20);
figure, imshow(I), hold on
max_len = 0;
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
% Plot beginnings and ends of lines
% Determine the endpoints of the longest line segment
len = norm(lines(k).point1 - lines(k).point2);
if ( len > max_len)
max_len = len;
xy_long = xy;
As a result i get this(rigth image):
I can not find a good paramerets to build all lines.
Maybe, can I manual add unfinished lines? Or excist enouther methods?
Sergey Kasyanov
Sergey Kasyanov on 20 Jan 2020
You should try to rotate the image on some angle and get some frames with the Hough transform and choose the best.
Also try to run another implementations of transormation [1, 2, 3].

Sign in to comment.

Answers (0)

Sign in to answer this question.