Untitled
import numpy as np import matplotlib.pyplot as plt img1 = plt.imread('test.jpg') img = np.zeros([120, 300, 3], dtype=np.uint8) h, w = img1.shape[:2] img2 = np.copy(img1) for x in range(w): for y in range(h): color = (img1[y, x]) + (255 + 0 + 255) / 255 img2[y, x] = color # create show image from function rgb2gray plt.imshow(img2, cmap='gray') plt.show()