comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Please, please, please can we have a missing data color for image()
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Please, please, please can we have a missing data color for image() [message #88743] Wed, 11 June 2014 16:04 Go to previous message
Gordon Farquharson is currently offline  Gordon Farquharson
Messages: 48
Registered: December 2010
Member
The function graphics routine image() has a number of nice features, including the ability to view the value of a pixel (and coordinates) under the cursor, to zoom interactively, and to assign a colorbar with matching colors in a sensible way. However, to get all of these features, one has to let image() bytscl the data, i.e., The Function Graphics (TM) Way:

data = findgen(100, 100) - 5000.
im1 = image(data, RGB_TABLE=70, POSITION=[0.1, 0.1, 0.9, 0.9])
cb1 = colorbar(TARGET=im1)

And Bliss and Happiness ensues in IDL heaven...

(Cue scratched record sound.)

... except when the data contains missing values:

data = findgen(100, 100) - 5000.
data[60:69,60:69] = !values.f_nan
im1 = image(data, RGB_TABLE=70, POSITION=[0.1, 0.1, 0.9, 0.9])
cb1 = im1.colorbar(TARGET=im1)

Notice the hideous red square where the missing data exists. Visually, this is terrible. (My eyes are still in therapy.)

The classic way of solving this problem is to bytscl the data manually, and to reserve indices in the color table for foreground and background colors, e.g.,

data = findgen(100, 100) - 5000.
data[60:69,60:69] = !values.f_nan
img = bytscl(data, MIN=-5000., MAX=5000., TOP=254B) + 1B
img[where(~finite(data), /NULL)] = 0B
ct = colortable(70)
ct[0,*] = 255B * make_array(3, /BYTE, VALUE=1B)
ct[255,*] = 0B * make_array(3, /BYTE, VALUE=1B)
im1 = image(img, RGB_TABLE=ct, POSITION=[0.1, 0.1, 0.9, 0.9])
cb1 = colorbar(TARGET=im1)

The hideous red square of missing data has been replaced by a pleasant white (background color) square, and all is well with the world ...

... except, that we've broken most of the nice functionality of image(), because the label values in the colorbar are the img byte values :-(

Oh IDL gods, I beseech thee: Please, please, please can we have a missing data color for image(). Ideally, I'd like to have a keywords like MISSING_VALUE and MISSING_COLOR. If the embarrassment of David having this functionality in his graphics routines is not enough to persuade the IDL gods to add this to image(), then the fact that image() is almost useless without it must convince you.

One last note: I have applied my IDL Kung fu [1] Master skills to tricking IDL into displaying a background color using the alpha channel, and this works great for bitmap formats that support transparency, but alas, it fails dismally when I try to create publication quality EPS graphics.

Gordon

[1] http://en.wikipedia.org/wiki/Kung_fu_%28term%29
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Fitting with three parameters ???
Next Topic: Error while creating video in IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 16:15:02 PDT 2025

Total time taken to generate the page: 0.00257 seconds