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

Home » Public Forums » archive » performing a TVRD() on 24 bit images...
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
performing a TVRD() on 24 bit images... [message #9736] Thu, 14 August 1997 00:00 Go to next message
tdarnell is currently offline  tdarnell
Messages: 3
Registered: August 1997
Junior Member
I am having some difficulty saving 24 bit TIFF files and was wondering
if anyone out there had a solution for me. I am constructing 24 bit
images of solar image data and am trying to save the resulting image
to a tiff file using TVRD(TRUE=1). I am writing each image to a PIXMAP
window and preforming the TVRD from the PIXMAP. Viewing the image in IDL
gives me exactly what I was expecting, however, once I view the image in an
external viewer, such as xv, the image appears to have lost some information
because it looks lossy. I am performing the TVRD off of the PIXMAP, not the
window showing the image, although, I tried it both ways and it doesn't seem
to matter. Here's my code:


WINDOW,0, /PIXMAP, XSIZE=xsz, YSIZE=ysz
DEVICE,SET_GRAPHICS_FUNCTION=7
loadct,1
STRETCH,50,200
TV,img2,xpos2,ypos2
loadct,3
STRETCH,20,255
TV,img1,xpos1,ypos1
final_img=TVRD(TRUE = 1)
;r=TVRD(CHANNEL=1)
;g=TVRD(CHANNEL=2)
;b=TVRD(CHANNEL=3)
DEVICE,SET_GRAPHICS_FUNCTION=3
WINDOW,1,XSIZE=(sz1(1)>sz2(1)), YSIZE=(sz1(2)>sz2(2)), /FREE
DEVICE,COPY=[0,0,xsz,ysz,0,0,0]
TIFF_WRITE,'test.tif',final_img
;TIFF_WRITE,'test.tif',RED=r,GREEN=g,BLUE=b

img1 and img2 are sent to this procedure by the calling program, they are
INTARR's of the same size. I noticed that when I do a TVRD on the PIXMAP,
final_img is of type LONARR and tiff_write casts arrays to BYTE. I'm not
sure if that is what is causing the problem or not. Any help would be much
appreciated, this problem has plagued me for some time now...


--
Tony Darnell (tdarnell@hao.ucar.edu) Boulder, CO
Re: performing a TVRD() on 24 bit images... [message #9806 is a reply to message #9736] Wed, 20 August 1997 00:00 Go to previous message
tdarnell is currently offline  tdarnell
Messages: 3
Registered: August 1997
Junior Member
In article <grunes.596.871738018@imsy1.nrl.navy.mil>,
grunes@imsy1.nrl.navy.mil (Mitchell R Grunes) writes:

>
> There are a number of potential problems with xv
> (and other display programs) that could be causing
> your problem. E.G., if the image is larger than
> the xv display window, xv would sub-sample it,
> producing interesting side effects. Other side
> effects can result from a image that is smaller
> than the xv display window, resulting from
> uneven pixel replication.

Thanks, I considered that so I viewed the image in a variety of viewers
on different platforms, all were the same.

>
> I use IDL or WAVE for display because I know that I
> can control exactly what they do, if I work at it,

Yeah, but I've noticed that sometimes we have to really work at it :-)

>
> I'm sure David Fanning's method of dealing with 8 bit
> images works, but if you really want to read 24 bit color

His method did work better than using tvrd(true=1), there was no loss
of contrast. The problem now is how do I place a smaller array in the
middle of a larger one without destroying the information underneath the
smaller array. (These are composite images of two datasets).
The nice thing about loading a colortable, tv'ing the image to a pixmap,
loading a second colortable, and tv'ing the second image to the pixmap,
was that I got exactly the effect I wanted: two images, each with its
own colortable superimposed on each other. I was able to see red solar
prominences 'underneath' a blue coronal image. This allowed us to see
how an event (say a coronal mass ejection) appeared in two datasets at
the same time. All that was left to do was get the info in the window into
a file (sigh). Unfortunately, tvrd() didn't give me what was
on the window. (No WYSIWYG here!)

I've been working with a tech support guy at RSI and he seems to think it is
in the TVRD() procedure (I'm inclined to agree). I've noticed before on an
unrelated problem that IDL does its own thing (at least on a SUN) with the
display and colors. This was certainly true when it came to GAMMA settings
on the monitor. In order for true color images to look consistent with our
SGI's and even in xv on the same system, our system admin had to change the
gamma to its 'linear' setting (apparently only root can do this). After that
change, what we saw in IDL was the same as what we saw in other imagers like
xv.

Thanks for your reply and suggestion, unfortunately, I've already tried most
of what you suggested. Just to be sure, I used REVERSE in the TIFF_WRITE
call to see if that mattered. It didn't. I wish I could help you with your
job hunt, but alas I am only a lowly IDL programmer. I know nothing about
what positions are available. Good luck in your search!

--
Tony Darnell
High Altitude Observatory
(tdarnell@hao.ucar.edu) Boulder, CO
Re: performing a TVRD() on 24 bit images... [message #9827 is a reply to message #9736] Sat, 16 August 1997 00:00 Go to previous message
grunes is currently offline  grunes
Messages: 68
Registered: September 1993
Member
tdarnell@hao.ucar.edu (Tony Darnell) writes

> I am having some difficulty saving 24 bit TIFF files and was wondering
> if anyone out there had a solution for me... I am constructing 24 bit
> images of solar image data and am trying to save the resulting image
> to a tiff file using TVRD(TRUE=1)...

> Viewing the image in IDL
> gives me exactly what I was expecting, however, once I view the image in an
> external viewer, such as xv, the image appears to have lost some information
> because it looks lossy.

Let me give a 3 part answer:

1. Possible problems with xv and other display
programs that could appear to cause your
problem.

2. How to write a 24 bit screen window to a
TIFF file.

3. By the way, anyone looking for an experienced
programmer?

===============================================

There are a number of potential problems with xv
(and other display programs) that could be causing
your problem. E.G., if the image is larger than
the xv display window, xv would sub-sample it,
producing interesting side effects. Other side
effects can result from a image that is smaller
than the xv display window, resulting from
uneven pixel replication.

Many other display programs would actually create an
8 bit window, drop those colors already in use by the
system, and dither.

I use IDL or WAVE for display because I know that I
can control exactly what they do, if I work at it,
and am willing to trade off some speed. E-mail me
if you want a junky but usable image/animation display
program, which can also extract other images and
sub-images (including TIFF), etc.

============================================================ =====

I'm sure David Fanning's method of dealing with 8 bit
images works, but if you really want to read 24 bit color
from the screen, and you want things to be more portable
on multiple systems, you might create the window (which
should be your FIRST window) with:

device,true=24
window,... ,colors=2L^24

Just as a check that you have a 24 bit window,
print,!d.n_colors,2L^24
They should be the same.

Then place your stuff in the window:
tv,...
etc.

Then read it in, and write to a TIFF file.
It is important to use top-to-bottom storage
order, so that most other TIFF viewers can read it right.

In IDL you could do this with:
A=tvrd(0,0,!d.x_vsize,!d.y_vsize,true=1)
tiff_write,'junk.tif',reverse(A,3),1

In PV-WAVE, you could use use:
A=tvrd(0,0,!d.x_vsize,!d.y_vsize,true=3)
for i=0,2 do A(*,*,i)=reverse(reform(A(*,*,i)),0)
if dc_write_tiff('junk.tif',A,class='RGB') ne 0 then $
stop,'*****Bad dc_write_tiff'

=======================================================

I have a confession. Part of my real reason for
responding is that I am looking for a job, since
funding for me is indefinite as of October 1.

If anyone out there who is reading this is looking for
an experienced IDL/PV-WAVE/Fortran/C scientific
programmer, with knowledge of image processing and
remote sensing, I am available.

(BTW, I am on leave the week of 8/18.)

I know, wrong newsgroup. Shame on me!
At least I contributed something useful.

(-:

------------------------------------------------------------ -
Mitchell R Grunes, grunes@imsy1.nrl.navy.mil. Opinions are mine alone.

------------------------------------------------------------ -
Mitchell R Grunes, grunes@imsy1.nrl.navy.mil. Opinions are mine alone.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Efficient comparison of arrays
Next Topic: Re: setenv,'x.x.x.x:0.1'

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

Current Time: Fri Oct 10 16:24:45 PDT 2025

Total time taken to generate the page: 0.64075 seconds