Image manipulation is a key technique in computer vision.This helps to better prepare our data for training .
In this short tutorial we would highlight various technique required for image manipulation
- Load Image
`
import skimage.io as io #for input output manipulations on the image
import matplotlib.pyplot as plt
import numpy as np
you can download any color image from google.com to use for this lab
Read the image
img = io.imread('/content/Screenshot 2023-05-05 at 09.45.04.png')
plt.imshow(img)
plt.show()
`
- Image shape
img.shape
(675, 1272,3)
The 3 means it contains three layer RGB(Red,Green and blue) all layered on each other.
- Slipt layers in different section
`
Split
red = img[:, :, 0]
green = img[:, :, 1]
blue = img[:, :, 2]
`
- Preview Split layers based on color
`
plt.imshow(red, cmap="Reds")
plt.show()
============================================
plt.imshow(green, cmap="Greens")
plt.show()
============================================
plt.imshow(blue, cmap="Blues")
plt.show()
`
Image Transformation
Using tensorflow you can run image argumentation to create muitiple variation of the same image
`
Rotation
import tensorflow as tf
transformation = tf.keras.preprocessing.image.apply_affine_transform(
img,
theta=270
)
plt.imshow(transformation)
Ship image
import tensorflow as tf
transformation = tf.keras.preprocessing.image.apply_affine_transform(
img,
tx=500,
ty=500,
)
plt.imshow(transformation)
`
Thanks for reading
Top comments (0)