fitswrite

Write image to FITS file

Syntax

fitswrite(imagedata,filename)
fitswrite(imagedata,filename,Name,Value)

Description

fitswrite(imagedata,filename) writes imagedata to the FITS file specified by filename. If filename does not exist, fitswrite creates the file as a simple FITS file. If filename exists, fitswrite overwrites the file or appends the image to the end of the file, depending on the value of the writemode argument.

fitswrite(imagedata,filename,Name,Value) writes imagedata to the FITS file specified by filename with additional options specified by one or more Name,Value pair arguments.

Input Arguments

imagedata

Image array.

filename

Character vector or string scalar specifying the name of an existing FITS file or the name you want to assign to a new FITS file.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'WriteMode'

Specified as one of the following:

  • 'overwrite'

  • 'append'

Default: 'overwrite'

'Compression'

Specified as one of the following:

  • 'none'

  • 'gzip'

  • 'rice'

  • 'hcompress'

  • 'plio'

Default: 'none'

Examples

Create a FITS file containing the red channel of an RGB image.

X = imread('ngc6543a.jpg');
R = X(:,:,1); 
fitswrite(R,'myfile.fits');
fitsdisp('myfile.fits');

Create a FITS file with three images constructed from the channels of an RGB image.

X = imread('ngc6543a.jpg');
R = X(:,:,1);  G = X(:,:,2);  B = X(:,:,3);
fitswrite(R,'myfile.fits');
fitswrite(G,'myfile.fits','writemode','append');
fitswrite(B,'myfile.fits','writemode','append');
fitsdisp('myfile.fits');

References

For copyright information, see the cfitsiocopyright.txt file.

See Also

|

Introduced in R2012a