Create FITS image




createImg(fptr,bitpix,naxes) creates a new primary image or image extension with a specified datatype bitpix and size naxes. If the FITS file is currently empty then a primary array is created, otherwise a new image extension is appended to the file.

The first two elements of naxes correspond to the NAXIS2 and NAXIS1 keywords, while any additional elements correspond to the NAXIS3, NAXIS4 ... NAXISn keywords.

The datatype bitpix may be given as either a CFITSIO name or as the corresponding MATLAB® datatype.


This function corresponds to the fits_create_imgll (ffcrimll) function in the CFITSIO library C API.


Create two images in a new FITS file. There are 100 rows (NAXIS2 keyword) and 200 columns (NAXIS1 keyword) in the first image, and 256 rows (NAXIS2 keyword), 512 columns (NAXIS1 keyword), and 3 planes (NAXIS3 keyword) in the second image.

fptr = fits.createFile('myfile.fits');
fits.createImg(fptr,'int16',[100 200]);
fits.createImg(fptr,'byte_img',[256 512 3]);
Was this topic helpful?