2017-10-12 68 views
0

我在圖像上畫了一條線,我希望將線平均分割/劃分5次並獲得5個點座標,在腳本中我有座標線但我不知道如何繼續。我會感謝任何幫助。謝謝split equal imline - Matlab

clc; 
clear all; 

figure, imshow('pout.tif'); 
h = imline; 
lineEndPoints = wait(h); 

x1 = round(lineEndPoints(1,1),2); 
y1 = round(lineEndPoints(1,2),2); 
x2 = round(lineEndPoints(2,1),2); 
y2 = round(lineEndPoints(2,2),2); 

回答

1

它只是將線劃分爲5個相等的片段?

>> x = lineEndPoints(1:2,1) 

x = 

    32 
    327 

>> y = lineEndPoints(1:2,2) 

y = 

    48 
    485 


>> a = (0:5)/5 

a = 

     0 0.2000 0.4000 0.6000 0.8000 1.0000 

>> x = x(1) + (x(2)-x(1))*a 

x = 

    32 91 150 209 268 327 

>> y = y(1) + (y(2)-y(1))*a 

y = 

    48.0000 135.4000 222.8000 310.2000 397.6000 485.0000