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
Re: Please, please, please can we have a missing data color for image() [message #88766 is a reply to message #88755] Mon, 16 June 2014 12:27 Go to previous message
Gordon Farquharson is currently offline  Gordon Farquharson
Messages: 48
Registered: December 2010
Member
Hi Chris

Thanks very much for the test code. I've included a diff below just to make sure that I inserted it correctly.

The new code definitely works. The missing data is displayed in the background color on the screen. As you said, it produces incorrect results if you don't use the BITMAP keyword with the save method.

--- idlitvisimage__define.pro.orig 2014-06-16 12:04:40.000000000 -0700
+++ idlitvisimage__define.pro 2014-06-16 12:08:29.000000000 -0700
@@ -1965,6 +1965,18 @@
self->EnsurePalette, red, green, blue


+ ; Handle float images with missing data.
+ if (~self._isByteData && nPlanes eq 1) then begin
+ good = FINITE(*pImgData)
+ if (~ARRAY_EQUAL(good, 1b)) then begin
+ nPlanes = 2
+ d = TEMPORARY(data)
+ data = BYTARR(imgDims[0], imgDims[1], 2)
+ data[0,0,0] = TEMPORARY(d)
+ data[0,0,1] = 255b*good
+ endif
+ endif
+
; Map projections. This may modify both the data and nPlanes.
self->_UpdateMapProjection, data, nPlanes, red, green, blue
imgDims = (SIZE(data, /DIMENSIONS))[0:1]

Gordon


On Friday, June 13, 2014 2:48:14 PM UTC-7, Chris Torrence wrote:
> On Thursday, June 12, 2014 2:38:39 AM UTC-6, Fabien wrote:
>
>> Thanks Gordon! I completely agree
>
>
>
> Okay, here's some code to try. I didn't add the MISSING_VALUE/COLOR keywords yet. Instead, I'm just keying off of NaN values.
>
>
>
> Open up lib/components/idlitvisimage__define.pro, and navigate to around line 1965. Modify the following block of code (I've included bits of code before & after for reference).
>
>
>
> pImageData = self->ByteScaleData(pImgData, data, nPlanes)
>
> ; Single-channel images must have a palette.
>
> ; This will also retrieve the red, green, blue values.
>
> if (nPlanes eq 1) then $
>
> self->EnsurePalette, red, green, blue
>
>
>
> **** NEW CODE
>
> ; Handle float images with missing data.
>
> if (~self._isByteData && nPlanes eq 1) then begin
>
> good = FINITE(*pImgData)
>
> if (~ARRAY_EQUAL(good, 1b)) then begin
>
> nPlanes = 2
>
> d = TEMPORARY(data)
>
> data = BYTARR(imgDims[0], imgDims[1], 2)
>
> data[0,0,0] = TEMPORARY(d)
>
> data[0,0,1] = 255b*good
>
> endif
>
> endif
>
> **** END NEW CODE
>
>
>
> ; Map projections. This may modify both the data and nPlanes.
>
> self->_UpdateMapProjection, data, nPlanes, red, green, blue
>
> imgDims = (SIZE(data, /DIMENSIONS))[0:1]
>
>
>
> Then, try your test case, but be sure to use /BITMAP when writing to the PDF file (to avoid alpha channel issues):
>
>
>
> data = findgen(100, 100) - 5000.
>
> data[30:60,30:60] = !values.f_nan
>
> im1 = image(data, RGB_TABLE=70, POSITION=[0.1, 0.1, 0.9, 0.9])
>
> cb1 = colorbar(TARGET=im1)
>
> im1.save,'test.pdf',/bitmap
>
>
>
> Let me know if this works. If it does, I'll think about adding the MISSING_* keywords.
>
>
>
> Cheers,
>
> Chris
>
> ExelisVIS
[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: Thu Oct 09 20:28:55 PDT 2025

Total time taken to generate the page: 0.47990 seconds