小编Ric*_*ose的帖子

如何根据百分比在 opencv 和 python 中裁剪图像

我想拍摄一张图像并将其从原始图像的中心裁剪 75%。说实话,我有点不知所措。我曾想过获取原始图像大小

height, width = image.shape
Run Code Online (Sandbox Code Playgroud)

获取百分比值和裁剪:

cropped_y_start = int((height * 0.75))
cropped_y_end = int((height * 0.25))
cropped_x_start = int((width * 0.75))
cropped_x_end = int((width * 0.25))

print cropped_x_start
print cropped_x_end

crop_img = image[cropped_y_start:cropped_y_end, cropped_x_start:cropped_x_end]
Run Code Online (Sandbox Code Playgroud)

这有多个问题,但主要问题是它不是基于图像的中心。对此的任何建议将不胜感激。

opencv python-2.7

2
推荐指数
1
解决办法
3482
查看次数

标签 统计

opencv ×1

python-2.7 ×1