Fitspng is an utility intended to convert of images in astronomical FITS to PNG format.
FITS format is a general purpose astronomical format storing images in high dynamical range (naturally including HDR). The primary goal of fitspng is to transform of the high dynamic range images to a limited numerical range of PNG format. The transformation uses global tone mapping technique by a set of tone functions. Their scaling parameters can by estimated by a machine or provided by user.
Fitspng uses global tone mapping technique to convert of a wide dynamical range (which can be practically infinite) to limited range of modern displaying devices. The usage of the tone mapping is crucial to get a visually satisfactory picture results.
The tone mapping is generally described by following transformation:
PNG value = f0 * Func[ (FITS value - black) * sensitivity ] + zero
where Func is a selected function (linear, asinh, ..) and f0, zero are profile scaling parameters (f0 is defaulted to 1 and zero to 0). FITS values are pre-scaled by parameters black and sensitivity to an appropriate domain of Func. The black sets a level of FITS values corresponding to the black on output. The sensitivity parameter sets an artificial (fake) sensitivity of detector. The sensitivity dims or highlights of the image like a gain tuning of an electric amplifier in detector. The sensitivity is a reciprocal to ISO value used by photographers.
Both parameters black and sensitivity can be leave unspecified. In this case, ones are estimated by the included machine algorithm with help of statistical parameters: median and mean of absolute deviations (mad). Both parameters are describing of a histogram of data: median marks centre of histogram and mad scales width of histogram.
There are available two modes:
black = median - u*mad
sensitivity = 1/(v*mad)
Both median and mad parameters are determined using of a ten node pixel grid over the image. Mad is mean of positive deviations from median. The default is u = 0.5, v = 15.
If any pixel is out of range 0 to 255 as result of mapping, the value is replaced by 0 or 255 respectively.
If colour FITS (as defined by Munipack) is converted, one can manipulate with colours by specifying of saturation in *L*u*v colour-space.
Moreover, the human eye has different colour sensitivity in high and low light conditions. The effect can be simulated by greying of dim parts of images application of PurkynÄ› effect.
Fitspng transforms images to sRGB or AdobeRGB colour-space. The transformation is started from FITS provided CIE 1931 XYZ colour-space to CIE *L*u*v. The luminosity channel is scaled according of parameters and tone functions and finally transformed to sRGB or AdobeRGB (pdf). Note that both RGB conversions uses gamma function to scale output intensities of RGBs.
In the case of grey scale image, values are equivalent to *L component whilst *u,*v are identically zero. Therefore just a tone mapping and the gamma correction is applied to output images.
An output image can be scaled-down by an integer factor. Every pixel of the scaled image is computed as the arithmetical mean of a square with side given by this factor. The photometric information is preserved while a noise is suppressed during the re-scaling. This sufficient fast method provides high quality images.
Any exposure parameters of images are stored in FITS header which is practically analogy of an EXIF information stored as a text strings in PNG so basic header information from FITS files is extracted during the conversion.
fitspng.png
.
Convert a FITS image to PNG:
$ fitspng grey.fits -o grey.png
Emulate humans night vision:
$ fitspng colour.fits -o colour.png -fn 100,10
Emulate the classical photography sensitivity function (density curve):
$ fitspng colour.fits -o colour.png -f logistic
Create a semi-grey image:
$ fitspng colour.fits -o colour.png -fs 0.2
Select just only Y band of a colour FITS (using FITS file name extension):
$ fitspng "colour.fits[*,*,2]" -o green.png
Generate thumbnails (with help of shell scripting):
$ for A in *.fits; do fitspng -s 10 $A -o ${A%fits}png; done
All this gallery examples has been generated by processing of the reference raw photo IMG_5952.CR2 :
$ rawtran -o IMG_5952.fits IMG_5952.CR2 $ fitspng IMG_5952.fits -o IMG_5952.png -s 10 $ fitspng IMG_5952.fits -o IMG_5952_a.png -s 10 -cs AdobeRGB $ fitspng IMG_5952.fits -o IMG_5952_fn.png -s 10 -fn 3000,100 $ fitspng IMG_5952.fits -o IMG_5952_ph.png -s 10 -f logistic $ fitspng IMG_5952.fits -o IMG_5952_s05.png -s 10 -fs 0.5 $ fitspng IMG_5952.fits -o IMG_5952_s15.png -s 10 -fs 1.5 $ fitspng IMG_5952.fits -o IMG_5952_fr10.png -s 10 -fr 3,10 $ fitspng IMG_5952.fits -o IMG_5952_fr50.png -s 10 -fr 3,50
Colour image in sRGB
Colour image in AdobeRGB
Highlighted
Shadowed
Reduced colours
Enhanced colours
Photography tone
Night vision
The tar-ball or the development repository with a source code is freely available under GPL-3 licence. Both cfitsio and libpng libraries with files required for development (headers, static libraries) is necessary for building.
A recommended way of installation under Unix-like system is:
$ tar zxf fitspng-X.Y.Z.tar.gz $ cd fitspng-X.Y.Z/ $ autoreconf -i # for Mercurial $ ./configure CFLAGS="-O4 -DNEBUG" $ make # make install
The last step must be executed under root account.
Both binary and
man page are installed under /usr/local
tree. It would be
nice to keep the directory for case of later uninstalling.
Munipack is a general utility to work with FITS images.
Development notes can be found in Hroch's diary.
Fitspng is free software licensed under the GNU General Public License. This gives you the freedom to use and modify Fitspng to suit your needs.
Copyright © 2006 - 2017, F. Hroch, Institute of Theoretical Physics and Astrophysics, Masaryk University, Brno, Czech Republic.