在matplotlib(特别是matplotlib.cm)中,可以调用色彩映射表中的颜色,如下所示 import matplotlib.cm as cm
cm.viridis(0.5) #viridisis the name of a colormap 它从色彩映射表的中心(也就是(0.127568, 0.566949, 0.550556, 1.0))获取颜色,基本上我希望能够调用一个从库中获取的色彩映射表您可以导入特定的调色板,如下
我创建了一个函数,可以将图像转换为灰度图像,也可以将图像转换为二进制图像。然而,返回值(应该是二进制图像)是紫色和黄色的。当我做'cmap = 'gray'‘时,它在函数中是正确的,但是,我不能在返回时做这件事。我怎么才能纠正它呢? 我当前的代码是: def greyscale_and_binary(file, file_name): this function graphs a histogram for the greyscale for the file inputed. It converts the image