Table of Contents
show
Copying the images
id – to find the object’s memory address

- When the object array “baboon” is assigned to “A”, then the id of A is same as baboon
- If the method copy() is applied and assigned it to “B”, then then the memory address is different
baboon[:,:,] = 0
- The above statement, makes the array “baboon” and “A” to be zero because they are pointing to the same memory location.
- But the array “B” remains same
Flipping Images – PIL
- Flipping images changes the orientation
- The image can be flipped by changing the index value of a pixel or intensity


- For color images, we can convert all the color channels at the same time
- PIL
- PIL have several ways to flip the image.
- ImageOps Module
from PIL import ImageOps
im_flip = ImageOps.flip(image)
im_mirror= ImageOps.mirror(image)
image.transpose(Image.FLIP_TOP_BOTTOM)
ImageOps Module has built-in attributes to determine type of flip.
FLIP_TOP_BOTTOM – flip the image upside down
FLIP_TOP_BOTTOM – flip the image upside down
Flip – vertical
Vertical flip reverses the order of rows

from PIL import ImageOps
image = Image.open("baboon.jpg")
im_flip = ImageOps.flip(image)
im_flip

Mirror – Horizontal Flip
Horizontal flip reverses the order of columns

im_mirror = ImageOps.mirror(image)
im_mirror
Transpose

image.transpose(Image.FLIP_TOP_BOTTOM)
- FLIP_TOP_BOTTOM to flip the image vertically
- FLIP_LEFT_RIGHT to flip the image horizontally (mirror)
Views: 1