2014-02-21 1 views
1

저는 데비안에서 파이썬 2.7.5를 사용하고 있습니다. 정확히 cmap=plt.cm.gray의 기능은 무엇입니까? 회색이 회색 음영 색상 맵을 나타내는 경우이 명령을 사용하여 색상 이미지를 표시 할 수있는 방법은 무엇입니까?Python Colormap

plt.imshow(im,cmap=plt.cm.gray) 

답변

3

당신은 아마 다음 해석과 RGB 이미지로 표시되는 MxNx3 배열로 imshow를 제공하고 있습니다. 단순히 무시됩니다 제공된 어떤 cmap를,이 예를 고려해

image = np.random.rand(10,10,3) 

fig, axs = plt.subplots(1,2, figsize=(8,6)) 

axs[0].set_title('RGB image with gray cmap') 
axs[0].imshow(image, interpolation='none', cmap=plt.cm.gray) 

axs[1].set_title('Single layer image with gray cmap') 
axs[1].imshow(image[:,:,0], interpolation='none', cmap=plt.cm.gray) 

enter image description here

+1

내가 잊지 "* cmap를 무시 *을 때 * X * RGB (A) 정보가"워드 프로세서를 – zhangxaochen