필터 지우기
필터 지우기

Draw 2 lines in image

조회 수: 3 (최근 30일)
Sajid Rahim
Sajid Rahim 2017년 8월 28일
댓글: Benjamin Kndson 2018년 4월 30일
i Have a code
I = imread('2.png') ;
I = rgb2gray(I) ;
[y,x] = find(I) ;
figure
imshow(I)
hold on
plot(x,y,'.b')
plot(x(1),y(1),'*y')
plot(x(end),y(end),'*r')
now i want to draw one line from first point(yellow one) and another one line from end point (red one)... plz help me
  댓글 수: 2
KSSV
KSSV 2017년 8월 28일
YOu can draw infinite lines......what is the criteria to draw lines?
Benjamin Kndson
Benjamin Kndson 2018년 4월 30일
Objective. Draw a box using Bresenhams line code http://www.mathworks.com/matlabcentral/fileexchange/12939-bresenhams-line
Draw a perfect box(90 Degree angles, same side lengths)
Allow user to read in an image, then using ginput function, the user can draw a line, anydirection. Based on this line create a perfect box. ask the user for box "left" or "right" from input line.

댓글을 달려면 로그인하십시오.

답변 (2개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2017년 8월 28일
%if true
I = imread('2.png') ;
I = rgb2gray(I) ;
[y,x] = find(I) ;
figure
imshow(I)
hold on
plot(x,y,'.b')
plot(x(1),y(1),'*y')
plot(x(end),y(end),'*r')
hold on;
line([x(1) y(1)], [x(end) y(end)]);
hold off;
%end
  댓글 수: 1
Sajid Rahim
Sajid Rahim 2017년 8월 29일
thank you for ANS but actualy i want to draw 2 lines , one line from x1 y1 to another pont say C.... and another line from x(end)y(end) to C...

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2017년 8월 29일
Just call plot() again with the new coordinates or call line() instead.

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by