【问题标题】:How to construct a rect structure in matlab giving four point's using ginput如何在matlab中构造一个矩形结构,使用ginput给出四个点
【发布时间】:2012-11-28 08:32:22
【问题描述】:

我正在尝试构建一个 rect 结构,该结构由函数 ginput 接收到 4 个点,以通过该矩形裁剪图像。

我有这样的事情:

[x,y] = ginput(4);
input_points = [x(1) y(1); x(2) y(2); x(3) y(3); x(4) y(4)];
...

disp([round(x(1)) round(x(2)) round(abs(x(2)-x(1))) round(abs(y(4)-y(1)))]);
image = imcrop(image,[round(x(1)) round(x(2)) round(abs(x(2)-x(1))) round(abs(y(4)-y(1)))]);

但是不起作用,显示的值太大了。 有谁知道怎么做?

提前致谢。

【问题讨论】:

    标签: image matlab crop


    【解决方案1】:

    试试这个

    rec=round([min(x), min(y), max(x)-min(x), max(y)-min(y)]);
    image2 = imcrop(image,rec);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-12
      • 2012-08-22
      • 1970-01-01
      • 1970-01-01
      • 2022-11-02
      • 1970-01-01
      相关资源
      最近更新 更多