I have an assignment where I need to apply a colormap to an image and generate a numpy array. I am unsure how to create and apply the function to the image.
Here is what I have,
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from matplotlib import cm
from matplotlib.colors import ListedColormap, LinearSegmentedColormap
mars_gray = mpimg.imread('img.png')
lum_img = mars_gray[:, :, 0]
plt.imshow(lum_img, cmap='gray')
print (lum_img)
def colorMapPlasma(red, green, blue):
cdict = {'red': [(0.0, 0.0, 0.0),
(0.2, 0.0, 0.14),
(0.75, 1.0, 1.0),
(1.0, 0.7, 0.7)],
'green': [(0.0, 0.0, 0.14),
(0.24, 0.14, 0.24),
(0.3, 0.7, 0.7),
(0.4, 0.3, 0.0),
(1.0, 0.0, 0.0)],
'blue': [(0.0, 1.0, 1.0),
(0.28, 0.0, 0.0),
(1.0, 0.0, 0.0)]}
return cdict
result = colorMapPlasma(lum_img[1],lum_img[2],lum_img[3])
print(result)