Re: How-to? color png [message #27624] |
Tue, 30 October 2001 16:08 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Mark Hadfield (m.hadfield@niwa.cri.nz) writes:
> Or to put it another way, if David didn't spend his time writing code that
> copes with *any* combination of colour depths, colour models, device
> settings and IDL versions, then what would he do with his time?
Oh, I don't know. He could spend a week trying to
reverse a *&%# axis. :-(
> So I'll use David's method. David hasn't shaved with Ockam's Razor for
> years!
I gave up Ockam's Razor the day I saw object graphics,
and I have never looked (or been) the same since.
Cheers.
David
P.S. The lovely wife points out that I could always
get a job. But I keep pointing out that the fallow
times are when I do my best thinking (and programming).
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: How-to? color png [message #27625 is a reply to message #27624] |
Tue, 30 October 2001 15:24  |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
From: "Andrew Cool" <andrew.cool@dsto.defence.gov.au>
> "Bernard K." wrote:
>>
>> I tried all the combinations proposed and they all work nicely. For the
>> surface I plot (and on my super-dupper mac :-) with the number of
>> colors used set to 256) the output I prefer is obtained by:
>>
>> tvlct, r, g, b, /get
>> and
>> write_png, 'image.png', datar,r,g,b
>> However I have to set decomposed to 1.
>
> Ockam's Razor wins again.
Ockam's Razor may help in understanding the universe but I don't think it
helps with IDL, which is *much* more complicated.
Or to put it another way, if David didn't spend his time writing code that
copes with *any* combination of colour depths, colour models, device
settings and IDL versions, then what would he do with his time?
Actually, there is a limitation with the above method. When the colour depth
is 24-bit, it is possible to issue successive graphics command to the same
window with different colour tables. In fact it might even be useful, eg:
loadct, 2 ; Load a nice colourful colour table
tv, ... ; Draw an image
loadct, 0 ; Load a boring grey-scale colour table
xyouts, ... ; Annotate the plot
This is arguably easier than using a single colour table & reserving some
indices for the annotation colours.
But if you then read the image with the above method, the tvlct command will
retrieve the current (grey-scale) colour table and the PNG file will look
rather boring.
So I'll use David's method. David hasn't shaved with Ockam's Razor for
years!
---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research
--
Posted from clam.niwa.cri.nz [202.36.29.1]
via Mailgate.ORG Server - http://www.Mailgate.ORG
|
|
|
Re: How-to? color png [message #27629 is a reply to message #27625] |
Tue, 30 October 2001 14:31  |
Andrew Cool
Messages: 219 Registered: January 1996
|
Senior Member |
|
|
"Bernard K." wrote:
>
> I tried all the combinations proposed and they all work nicely. For the
> surface I plot (and on my super-dupper mac :-) with the number of
> colors used set to 256) the output I prefer is obtained by:
>
> tvlct, r, g, b, /get
> and
> write_png, 'image.png', datar,r,g,b
> However I have to set decomposed to 1.
>
> Thanks to all,
>
> Bernard.
>
Bernard,
I love you... ;-)
Ockam's Razor wins again.
Andrew
http://www.abc.net.au/rn/science/ockham/stories/s118778.htm
------------------------------------------------------------ ---------
Andrew D. Cool .->-.
Electromagnetics & Propagation Group `-<-'
Surveillance Systems Division Transmitted on
Defence Science & Technology Organisation 100% recycled
PO Box 1500, Salisbury electrons
South Australia 5108
Phone : 061 8 8259 5740 Fax : 061 8 8259 6673
Email : andrew.cool@dsto.defence.gov.au
------------------------------------------------------------ ---------
|
|
|
Re: How-to? color png [message #27644 is a reply to message #27629] |
Tue, 30 October 2001 01:16  |
Bernard K.
Messages: 11 Registered: October 2001
|
Junior Member |
|
|
I tried all the combinations proposed and they all work nicely. For the
surface I plot (and on my super-dupper mac :-) with the number of
colors used set to 256) the output I prefer is obtained by:
tvlct, r, g, b, /get
and
write_png, 'image.png', datar,r,g,b
However I have to set decomposed to 1.
Thanks to all,
Bernard.
In article <3BDDDDC0.2B76870F@dsto.defence.gov.au>, Andrew Cool
<andrew.cool@dsto.defence.gov.au> wrote:
> David Fanning wrote:
>>
>> Andrew Cool (andrew.cool@dsto.defence.gov.au) writes:
>>
>>> You probably need to insert :-
>>>
>>> 6a) TVLCT,r,g,b,/GET ; get the current colour tables
>>>
>>> and then change 7 to be :-
>>>
>>> 7) write_png, 'image.png', data, r,g,b ; write out colour tables
>>> too!
>>
>> On a super-duper Mac!? I doubt it.
>
>
> OK, I'll shut up then, and stick to VMS.
>
> Of course, the world *should* have the adopted the British BBC
> Microcomputer
> rather than IBM or Apple. Then we'd truly have some StrongARM muscle
> with
> a decent OS.
>
> But I'll shut up.
>
> ADC
|
|
|
Re: How-to? color png [message #27655 is a reply to message #27644] |
Mon, 29 October 2001 14:52  |
Andrew Cool
Messages: 219 Registered: January 1996
|
Senior Member |
|
|
David Fanning wrote:
>
> Andrew Cool (andrew.cool@dsto.defence.gov.au) writes:
>
>> You probably need to insert :-
>>
>> 6a) TVLCT,r,g,b,/GET ; get the current colour tables
>>
>> and then change 7 to be :-
>>
>> 7) write_png, 'image.png', data, r,g,b ; write out colour tables too!
>
> On a super-duper Mac!? I doubt it.
OK, I'll shut up then, and stick to VMS.
Of course, the world *should* have the adopted the British BBC
Microcomputer
rather than IBM or Apple. Then we'd truly have some StrongARM muscle
with
a decent OS.
But I'll shut up.
ADC
|
|
|
Re: How-to? color png [message #27658 is a reply to message #27655] |
Mon, 29 October 2001 14:24  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning (david@dfanning.com) writes:
> 6) data=tvrd() ; Whoops! Not on 24-bit display.
> 6a) data = Tvrd(True=1)
> 6b) image2D = Color_Quan(data, 1, r, g, b, Colors=colors, Dither=dither)
> 7) write_png, 'image.png', image2D, r, g, b
Whoops! I just stole this out of TVRead. Line 6b should
read something like this:
6b) image2D = Color_Quan(data, 1, r, g, b, Colors=256, Dither=1)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: How-to? color png [message #27659 is a reply to message #27658] |
Mon, 29 October 2001 14:19  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Andrew Cool (andrew.cool@dsto.defence.gov.au) writes:
> You probably need to insert :-
>
> 6a) TVLCT,r,g,b,/GET ; get the current colour tables
>
> and then change 7 to be :-
>
> 7) write_png, 'image.png', data, r,g,b ; write out colour tables too!
On a super-duper Mac!? I doubt it.
More likely something like this (assuming he wants
a flat 2D PNG image):
6) data=tvrd() ; Whoops! Not on 24-bit display.
6a) data = Tvrd(True=1)
6b) image2D = Color_Quan(data, 1, r, g, b, Colors=colors, Dither=dither)
7) write_png, 'image.png', image2D, r, g, b
If he wants a 24-bit image, then:
6) data = TVRD(True=1)
7) write_png, 'image.png', data
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: How-to? color png [message #27661 is a reply to message #27659] |
Mon, 29 October 2001 13:45  |
Andrew Cool
Messages: 219 Registered: January 1996
|
Senior Member |
|
|
"Bernard K." wrote:
>
> Hello,
> I would like to ouput the result of a shade_surf graphic to a png file.
> Here is what I tried.
>
> 1)window, 1, xsize=600, ysize=400
> 2)data=findgen(600,400)
> 3) DEVICE, RETAIN=2, DECOMPOSED=0
> 4) xloadct to choose the color table BLUE/WHITE;
> 5) shade_surf, spec2d
> 6) data=tvrd()
> 7) write_png, 'image.png', data
>
> Although the screen output is displayed in color with the BLUE/WHITE
> table, the file 'image.png' only contains the axis but no colored
> surface.
>
> Does anybody know what I am doing wrong?
>
> Thanks for any answer,
>
> Bernard.
>
> ps: I am using IDL 5.5 on a Macintosh (OS X 10.1 in classic mode).
Hi,
You probably need to insert :-
6a) TVLCT,r,g,b,/GET ; get the current colour tables
and then change 7 to be :-
7) write_png, 'image.png', data, r,g,b ; write out colour tables too!
Andrew
------------------------------------------------------------ ---------
Andrew D. Cool .->-.
Electromagnetics & Propagation Group `-<-'
Surveillance Systems Division Transmitted on
Defence Science & Technology Organisation 100% recycled
PO Box 1500, Edinburgh electrons
South Australia 5108
Phone : 061 8 8259 5740 Fax : 061 8 8259 6673
Email : andrew.cool@dsto.defence.gov.au
------------------------------------------------------------ ---------
|
|
|
Re: How-to? color png [message #27663 is a reply to message #27661] |
Mon, 29 October 2001 13:41  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Bernard K. (bknaepen@'skip'mac.com) writes:
> I would like to ouput the result of a shade_surf graphic to a png file.
> Here is what I tried.
>
> 1)window, 1, xsize=600, ysize=400
> 2)data=findgen(600,400)
> 3) DEVICE, RETAIN=2, DECOMPOSED=0
> 4) xloadct to choose the color table BLUE/WHITE;
> 5) shade_surf, spec2d
> 6) data=tvrd()
> 7) write_png, 'image.png', data
>
> Although the screen output is displayed in color with the BLUE/WHITE
> table, the file 'image.png' only contains the axis but no colored
> surface.
>
> Does anybody know what I am doing wrong?
You are not using TVREAD. :-)
http://www.dfanning.com/programs/tvread.pro
IDL> image = TVRead(/PNG)
> ps: I am using IDL 5.5 on a Macintosh (OS X 10.1 in classic mode).
Oh, oh. All bets are off then. :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|