I want to read image and use cmap="gray"
and then return the image for further image processing. I tried this:
import cv2
import tkinter.filedialog as fd
from matplotlib import pyplot as plt
def change_plt_colormap(filepath):
image = cv2.imread(filepath)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gray_cmap = plt.imread(gray, cmap="gray")
return gray_cmap
filepath = fd.askopenfilename()
change_plt_colormap(filepath)
But this gives an error:
TypeError: imread() got an unexpected keyword argument 'cmap'
I tried to search from web but I did not find any instructions on how to change the cmap
argument and then return the grayscale image. How could I do this?