I have an image which is resize to 128x128. I want to crop the center of the image(which is the ROI) with , a square of n size.
我有一个图像,调整大小为128x128。我想用n个正方形裁剪图像的中心(即ROI)。
I know cropping can be done by
我知道裁剪可以通过
imcrop
and center of an image can be found out using
可以使用找到图像的中心
center=size(I)/2+.5.
How can I use this two information togather inorder to crop the center part of my image
如何使用这两个信息来收集以裁剪图像的中心部分
1 个解决方案
#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);
this will do the same which I asked:-)
这会像我问的那样做:-)
#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);
this will do the same which I asked:-)
这会像我问的那样做:-)