Utilities to convert (FITS) images/data into commonaly used media formats

The JSOC Module: render_image(look under Modules) can be used to convert a segment image file in a series into ppm/jpg or png format. It can be used to convert a data series into a series of sequentially numbered images that can then be converted to a movie.

Typical Syntax:

render_image --help
render_image in= < RecordSet>
out =< target_directory>
outname=< ident_for_filename>
scaling =< scaletype>
pallette =< color_table>
type =< image_protocol>
outid =< filename_code>
min= scale_min
max= scale_max>
scale=< image_size_ratio>
-c --< crop_image> will cause the image to be cropped at pixel radius RSUN_OBS/CDELT1 about CRPIX1,CRPIX2 center.
-w -- < white_background> i.e.-w flag will cause missing values to be white. Else black. >
-x --this flag is used to indicate extra resolution in the color table, i.e. 16-bits per color. currently not working

Example Usage:
render_image in='hmi_test.M_45s[2010.07.08_00:00:00/30m]' out=./test/ type=jpg min=-500 max=500 outid=# outname=test
will give a set of uncropped grey scale images.
Example yeilding colored images:
render_image in='hmi_test.M_45s[2010.08.15_00:00:00/15m]' out=./test2/ type=jpg min=-500 max=500 palette =/home/priya/Colormaps/Blue_grey_Red.lut outid=# outname=M

Phil has a stand alone C script fits_to_ppm that converts fits files into ppm - but does NOT convert compressed files - So check fits headerbefore using. For a fits datacube; it only converts the first image! But we can put in and shell script and it can use ds9 colortables.

Use fits_to_ppm on ds9.fits as :
fits_to_ppm in='someingaeuncompressed.fits' MIN=-2000 MAX=2000 table=/home/phil/apps/hgtest/pmag.lut | pnmtopng >xxx.png
so these are coloured png images using a lut (look up color table) from Phil's directory:

Netpbm is toolkit for manipulation of graphic imagesincluding conversion of images between various formats.
ls /usr/bin/pnm* yeild a host of utilities.

Note ppmtompeg converts it into mpeg1 video stream not mpeg4.

ImageMagickis an open source software suite for displaying, converting, and editing raster image files.It can read and write over a 100 image formats. however theer is no utility to convert fits mages to any other format.

Ffmpeg/ffplay is a complete, cross-platform solution to record, convert and stream audio and video.

Mencoder/menplayer
Mencoder:(MPlayer's Movie Encoder) is a simple movie encoder, designed to encode MPlayer-playable movies (see above) to other MPlayer-playable formats (see below). It encodes to MPEG-4 (DivX/Xvid), one of the libavcodec codecs and PCM/MP3/VBRMP3 audio in 1, 2 or 3 passes. Fur- thermore it has stream copying abilities, a powerful filter system (crop, expand, flip, postprocess, rotate, scale, noise, RGB/YUV conver- sion) and more.
Mplayer is a movie player for Linux (runs on many other platforms) and runs most of the movie formats out there.

DS9 can also be used to convert fits files or fits data cube into jpg images or mpeg1 video. However the image resolution and quality is not great.
Note: ds9 can be controlled from the commandline. For eg:
ds9 -pan 1495 -640 physical -zoom 2 -scale limits -1000 1000 -cmap bb
Or in a shell script:
ds9 $basic_file{$f}.magnetogram.fits -zoom to fit -scale limits -1000 1000 -cmap grey -saveimage jpeg images/{$f}.jpg -exit

ds9 Vtrack.fits -scale limits -2000 2000 -cmap file Blue_grey_Red.lut -saveimage tiff Vtrack1/Vtrack1.tiff -exit
More information on how to use ds9 effectively can be found at Learning ds9

Commonly Used Image Formats:

PPM: stands for portable pixel map. It is a netpbm format -Apparently very inefficient:It is highly redundant, while containing a lot of information that the human eye can't even discern. Furthermore, the format allows very little information about the image besides basic color, which means you may have to couple a file in this format with other independent information to get any decent use out of it. However, it is very easy to write and analyze programs to process this format, and that is the point.

GIFS: Extremely common, has been around a long time. Uses limited colors with only saves 8 bit quality -use for line drawings/cartoons with limited colours.Howver it saves canvas size info to make animation sequences.

JPEG: Does not handle transparency at all. The image is equivalent to using "+matte" operation to remove the alpha channel, so any background transparency commonly becomes black depending on the image processing used to generate the image. This format is also 'lossy', producing edge effects on sharp lines and borders and thus should not be used for any intermediate image processing, or storage of image originals (unless they were already in this format). It is well suited to long term storage of real life photographs, but avoid it if you plan to further process the image, or the image contains large areas of solid colors.

PNG This format is intended to eventually replace older formats like GIF and TIFF. It is a modern format capable of handling 16 bit quality with four color channels allowing the full use of semi-transparent colors. It also includes a huge number of lossless image compression options.

MNG This is the multi-image format for PNG, and allows animations to movie quality levels and speed.

About Colormaps:

Some Common colormap formats: