readImage
function readImage( hdu, reader,opts?): Promise<FitsImage>;Defined in: image/image.ts:327
Read and decode the image in an IMAGE extension or the primary HDU,
optionally just a rectangular cutout.
Pixels are fetched through reader, so a multi-gigabyte file is never
materialized just to open it, and a region reads only the bytes that
region spans (one contiguous run per fastest-axis line; a backing
HttpRangeReader coalesces adjacent runs). Bytes are decoded from FITS
big-endian into the typed array for BITPIX; BZERO/BSCALE are
applied by default. See FitsImage for scaling and layout.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
hdu |
Hdu |
reader |
RandomAccessReader |
opts |
ReadImageOptions |
Returns
Section titled “Returns”Promise<FitsImage>
Throws
Section titled “Throws”FitsStructureError if the HDU is not an image, the
structural keywords or region are invalid, or the data unit is
truncated (fewer bytes available than the header declares).
Throws
Section titled “Throws”FitsUnsupportedError if the HDU is a tile-compressed
image (ZIMAGE = T), which this library does not decode yet.
Example
Section titled “Example”const { hdus } = readHdus(await reader.read(0, 2880 * 4));const full = await readImage(hdus[0], reader);const tile = await readImage(hdus[0], reader, { region: { start: [1024, 1024], shape: [256, 256] },});