Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i select a part of a image using python?

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?

Thanks

like image 915
Carlos Pinto da Silva Neto Avatar asked Jun 27 '11 17:06

Carlos Pinto da Silva Neto


1 Answers

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

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

cropped_im.show()

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

More details here Using the Image Class

like image 117
symmetry Avatar answered Sep 28 '22 03:09

symmetry