Re: Writing out TIFF files [message #5679] |
Thu, 25 January 1996 00:00 |
kak
Messages: 16 Registered: February 1995
|
Junior Member |
|
|
Sangeet Singh <singh@thor.xraylith.wisc.edu> writes:
> I would like to write out some image arrays in IDL as .tif files. So
> far I have been able to do this *only* by doing a TVSCL of the image
> followed by a TVRD into a BYTARR which is written using TIFF_WRITE.
[stuff deleted...]
> tvscl,img2,ex,why,ORDER=1
> tifimg=tvrd(ex,why,col,row)
> TIFF_WRITE,filename5,tifimg,1
Perhaps you did not realize that there is a function BYTSCL, which should
do what you want: it scales an array to the range of byte values, so that
you can store them as 8bit TIFF file. I guess it's also used internally
by tvscl. Therefore:
tifimg=bytscl(img2)
tiff_write,'filename',tifimg
> ; The following results in a tiff file containing only random noise, not
> ; the real image.
> ;tifimg=img2
> ;OR
> ;tifimg=BYTE(img2)
The attempt with tifimg=byte(img2) must fail because you only see
the lowest bitplane of your image which usually contains the
camera noise (byte takes the rightmost 8 bits of your integer numbers).
If you apply the bitshift operation on your dataset,
you can easily travel through the bitplanes of your image:
tifimg=byte(ishft(img2,-n)) gives you the n'th bitplane of your image.
Karl
|
|
|