Re: Change Color Table [message #14891] |
Fri, 02 April 1999 00:00 |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Stein Vidar Hagfors Haugan (steinhh@ulrik.uio.no) writes:
>> You can either download an earlier version of XColors from
>> the "old program" archive on my web page, or replace the
>> offending line of code with something like this:
>>
>> s = Size(info.notifyobj)
>> nelements = s[s[0]+2]
>
> But why not just use n_elements(info.notifyobj) instead?
>
> I've never understood why anybody would want to use the
> /N_Elements keyword in Size() given the availability of
> the built-in function n_elements(). Portability plus
> backwards compatibility, what more could you want..?
This is just one of the tricks you learn when you
get paid by the hour to write programs. Not only is
this TWO lines instead of one, its a lot harder to
understand. Very rare to get two positive benefits
with the same piece of code. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Change Color Table [message #14893 is a reply to message #14891] |
Fri, 02 April 1999 00:00  |
steinhh
Messages: 260 Registered: June 1994
|
Senior Member |
|
|
David Fanning wrote:
> You can either download an earlier version of XColors from
> the "old program" archive on my web page, or replace the
> offending line of code with something like this:
>
> s = Size(info.notifyobj)
> nelements = s[s[0]+2]
But why not just use n_elements(info.notifyobj) instead?
I've never understood why anybody would want to use the
/N_Elements keyword in Size() given the availability of
the built-in function n_elements(). Portability plus
backwards compatibility, what more could you want..?
Regards,
Stein Vidar
|
|
|
Re: Change Color Table [message #14906 is a reply to message #14891] |
Thu, 01 April 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
VU KHAC Tri (tvk@info.fundp.ac.be) writes:
> Having 2 widget-draw in a dialog I want to be able to apply 2 different
> color tables for these 2 widgets individually. I tried to do this with
> XLoadCT, but it changes color tables in both 2 widgets.
If you are running on an 8-bit display, you have
to divide you color table in half and scale your image
data to use only values in one or the other half of the
color table range. Then, be sure to use the NCOLORS keyword
with XLOADCT:
image = LoadData(7)
LoadCT, 5, NColors=100
Window, 0, XSize=360, YSize=360
TV, BytScl(image, Top=99)
LoadCT, 3, NColors=100, Bottom=100
Window, 1, XSize=360, YSize=360
TV, BytScl(image, Top=99) + 100B
Now, to change colors in the first window:
XLoadCT, NColors=100
To change colors in the second window:
XLoadCT, NColors=100, Bottom = 100
With 24-bit color everything is a whole lot simpler. Just
change the color tables and display the images. Be sure
to turn color decomposition OFF.
(LoadData can be downloaded from my web page.)
The only thing that XColors will give you that XLoadCT
will not is the ability to have more than one color table
tool on the display at once. XLoadCT can't do this because
it uses the dreaded Common block to store its color information. :-(
XColors, NColors=100, Title='Window 0 Colors'
XColors, NColors=100, Bottom=100, Title='Window 1 Colors'
> I've got the XColor.pro of D.Fanning, but I cannot compile it since my
> IDL
> version is 5.0. The compilator signals this error:
>
> nelements = SIZE(info.notifyobj, /N_Elements)
>
> % Keyword parameters not allowed in call.
> At: /home/black/tvk/programming/idl/examples/xcolors.pro, Line 446
> % 1 Compilation errors in module XCOLORS_SET.Badly placed ()'s
>
> I guess probably IDL5.0 doesn't support this command that way (but only
> IDL5.2). Is this true?
The SIZE function gained a lot of new keywords in IDL 5.1 or 5.2
(can't really remember) that give you easier access to the
information in the SIZE function. Most of us had already
written our own IDL functions to access this information,
but it was a nice surprise to see RSI add these keyword
features. It makes code more portable...or, at least it
will once everyone upgrades to IDL 5.2. :-)
You can either download an earlier version of XColors from
the "old program" archive on my web page, or replace the
offending line of code with something like this:
s = Size(info.notifyobj)
nelements = s[s[0]+2]
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|