我做了关于numpy的教程[https://matplotlib.org/3.1.0/tutorials/colors/colormap-manipulation.html],但我没有找到任何教程来获取rgb像素的颜色贴图位置,例如(1001501001)。有什么想法吗??
我最终迭代了我的颜色Map中存在的每种颜色:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.colors import ListedColormap, LinearSegmentedColormap
import time
magma = cm.get_cmap('magma',256)
bottom = cm.get_cmap('binary',256)
## print(magma(0.5))
newcolors=np.vstack((bottom(np.linspace(0,1,128)),magma(np.linspace(0,1,128))))
newcmp = ListedColormap(newcolors)
def colorfinder(colormap,pixel,delta):
for i in range(len(colormap)):
if(pixel[0]>newcolors[i][0]-delta and pixel[0]<newcolors[i][0]+delta):
if(pixel[1]>newcolors[i][1]-delta and pixel[1]<newcolors[i][1]+delta):
if(pixel[2]>newcolors[i][2]-delta and pixel[1]<newcolors[i][2]+delta):
print(i)
dot=np.zeros(4)
dot=[0/256,16/256,110/256,1]
colorfinder(newcolors,dot,0.037)
暂无答案!
目前还没有任何答案,快来回答吧!