VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time ]
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 ]


Post a message:
This forum requires an account to post.
[ Create Account ]
[ Login ]
[ Contact Forum Admin ]


Forum timezone: GMT-8
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.