In [5]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
In [2]:
# loading image
img = mpimg.imread('i/super_mario_head.png')
# creates sub plots of 15x15
f, (plt1, plt2, plt3, plt4) = plt.subplots(1, 4, figsize=(15, 15))
plt1.set_title('Original'); plt1.imshow(img);
# showing each channel img[x,y,color_plane]
plt2.axis('off'); plt2.set_title('Red'); plt2.imshow(img[:,:,0], cmap='gray');
plt3.axis('off'); plt3.set_title('Luigi'); plt3.imshow(img[:,:,1], cmap='gray');
plt4.axis('off'); plt4.set_title('Blue'); plt4.imshow(img[:,:,2], cmap='gray');
In [3]:
# creates sub plots of 15x15
f, (plt1, plt2, plt3, plt4) = plt.subplots(1, 4, figsize=(15, 15))
# cutting the image
eye_brow = img[100:150, 150:200,]
eye_split = eye_brow[40:50, 20:30]
zoomed_eye_split = eye_split[4:8, 0:4]
plt1.axis('off'); plt1.imshow(img, interpolation='nearest');
plt2.axis('off'); plt2.imshow(eye_brow, interpolation='nearest');
plt3.axis('off'); plt3.imshow(eye_split, interpolation='nearest');
plt4.axis('off'); plt4.imshow(zoomed_eye_split, interpolation='nearest');
In [4]:
latest_pixel = zoomed_eye_split[3, 3]
print("R intensity at x=3, y=3 is",round(256 * latest_pixel[0]))
print("G intensity at x=3, y=3 is",round(256 * latest_pixel[1]))
print("B intensity at x=3, y=3 is",round(256 * latest_pixel[2]))