【问题标题】:Cropping the center of an image : Matlab裁剪图像的中心:Matlab
【发布时间】:2019-04-01 14:43:02
【问题描述】:

我有一张调整为 128x128 的图片。我想用 n 大小的正方形裁剪图像的中心(即 ROI)。

我知道裁剪可以通过

 imcrop 

图像的中心可以使用

 center=size(I)/2+.5.

如何结合使用这两个信息来裁剪图像的中心部分

【问题讨论】:

  • 很高兴您自己解决了这个问题。本着本网站的精神,很高兴展示您的解决方案 - 或删除问题......
  • @ANUSHADEVI 将其作为答案发布并接受它

标签: matlab image-processing


【解决方案1】:
II = imread('img.png')
[p3, p4] = size(II);
q1 = 50; // size of the crop box
i3_start = floor((p3-q1)/2); % or round instead of floor; using neither gives warning
i3_stop = i3_start + q1;

i4_start = floor((p4-q1)/2);
i4_stop = i4_start + q1;

II = II(i3_start:i3_stop, i4_start:i4_stop, :);
figure ,imshow(II);

这和我问的一样:-)

【讨论】:

    猜你喜欢
    • 2016-12-05
    • 2014-05-26
    • 2019-05-13
    • 1970-01-01
    • 1970-01-01
    • 2013-08-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多