Re: display gray image with NaN [message #94246 is a reply to message #94242] |
Mon, 06 March 2017 02:02   |
Markus Schmassmann
Messages: 129 Registered: April 2016
|
Senior Member |
|
|
Am 04.03.2017 um 11:00 schrieb jpleahy2@gmail.com:
> On Friday, March 3, 2017 at 1:55:26 PM UTC, dashtab...@gmail.com wrote:
>> i have a gray scale image (one band with NaN value) and display it with image() and widget_window().
>> i want to show specific values (maybe gt 1000 pixels ) over image with red color.
>> like this. http://pasteboard.co/EYXxQWAAW.jpg
>
> 1) If required, define a colour scale to map your raw data values to pixel values, e.g. for a greyscale RGB should all be the same:
> offset = MIN(raw_data)
> scale = 255/(1000-offset)
> data = BYTE(REBIN(scale*(raw_data - offset),N,M,3))
>
> (doesn't have to be bytes with IMAGE(), but most display devices can only cope with 256 levels per RGB so you might as well).
>
> 2) Choose a colour well away from the main colour map to represent NaNs and saturated pixels.
> nan_colour = [0,0,1] ; blue NaN
> sat_colour = [1,0,0] ; red for values > 1000
> nanpix = WHERE(FINITE(raw_data))
>
> 3) Flatten array temporarily so the indexing from WHERE will work:
> data = REFORM(data, N*M,3)
> data[nanpix,*] = nan_colour
> satpix = WHERE(raw_data GT 1000)
> data[satpix,*] = sat_colour
> data = REFORM(data,N,M,3)
>
> 4) Display, with options as required:
> graphic = IMAGE(data)
this code fails, if raw_data[0] is a NaN. use
offset = MIN(raw_data,/nan)
for the first line to be safe.
|
|
|