【问题标题】:imcrop - Matlabimcrop - Matlab
【发布时间】:2015-11-09 18:49:52
【问题描述】:

我想根据图像的中心裁剪一个框,因此我对 imcrop 感到困惑。

主要是,我想在中心上方/下方/左侧/右侧裁剪 50 像素的框,但我无法获得正确的坐标。此外,如何在原始图像上标记框。

谢谢。

脚本:

clc;
clear;
I = imread('m83.tif');
imshow(I)
[height, width, dim] = size(I);
centerWidth=round(width/2)
centerHeight=round(height/2)
BoxBottomX=centerWidth-50;
BoxBottomY=centerHeight-50;
BoxTopX=centerWidth+50;
BoxTopY=centerHeight+50
imshow(I)
hold on
plot(centerWidth, centerHeight, '-rx')

imcrop(I, [BoxBottomX BoxBottomY BoxTopX BoxTopY]);

【问题讨论】:

    标签: matlab image-processing


    【解决方案1】:

    imcroprec选项不是盒子的坐标,而是[xmin ymin width height]。所以如果你想裁剪一个 100x100 的盒子,你应该这样做

    imcrop(I, [BoxBottomX BoxBottomY 100 100]);
    

    然后您可以使用点来绘制 4 条线或使用函数rectangle 绘制一个矩形(注意这个也采用[xmin ymin width height] 格式)

    【讨论】:

    • 谢谢,在imcrop中使用100 100的逻辑是什么?
    • @user2916044 宽度-高度。你的正方形有多长? 100x100(至少在您显示的代码中)
    猜你喜欢
    • 1970-01-01
    • 2014-10-20
    • 1970-01-01
    • 1970-01-01
    • 2012-07-02
    • 2018-05-22
    • 2013-07-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多