Posts

Showing posts from March, 2013

Bounding Box in PIL (Python Image Library)

Image
Bounding Box in PIL(Python Image Library) : Bounding Box function of PIL can be very useful for removing unused pixels from an image. Eg. If we want to remove unused pixels based on alpha channel of an image, we can use following code.   im = Image.open(imagePath) r,g,b,a = im.split() left,upper,right,lower = a.getbbox() tempImage = im.crop((left,upper,right,lower)) newPath = imagePath.split(".")[0]+"_Cropped" + "." + imagePath.split(".")[1] tempImage.save(newPath) To understand which values, getbbox() function returns and what do they look like on an image, I created an image showing the values returned by the function. left,upper,right,lower = image.getbbox()   Suppose you have a point in an original image and you want to find out the new position of the same point in the cropped image, lets see how we can do it. Suppose the point is at (300,450) position in an original image, so after cr

Some Regex Expressions

http://www.tutorialspoint.com/python/python_reg_expressions.htm

Nice Little Game Development Breakdown.

http://blogs.wsj.com/digits/2013/03/04/behind-the-making-of-a-mobile-game/