2017-10-12 26 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