Fits convert into (bmp,tif,gif)

Alessandro Scotti ascotti at netscape.net
Tue Aug 3 12:22:01 EDT 1999


In article <37A2EE13.59B6A81C at enserg.fr>, Nicolas POINTEAU <npointea at enserg.fr> wrote:
>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.

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.



More information about the fitsbits mailing list