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

Home » Public Forums » archive » TVRD, Decomposed = ? and 24bit display
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
TVRD, Decomposed = ? and 24bit display [message #30259] Fri, 12 April 2002 02:15 Go to next message
maarten is currently offline  maarten
Messages: 30
Registered: April 2002
Member
Hi all,

I'm new to this newsgroup, but been working with IDL for a while.
My problems relates to getting nice output (in form of png files) from
my IDL sessions.

I'm using IDL 5.5 on Macintosh, with a TrueColor 32 bits, visual class
and depth.

I'm plotting a gray-scale image (ImageData) together with some colored
contour plots (ColorData) in a graphics window, and I whish to put the
result in a png file.

To get good-looking result in my window I must use DEVICE, Decomposed = 1
But then my TVRD results looks completely messed up!

When I use DEVICE, Decomposed = 0, the colortables doesn't work, and all I get
is red colors, but the TVRD output looks exactly as in the window.

It must be possible to handle the color tables correctly AND get nice output
from TVRD - but my question is: how?

Maybe I don't even need to use TVRD to store the output?

Grateful for any help!
M�rten

An example code looks something like
;--------------------CODE----------------------------
Device, Decomposed = 1 ;Tried with Decomposed = 0, but then I
;can't reproduce any sensible data from TVRD

; Create a "split" colortable
ncolors = 2.^8
LoadCT,0, NCOLORS=ncolors/2,BOTTOM=0 ;BW colorscale
LoadCT,5, NCOLORS=ncolors/2,BOTTOM=ncolors/2 ;Colorscale

ColorData = ...... ;Array of data
ImageData = ...... ;Array contaning BW image

; Scale data so that it fits into the two different parts of the colortable
ColorData = BYTSCL(ColorData,TOP=ncolors/2.-1)+BYTE(ncolors/2.)
ImageData = BYTSCL(ImageData,TOP=ncolors/2.-1)

; Display the data
CONTOUR, ColorData,/CELL_FILL, C_COLORS=INDGEN(25)*5+ncolors/2.,$
.... ;+Alot of positioning commands'
TV, ImageData, .... ;+ Alot of positioning commands

; Save window to file
screendump = TVRD(True=1)
WRITE_PNG,'filame.png',screendump
;------------------END CODE--------------------------------
Re: TVRD [message #35251 is a reply to message #30259] Thu, 22 May 2003 13:55 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
JD Smith wrote:

> I'm finding TVRD doesn't return the expected result on my TRUECOLOR,
> 16-bit X-Windows device (with decomposed=0, retain=2):
>
> IDL> window,1
> IDL> loadct,0
> IDL> tv,bindgen(16,16)
> IDL> print,tvrd(0,0,16,16)
> 0 0 0 0 4 4 4 4 8 8 8 8 12 12 12 12
> 16 16 16 16 20 20 20 20 24 24 24 24 28 28 28 28
> 32 32 32 32 36 36 36 36 40 40 40 40 44 44 44 44
> 48 48 48 48 52 52 52 52 56 56 56 56 60 60 60 60
> 64 64 64 64 68 68 68 68 72 72 72 72 76 76 76 76
> 80 80 80 80 84 84 84 84 88 88 88 88 92 92 92 92
> 96 96 96 96 100 100 100 100 104 104 104 104 108 108 108 108
> 112 112 112 112 116 116 116 116 120 120 120 120 124 124 124 124
> 128 128 128 128 132 132 132 132 136 136 136 136 140 140 140 140
> 144 144 144 144 148 148 148 148 152 152 152 152 156 156 156 156
> 160 160 160 160 164 164 164 164 168 168 168 168 172 172 172 172
> 176 176 176 176 180 180 180 180 184 184 184 184 188 188 188 188
> 192 192 192 192 196 196 196 196 200 200 200 200 204 204 204 204
> 208 208 208 208 212 212 212 212 216 216 216 216 220 220 220 220
> 224 224 224 224 228 228 228 228 232 232 232 232 236 236 236 236
> 240 240 240 240 244 244 244 244 248 248 248 248 252 252 252 252
>
> IDL> print,!D.TABLE_SIZE
> 256
> IDL> tvlct,r,g,b,/GET
> IDL> print,r
> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
> 18
> 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
> 37
> 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
> 56
> 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
> 75
> 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
> 94
> 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
> 113
> 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
> 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
> 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
> 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
> 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
> 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
> 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
> 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
>
> Why does it report display values rounded down to the nears multiple
> of four? Is it really cheating to display these? The color map is
> complete and contains 256 entries, in a linear ramp 0-255 for all
> three color vectors. It doesn't matter what color map you use though,
> it always rounds down to the nearest multiple of 4. It also seems to
> be independent of RETAIN setting. What do others find TVRD returns in
> this case?
>
> Also try this test:
>
> IDL> tvlct,[255b,0b,0b,255b],[0b,255b,0b,255b],[0b,0b,255b,0b]
> IDL> tv,make_array(/BYTE,VALUE=3,100,100)
> IDL> tv,tvrd(0,0,100,100)
>
> Hmmm... not good. It gives you the value of the green color vector,
> spread over the smaller dynamic range of the 6-bit hardware range.
>
> My theory is that only either 5 or 6 bits are actually stored for each
> color with 16-bit truecolor, so, while tvlct is using all values 0-255
> for each color, in reality only 0-31 or 0-63 are valid (depending on
> color... most use 6 bits for green and 5 bits for red and blue).
> Sadly, IDL doesn't seem to understand this mapping, and can't map
> backwards from the visual through the software colormap. To be fair,
> two colors which differ only by 1/255 are the same color in a 16-bit
> map. If my theory is right, this test should succeed for 8-bit and
> 24-bit setups.
>
> Thanks,
>
> JD


You are right. I have discussed this a while ago with CREASO and RSI too.
A feature request was accepted. But we should get a higher priority if you
ask them too.

regards
Reimar




--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
Re: TVRD [message #35362 is a reply to message #35251] Thu, 05 June 2003 12:39 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Here is another example which shows the problem.


PRO my_color
DEVICE,decomposed=0
WINDOW,1,xs=300,ys=300,xpos=0,ypos=300,title='MASTER'

z=DIST(300)

r0=MAKE_ARRAY(256,/index,/BYTE)
g0=MAKE_ARRAY(256,/index,/BYTE)-128b
b0=128b-MAKE_ARRAY(256,/index,/BYTE)

TVLCT,r0,g0,b0

TV,z

TVLCT,r,g,b,/get

PRINT,'Difference between set and get'
print,'max diff.:','min diff.:'
PRINT,'red:',MAX(r0-r,MIN=m),m
PRINT,'green',MAX(g0-g,MIN=m),m
PRINT,'blue',MAX(b0-b,MIN=m),m

col_def=BYTE(STRING(r,format='(i3)')+$
STRING(g,format='(i3)')+$
STRING(b,format='(i3)'))
ix=WHERE(col_def EQ 32b)
col_def[ix]=BYTE('0')
col_def=STRING(col_def)
img=TVRD(true=1)
WINDOW,2,xs=300,ys=300,xpos=300,ypos=300,title='COPY'
TV,img,/true
col_img=BYTE(STRING(img[0,*,*],format='(I3)')+$
STRING(img[1,*,*],format='(I3)')+$
STRING(img[2,*,*],format='(I3)'))
ix=WHERE(col_img EQ 32b)
col_img[ix]=BYTE('0')
col_img=STRING(col_img)

new_img=MAKE_ARRAY(300,300,/BYTE)
n_col_img=SIZE(col_img,/N_ELEMENTS)
FOR i=0L,n_col_img-1 DO BEGIN
ix=WHERE(col_def EQ col_img[i],count_ix)
IF count_ix GT 0 THEN BEGIN
new_img[i]=ix[0]
ENDIF
ENDFOR
re=col_img[uniq(col_img,SORT(col_img))]
HELP,re
WINDOW,3,xs=300,ys=300,xpos=600,ypos=300,title='RESULT'
TV,new_img

PRINT,'my defined color tripled'
PRINT,TRANSPOSE(col_def[sort(col_def)])
PRINT,'============================'
PRINT,'true color color tripled'
PRINT,TRANSPOSE(re)
PRINT,'============================'
PRINT,'many colors aren''t defined, but still there!!'
PRINT,'result shows only colors which are defined'


END


--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: vfw for idl
Next Topic: transparent background

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

Current Time: Wed Oct 08 19:43:55 PDT 2025

Total time taken to generate the page: 0.00628 seconds