首页 > 解决方案 > 调整图像大小并仅在中心周围显示 100x100 像素

问题描述

我想用 cv2 调整图像的大小,使图像只有 100x100 大,并用 imshow 显示。

从:

在此处输入图像描述

至:

在此处输入图像描述

cv2 中是否有一个函数会遗漏部分图像?

标签: pythonopencvimage-processing

解决方案


感谢busybyte,我找到了答案:

img = cv.imread("PATH")
centerx, centery = [int(img.shape[0] / 2) - 50, int(img.shape[1] / 2) - 50]
img = img[centerx:centerx + 100, centery:centery + 100]

它将图像从中心裁剪为所需的 100x100 大小。


推荐阅读