Hold_My_Anger
Hold_My_Anger

Reputation: 1015

randomly select a 200x200 square inside an image in python

I am using python to work on my project in image processing. Suppose I got a very large image ( 100000 x 100000), and I need to randomly select a 200 x 200 square from this large image. Are there any easy way to do this job? Please share some light with me. Thank you

----------------------------- EDIT ------------------------------------

Sorry I don't think it is 100000 x 100000, but the resolution of images are in 1 km and 2km. I am having trouble with selecting the area of 200 x 200.

Upvotes: 2

Views: 612

Answers (1)

dstromberg
dstromberg

Reputation: 7177

If you convert to binary PPM format, then there should be an easy way to seek to the appropriate offsets - it's not compressed, so there should be simple relationships.

So pick two random numbers between 0 and 100000-200-1, and go to town.

(I'm assuming you don't have a system with 10's of gigabytes of RAM)

Upvotes: 4

Related Questions