Upload a grayscale cat image to Google Colab
Load the grayscale image into a numpy array
import cv2
import numpy as np
import matplotlib.pyplot as plt
from google.colab import files
mycolor = cv2.imread('cat-grayscale.jpg')
resized = cv2.resize(mycolor, (128, 128), interpolation = cv2.INTER_AREA)
mygray = cv2.cvtColor(resized, cv2.COLOR_BGR2GRAY)
print(mygray.shape)
print(mygray[:15, :15])
print(mygray.shape)
plt.imshow(mygray, cmap='gray')
plt.colorbar()
plt.show()
np.savetxt('mycat.csv', mygray, fmt='%.1f', delimiter =',')
files.download('mycat.csv')