Subject: Fits convert into (bmp,tif,gif)

From: Nicolas POINTEAU <npointea at enserg.fr>
Date: Sat, 31 Jul 1999 13:37:40 +0100

I'm looking how the programming convert FITS images. I can open these 16
bits FITS images with the MATLAB code, and then I'd like to convert
image into 8 bits. I don't succeed. I think that we have to define High
and Low level to do this convertion, but I don't know how it works.

Thanks for your answer.

Research Student. J.FISCHER

---

From: ascotti at netscape.net (Alessandro Scotti)
Date: Tue, 03 Aug 1999 16:22:01 GMT

>and Low level to do this convertion, but I don't know how it works.

Conversion from 16 to 8 bit can be done quite simply by discarding the lower 8 
bits, that is by shifting right 8 bits. Now I'm sure you have tried this and 
I don't know MATLAB so maybe it's a problem due to the FITS specifications. In 
FITS there are two numbers called DATAMIN and DATAMAX: all samples fall within 
the range specified by these two numbers. Now if for example MINVAL=23 and 
MAXVAL=191 you can encode the FITS using 8 bits, 16 bits, 32 bits and even 
floating point values and all this numbers will be exactly the same. It this 
is the case then by shifting right you are destroying the information which is 
only placed in the lower bits! So I would try to scale the values (keeping 
into account BZERO and BSCALE) into the full 16 bit range or even direcly to 
the 8 bit range. Also a problem I have found with some FITS images is that 
they use only a part of the allowed range and are in need of a 
(histogram) contrast stretch. If this doesn't work let me know and I'll 
provide you some source code to read FITS into 8 bit gray and RGB.

---

From: super_banane at my-deja.com
Date: Fri, 06 Aug 1999 11:35:43 GMT

In article <37A2EE13.59B6A81C at enserg.fr>,
> and Low level to do this convertion, but I don't know how it works.

Hello:

If you are just looking for a utility that converts
FITS files pixel depths, you might be interested
in the following stand-alone C code:

http://www.eso.org/~ndevilla/saft

Go to the bottom of the page and have a look at
'iofits'. It does pixel depth conversion between
all possible FITS types. Beware that no scaling
is applied, though.

'iofits' is stand-alone, i.e. you do not need any
special library or compiler nor external programs
to compile and use it. Just do:

gcc -o iofits iofits.c

... and you're done.

Hope it helps,
--
Nicolas
PS: This posting address ( at my-deja.com) is phony
    to avoid spam.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.