【问题标题】:split equally imline - Matlab等分 imline - Matlab
【发布时间】:2017-10-13 02:23:16
【问题描述】:

我在图像上画一条线,我希望将这条线平均分割/分割 5 次并获得 5 个点坐标,在脚本中我有线坐标,但我不知道如何继续。我将不胜感激。谢谢

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); 

【问题讨论】:

    标签: matlab


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-02
      • 2011-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-25
      相关资源
      最近更新 更多