如何使用python选择图像的一部分? [英] How can i select a part of a image using python?

查看:1548
本文介绍了如何使用python选择图像的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用卫星图像,我需要选择图像的一部分才能工作。我该怎么做? Im.crop看起来没有用。调整大小?

I'm working with satellites images and i need to select one part of the image to work if. How can i do it? Im.crop doesn't seen to work. Resize?

谢谢

推荐答案

from PIL import Image
im = Image.open("test.jpg")

crop_rectangle = (50, 50, 200, 200)
cropped_im = im.crop(crop_rectangle)

cropped_im.show()

请注意作物区域必须以4元组的形式给出 - (左,上,右,下)。

Note that the crop region must be given as a 4-tuple - (left, upper, right, lower).

此处有更多详情使用图像类

这篇关于如何使用python选择图像的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆