Main Content

matlab.io.fits.createImg

Create FITS image

Syntax

matlab.io.fits.createImg(fptr,bitpix,naxes)

Description

matlab.io.fits.createImg(fptr,bitpix,naxes) creates a new primary image or image extension with specified data type bitpix and size naxes. If the FITS file is currently empty, then the function creates a primary array. Otherwise, the function appends a new image extension to the file.

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

Specify the data type bitpix as a string scalar or character vector containing either a CFITSIO name or the corresponding MATLAB® data type.

CFITSIO NameMATLAB Data Type
"byte_img""uint8"
"short_img""int16"
"long_img""int32"
"longlong_img""int64"
"float_img""single"
"double_img""double"

Examples

collapse all

Create a new FITS file and add an image to it. Then close the file.

import matlab.io.*
fptr = fits.createFile("myfile.fits");
fits.createImg(fptr,"uint8",[256 512])
fits.closeFile(fptr)

Examine the file metadata and then delete the file.

fitsdisp("myfile.fits")
HDU:  1 (Primary HDU)
	SIMPLE  =                    T / file does conform to FITS standard
	BITPIX  =                    8 / number of bits per data pixel
	NAXIS   =                    2 / number of data axes
	NAXIS1  =                  512 / length of data axis 1
	NAXIS2  =                  256 / length of data axis 2
	EXTEND  =                    T / FITS dataset may contain extensions
	COMMENT   FITS (Flexible Image Transport System) format is defined in 'Astronomy
	COMMENT   and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H
delete myfile.fits

Tips

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

  • To use this function, you must be familiar with the CFITSIO C interface. You can access the CFITSIO documentation at the CFITSIO website.

Extended Capabilities

expand all

Version History

expand all