Subject: Image Object color 的問題(使用IDLgrPalette) |
Author:
Rendy
|
[
Next Thread |
Previous Thread |
Next Message |
Previous Message
]
Date Posted: 20:12:32 11/05/03 Wed
如何在image object上,針對一個index data,要給予一個colortable,colortable=[[0,0,0],[0,0,255],[0,255,0],[0,255,255],[255,0,0],[255,255,255]]這樣6個顏色,
想讓data中1為colortable中第一個顏色,以此類推,
這是要用palette嗎?可是不瞭解他如何用index對應到RGB三色
Ans:
該是要用Palette物件.
對應的方式就是直接用Image內容的值對應至Color table的Index,
以下為範例, 請參考
Pro tColor
;建立一個600x600的Image, 其值在範圍:0-5
a = bytscl(dist(600,600), TOP=5)
help, a
print, max(a), min(a)
;你提供的COLOR table:
;[[0,0,0],[0,0,255],[0,255,0],[0,255,255],[255,0,0],[255,255,255]]
;建立Palette物件
aRed = [0, 0, 0, 0, 255, 255]
aGreen = [0, 0, 255, 255, 0, 255]
aBlue = [0, 255, 0, 255, 0, 255]
oPalette = obj_new('IDLgrPalette', aRed, aGreen, aBlue)
;建立Image物件, 並使用Palette物件作為PALETTE關鍵字的內容
oImg = obj_new('IDLgrImage', a, PALETTE=oPalette)
;顯示Image物件
xobjview, oImg
End
[
Next Thread |
Previous Thread |
Next Message |
Previous Message
]
| |