[fitsbits] crop FITS images

William Pence pence at tetra.gsfc.nasa.gov
Thu Oct 17 10:55:52 EDT 2002


CFITSIO's  virtual file filtering syntax supports extracting a subimage out
of a larger image.  See the "Image Section"  chapter of the CFITSIO
Reference Guide at:

http://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/c_user/node89.html.

Any program that uses CFITSIO to open an image shares this capability, but
in particular the 'fitscopy' program that is distributed with the CFITSIO
library may be used to copy sections of image as shown below:

>>  fitscopy 'infile.fits[101:200,201:300]' out.fits

or

>>  fitscopy 'infile.fits[101:200,201:300]' out.fits.gz

These examples extract a 100 by 100 pixel subimage out of the input image,
starting at pixel location (101,201).  The coordinate system keywords are
also updated in the output image.  In the second example, the output image
is also compressed with the gzip algorithm to reduce disk space.

The fitscopy program can be built on unix platforms by copying the cfitsio
distribution tar file available from

http://heasarc.gsfc.nasa.gov/docs/software/fitsio/fitsio.html

and then entering the commands
>>  ./configure
>>  make            # (this builds the CFITSIO library)
>>  make fitscopy   # compiles and links fitscopy

Bill Pence

Michael Olberg wrote:
> 
> Hi,
> 
> A student in our department looks for a tool that would allow her to
> cut down FITS images to a smaller size and then store the cropped
> picture again as a FITS file with updated coordinate information in
> the header. I guess AIPS, IRAF, Midas etc. would be able to do this,
> but I wondered if anybody knows of smaller, stand-alone programs for
> this kind of job. It should run under Linux.
> 
> Thanks in advance,
> Michael
> 
> ---------------------------------------------------------------------------
> Michael Olberg           | e-mail: olberg at oso.chalmers.se
> Onsala Space Observatory | tel: +46-31-7725507 (work) +46-300-10778 (home)
> S-43992 Onsala, SWEDEN   | fax: +46-31-7725590
> -------------------- This quote left blank intentionally ------------------




More information about the fitsbits mailing list