4
我想要實現Photoshop中可用的漸變映射效果。 There's already a post that explains the desired outcome.此外,this answer佔地面積正是我想做的事,但Python - 將彩色貼圖應用於灰度numpy陣列並將其轉換爲圖像
im = Image.fromarray(np.uint8(cm.gist_earth(myarray)*255))
工作不適合我,因爲我不知道該怎麼陣列正常化的1.0的值。
下面是我的代碼,因爲我打算它的工作。
im = Image.open(filename).convert('L') # Opening an Image as Grayscale
im_arr = numpy.asarray(im) # Converting the image to an Array
# TODO - Grayscale Color Mapping Operation on im_arr
im = Image.fromarray(im_arr)
任何人都可以指出可能的選項和理想的方式來應用顏色映射到這個數組嗎?我不想繪製它,因爲似乎沒有簡單的方法將pyplot數字轉換爲圖像。
另外,你能指出如何正常化數組,因爲我無法這樣做,並且無法在任何地方找到幫助。
謝謝!但對於這個問題,你是否也可以建議一種應用顏色圖的方法? –
您發佈的代碼不適用於我建議的添加規範化? – jnovacho
它的確如此。我只想知道是否有辦法在功能上應用自定義顏色映射。 –