cfitsio  3390
Macros | Functions | Variables
imcompress.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <time.h>
#include "fitsio2.h"
Include dependency graph for imcompress.c:

Macros

#define NULL_VALUE   -2147483647 /* value used to represent undefined pixels */
 
#define ZERO_VALUE   -2147483646 /* value used to represent zero-valued pixels */
 
#define NINT(x)   ((x >= 0.) ? (int) (x + 0.5) : (int) (x - 0.5))
 
#define NO_QUANTIZE   9999
 

Functions

int imcomp_write_nocompress_tile (fitsfile *outfptr, long row, int datatype, void *tiledata, long tilelen, int nullcheck, void *nullflagval, int *status)
 
int imcomp_convert_tile_tshort (fitsfile *outfptr, void *tiledata, long tilelen, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, double actual_bzero, int *intlength, int *status)
 
int imcomp_convert_tile_tushort (fitsfile *outfptr, void *tiledata, long tilelen, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, int *intlength, int *status)
 
int imcomp_convert_tile_tint (fitsfile *outfptr, void *tiledata, long tilelen, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, int *intlength, int *status)
 
int imcomp_convert_tile_tuint (fitsfile *outfptr, void *tiledata, long tilelen, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, int *intlength, int *status)
 
int imcomp_convert_tile_tbyte (fitsfile *outfptr, void *tiledata, long tilelen, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, int *intlength, int *status)
 
int imcomp_convert_tile_tsbyte (fitsfile *outfptr, void *tiledata, long tilelen, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, int *intlength, int *status)
 
int imcomp_convert_tile_tfloat (fitsfile *outfptr, long row, void *tiledata, long tilelen, long tilenx, long tileny, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, int *intlength, int *flag, double *bscale, double *bzero, int *status)
 
int imcomp_convert_tile_tdouble (fitsfile *outfptr, long row, void *tiledata, long tilelen, long tilenx, long tileny, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, int *intlength, int *flag, double *bscale, double *bzero, int *status)
 
int fits_init_randoms (void)
 
void bz_internal_error (int errcode)
 
int fits_set_compression_type (fitsfile *fptr, int ctype, int *status)
 
int fits_set_tile_dim (fitsfile *fptr, int ndim, long *dims, int *status)
 
int fits_set_quantize_level (fitsfile *fptr, float qlevel, int *status)
 
int fits_set_quantize_method (fitsfile *fptr, int method, int *status)
 
int fits_set_quantize_dither (fitsfile *fptr, int dither, int *status)
 
int fits_set_dither_seed (fitsfile *fptr, int seed, int *status)
 
int fits_set_dither_offset (fitsfile *fptr, int offset, int *status)
 
int fits_set_noise_bits (fitsfile *fptr, int noisebits, int *status)
 
int fits_set_hcomp_scale (fitsfile *fptr, float scale, int *status)
 
int fits_set_hcomp_smooth (fitsfile *fptr, int smooth, int *status)
 
int fits_set_lossy_int (fitsfile *fptr, int lossy_int, int *status)
 
int fits_set_huge_hdu (fitsfile *fptr, int huge, int *status)
 
int fits_get_compression_type (fitsfile *fptr, int *ctype, int *status)
 
int fits_get_tile_dim (fitsfile *fptr, int ndim, long *dims, int *status)
 
int fits_unset_compression_param (fitsfile *fptr, int *status)
 
int fits_unset_compression_request (fitsfile *fptr, int *status)
 
int fits_set_compression_pref (fitsfile *infptr, fitsfile *outfptr, int *status)
 
int fits_get_noise_bits (fitsfile *fptr, int *noisebits, int *status)
 
int fits_get_quantize_level (fitsfile *fptr, float *qlevel, int *status)
 
int fits_get_dither_seed (fitsfile *fptr, int *offset, int *status)
 
int fits_get_hcomp_scale (fitsfile *fptr, float *scale, int *status)
 
int fits_get_hcomp_smooth (fitsfile *fptr, int *smooth, int *status)
 
int fits_img_compress (fitsfile *infptr, fitsfile *outfptr, int *status)
 
int imcomp_init_table (fitsfile *outfptr, int inbitpix, int naxis, long *naxes, int writebitpix, int *status)
 
int imcomp_calc_max_elem (int comptype, int nx, int zbitpix, int blocksize)
 
int imcomp_compress_image (fitsfile *infptr, fitsfile *outfptr, int *status)
 
int imcomp_compress_tile (fitsfile *outfptr, long row, int datatype, void *tiledata, long tilelen, long tilenx, long tileny, int nullcheck, void *nullflagval, int *status)
 
int imcomp_nullscale (int *idata, long tilelen, int nullflagval, int nullval, double scale, double zero, int *status)
 
int imcomp_nullvalues (int *idata, long tilelen, int nullflagval, int nullval, int *status)
 
int imcomp_scalevalues (int *idata, long tilelen, double scale, double zero, int *status)
 
int imcomp_nullscalei2 (short *idata, long tilelen, short nullflagval, short nullval, double scale, double zero, int *status)
 
int imcomp_nullvaluesi2 (short *idata, long tilelen, short nullflagval, short nullval, int *status)
 
int imcomp_scalevaluesi2 (short *idata, long tilelen, double scale, double zero, int *status)
 
int imcomp_nullfloats (float *fdata, long tilelen, int *idata, int nullcheck, float nullflagval, int nullval, int *status)
 
int imcomp_nullscalefloats (float *fdata, long tilelen, int *idata, double scale, double zero, int nullcheck, float nullflagval, int nullval, int *status)
 
int imcomp_nulldoubles (double *fdata, long tilelen, int *idata, int nullcheck, double nullflagval, int nullval, int *status)
 
int imcomp_nullscaledoubles (double *fdata, long tilelen, int *idata, double scale, double zero, int nullcheck, double nullflagval, int nullval, int *status)
 
int fits_write_compressed_img (fitsfile *fptr, int datatype, long *infpixel, long *inlpixel, int nullcheck, void *array, void *nullval, int *status)
 
int fits_write_compressed_pixels (fitsfile *fptr, int datatype, LONGLONG fpixel, LONGLONG npixel, int nullcheck, void *array, void *nullval, int *status)
 
int fits_write_compressed_img_plane (fitsfile *fptr, int datatype, int bytesperpixel, long nplane, long *firstcoord, long *lastcoord, long *naxes, int nullcheck, void *array, void *nullval, long *nread, int *status)
 
int fits_img_decompress (fitsfile *infptr, fitsfile *outfptr, int *status)
 
int fits_decompress_img (fitsfile *infptr, fitsfile *outfptr, int *status)
 
int fits_img_decompress_header (fitsfile *infptr, fitsfile *outfptr, int *status)
 
int fits_read_compressed_img (fitsfile *fptr, int datatype, LONGLONG *infpixel, LONGLONG *inlpixel, long *ininc, int nullcheck, void *nullval, void *array, char *nullarray, int *anynul, int *status)
 
int fits_read_compressed_pixels (fitsfile *fptr, int datatype, LONGLONG fpixel, LONGLONG npixel, int nullcheck, void *nullval, void *array, char *nullarray, int *anynul, int *status)
 
int fits_read_compressed_img_plane (fitsfile *fptr, int datatype, int bytesperpixel, long nplane, LONGLONG *firstcoord, LONGLONG *lastcoord, long *inc, long *naxes, int nullcheck, void *nullval, void *array, char *nullarray, int *anynul, long *nread, int *status)
 
int imcomp_get_compressed_image_par (fitsfile *infptr, int *status)
 
int imcomp_copy_imheader (fitsfile *infptr, fitsfile *outfptr, int *status)
 
int imcomp_copy_img2comp (fitsfile *infptr, fitsfile *outfptr, int *status)
 
int imcomp_copy_comp2img (fitsfile *infptr, fitsfile *outfptr, int norec, int *status)
 
int imcomp_copy_prime2img (fitsfile *infptr, fitsfile *outfptr, int *status)
 
int imcomp_decompress_tile (fitsfile *infptr, int nrow, int tilelen, int datatype, int nullcheck, void *nulval, void *buffer, char *bnullarray, int *anynul, int *status)
 
int imcomp_test_overlap (int ndim, long *tfpixel, long *tlpixel, long *fpixel, long *lpixel, long *ininc, int *status)
 
int imcomp_copy_overlap (char *tile, int pixlen, int ndim, long *tfpixel, long *tlpixel, char *bnullarray, char *image, long *fpixel, long *lpixel, long *ininc, int nullcheck, char *nullarray, int *status)
 
int imcomp_merge_overlap (char *tile, int pixlen, int ndim, long *tfpixel, long *tlpixel, char *bnullarray, char *image, long *fpixel, long *lpixel, int nullcheck, int *status)
 
int fits_compress_table (fitsfile *infptr, fitsfile *outfptr, int *status)
 
int fits_uncompress_table (fitsfile *infptr, fitsfile *outfptr, int *status)
 

Variables

char results [999][30]
 
float * fits_rand_value = 0
 

Macro Definition Documentation

#define NINT (   x)    ((x >= 0.) ? (int) (x + 0.5) : (int) (x - 0.5))
#define NO_QUANTIZE   9999

special quantize level value indicates that floating point image pixels should not be quantized and instead losslessly compressed (with GZIP)

#define NULL_VALUE   -2147483647 /* value used to represent undefined pixels */
#define ZERO_VALUE   -2147483646 /* value used to represent zero-valued pixels */

Function Documentation

void bz_internal_error ( int  errcode)

external function declared by the bzip2 code in bzlib_private.h

Here is the call graph for this function:

int fits_compress_table ( fitsfile infptr,
fitsfile outfptr,
int *  status 
)

Compress the input FITS Binary Table.

First divide the table into equal sized chunks (analogous to image tiles) where all the contain the same number of rows (except perhaps for the last chunk which may contain fewer rows). The chunks should not be too large to copy into memory (currently, about 100 MB max seems a reasonable size).

Then, on a chunk by piece basis, do the following:

  1. Transpose the table from its original row-major order, into column-major order. All the bytes for each column are then continuous. In addition, the bytes within each table element may be shuffled so that the most significant byte of every element occurs first in the array, followed by the next most significant byte, and so on to the least significant byte. Byte shuffling often improves the gzip compression of floating-point arrays.
  2. Compress the contiguous array of bytes in each column using the specified compression method. If no method is specifed, then a default method for that data type is chosen.
  3. Store the compressed stream of bytes into a column that has the same name as in the input table, but which has a variable-length array data type (1QB). The output table will contain one row for each piece of the original table.
  4. If the input table contain variable-length arrays, then each VLA is compressed individually, and written to the heap in the output table. Note that the output table will contain 2 sets of pointers for each VLA column. The first set contains the pointers to the uncompressed VLAs from the input table and the second is the set of pointers to the compressed VLAs in the output table. The latter set of pointers is used to reconstruct table when it is uncompressed, so that the heap has exactly the same structure as in the original file. The 2 sets of pointers are concatinated together, compressed with gzip, and written to the output table. When reading the compressed table, the only VLA that is directly visible is this compressed array of descriptors. One has to uncompress this array to be able to to read all the descriptors to the individual VLAs in the column.

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_decompress_img ( fitsfile infptr,
fitsfile outfptr,
int *  status 
)

THIS IS AN OBSOLETE ROUTINE. USE fits_img_decompress instead!!!

This routine decompresses the whole image and writes it to the output file.

Parameters
[in]infptrimage (bintable) to uncompress
[in]outfptrempty HDU for output uncompressed image
[in,out]statuserror status

Here is the call graph for this function:

int fits_get_compression_type ( fitsfile fptr,
int *  ctype,
int *  status 
)

This routine returns the image compression algorithm that should be used when writing a FITS image. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.

Parameters
[in]fptrFITS file pointer
[in]ctypeimage compression type code; allowed values: RICE_1, GZIP_1, GZIP_2, PLIO_1, HCOMPRESS_1, BZIP2_1
[in,out]statuserror status

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_get_dither_seed ( fitsfile fptr,
int *  offset,
int *  status 
)

This routine returns the value of the dithering offset parameter that is used when compressing floating point images. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.

Parameters
[in]fptrFITS file pointer
[in]offsetdithering offset parameter value
[in,out]statuserror status
int fits_get_hcomp_scale ( fitsfile fptr,
float *  scale,
int *  status 
)
int fits_get_hcomp_smooth ( fitsfile fptr,
int *  smooth,
int *  status 
)
Parameters
[in]fptrFITS file pointer
[in]smoothHcompress smooth parameter value
[in,out]statuserror status
int fits_get_noise_bits ( fitsfile fptr,
int *  noisebits,
int *  status 
)
Deprecated:
THIS ROUTINE IS PROVIDED ONLY FOR BACKWARDS COMPATIBILITY; ALL NEW SOFTWARE SHOULD CALL fits_set_quantize_level INSTEAD

This routine returns the value of the noice_bits parameter that should be used when compressing floating point images. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.

Since
Feb 2008: code changed to use the more general "quantize level" parameter rather than the "noise bits" parameter. If quantize level is greater than zero, then the previous noisebits parameter is approximately given by

This result is rounded to the nearest integer.

Parameters
[in]fptrFITS file pointer
[in]noisebitsnoise_bits parameter value (default = 4). noise bits = natural logarithm (quantize level) / natural log (2).
[in,out]statuserror status
int fits_get_quantize_level ( fitsfile fptr,
float *  qlevel,
int *  status 
)

This routine returns the value of the noice_bits parameter that should be used when compressing floating point images. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.

Parameters
[in]fptrFITS file pointer
[in]qlevelquantize level parameter value
[in,out]statuserror status
int fits_get_tile_dim ( fitsfile fptr,
int  ndim,
long *  dims,
int *  status 
)

This routine returns the size (dimension) of the image compression tiles that should be used when writing a FITS image. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.

Parameters
[in]fptrFITS file pointer
[in]ndimnumber of dimensions in the compressed image
[in]dimssize of image compression tile in each dimension default tile size = (NAXIS1, 1, 1, ...)
[in,out]statuserror status

Here is the call graph for this function:

int fits_img_compress ( fitsfile infptr,
fitsfile outfptr,
int *  status 
)

This routine initializes the output table, copies all the keywords, and loops through the input image, compressing the data and writing the compressed tiles to the output table.

This is a high level routine that is called by the fpack and funpack FITS compression utilities.

Parameters
[in]infptrpointer to image to be compressed
[in]outfptrempty HDU for output compressed image
[in,out]statuserror status

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_img_decompress ( fitsfile infptr,
fitsfile outfptr,
int *  status 
)

This routine decompresses the whole image and writes it to the output file.

Parameters
[in]infptrimage (bintable) to uncompress
[in]outfptrempty HDU for output uncompressed image
[in,out]statuserror status

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_img_decompress_header ( fitsfile infptr,
fitsfile outfptr,
int *  status 
)

This routine reads the header of the input tile compressed image and converts it to that of a standard uncompress FITS image.

Parameters
[in]infptrimage (bintable) to uncompress
[in]outfptrempty HDU for output uncompressed image
[in,out]statuserror status

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_init_randoms ( void  )

initialize an array of random numbers

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_read_compressed_img ( fitsfile fptr,
int  datatype,
LONGLONG infpixel,
LONGLONG inlpixel,
long *  ininc,
int  nullcheck,
void *  nullval,
void *  array,
char *  nullarray,
int *  anynul,
int *  status 
)

Read a section of a compressed image; Note: lpixel may be larger than the size of the uncompressed image. Only the pixels within the image will be returned.

Parameters
[in]fptrFITS file pointer
[in]datatypedatatype of the array to be returned
[in]infpixel'bottom left corner' of the subsection
[in]inlpixel'top right corner' of the subsection
[in]inincincrement to be applied in each dimension
[in]nullcheck0 for no null checking 1: set undefined pixels = nullval 2: set nullarray=1 for undefined pixels
[in]nullvalvalue for undefined pixels
[out]arrayarray of values that are returned
[out]nullarrayarray of flags = 1 if nullcheck = 2
[out]anynulset to 1 if any values are null; else 0
[in,out]statuserror status

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_read_compressed_img_plane ( fitsfile fptr,
int  datatype,
int  bytesperpixel,
long  nplane,
LONGLONG firstcoord,
LONGLONG lastcoord,
long *  inc,
long *  naxes,
int  nullcheck,
void *  nullval,
void *  array,
char *  nullarray,
int *  anynul,
long *  nread,
int *  status 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_read_compressed_pixels ( fitsfile fptr,
int  datatype,
LONGLONG  fpixel,
LONGLONG  npixel,
int  nullcheck,
void *  nullval,
void *  array,
char *  nullarray,
int *  anynul,
int *  status 
)

Read a consecutive set of pixels from a compressed image. This routine interpretes the n-dimensional image as a long one-dimensional array. This is actually a rather inconvenient way to read compressed images in general, and could be rather inefficient if the requested pixels to be read are located in many different image compression tiles.

The general strategy used here is to read the requested pixels in blocks that correspond to rectangular image sections.

Parameters
[in]fptrFITS file pointer

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_set_compression_pref ( fitsfile infptr,
fitsfile outfptr,
int *  status 
)

Set the preference for various compression options, based on keywords in the input file that provide guidance about how the HDU should be compressed when written to the output file.

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_set_compression_type ( fitsfile fptr,
int  ctype,
int *  status 
)

This routine specifies the image compression algorithm that should be used when writing a FITS image. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.

Parameters
[in]fptrFITS file pointer
[in]ctypemage compression type code; allowed values: RICE_1, GZIP_1, GZIP_2, PLIO_1, HCOMPRESS_1, BZIP2_1, and NOCOMPRESS
[in,out]status)error status

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_set_dither_offset ( fitsfile fptr,
int  offset,
int *  status 
)

The name of this routine has changed. This is kept just for backwards compatibility with any software that calls the old name

Parameters
[in]fptrFITS file pointer
[in]offsetrandom dithering offset value (1 to 10000)
[in,out]statuserror status

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_set_dither_seed ( fitsfile fptr,
int  seed,
int *  status 
)

This routine specifies the value of the offset that should be applied when calculating the random dithering when quantizing floating point iamges. A random offset should be applied to each image to avoid quantization effects when taking the difference of 2 images, or co-adding a set of images. Without this random offset, the corresponding pixel in every image will have exactly the same dithering.

offset = 0 means use the default random dithering based on system time offset = negative means randomly chose dithering based on 1st tile checksum offset = [1 - 10000] means use that particular dithering pattern

Parameters
[in]fptrFITS file pointer
[in]seedrandom dithering seed value (1 to 10000)
[in,out]statuserror status

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_set_hcomp_scale ( fitsfile fptr,
float  scale,
int *  status 
)

This routine specifies the value of the hcompress scale parameter.

Parameters
[in]fptrFITS file pointer
[in]scalehcompress scale parameter value (default = 0.)
[in,out]statuserror status

Here is the caller graph for this function:

int fits_set_hcomp_smooth ( fitsfile fptr,
int  smooth,
int *  status 
)

This routine specifies the value of the hcompress scale parameter.

Parameters
[in]fptrFITS file pointer
[in]smoothhcompress smooth parameter value if scale > 1 and smooth != 0, then the image will be smoothed when it is decompressed to remove some of the 'blockiness' in the image produced by the lossy compression
[in,out]statuserror status

Here is the caller graph for this function:

int fits_set_huge_hdu ( fitsfile fptr,
int  huge,
int *  status 
)

This routine specifies whether the HDU that is being compressed is so large (i.e., > 4 GB) that the 'Q' type variable length array columns should be used rather than the normal 'P' type. The allows the heap pointers to be stored as 64-bit quantities, rather than just 32-bits.

Parameters
[in]fptrFITS file pointer
[in]hugeTrue (!= 0) or False (0)
[in,out]statuserror status

Here is the caller graph for this function:

int fits_set_lossy_int ( fitsfile fptr,
int  lossy_int,
int *  status 
)

This routine specifies whether images with integer pixel values should quantized and compressed the same way float images are compressed. The default is to not do this, and instead apply a lossless compression algorithm to integer images.

Parameters
[in]fptrFITS file pointer
[in]lossy_intTrue (!= 0) or False (0)
[in,out]statuserror status

Here is the caller graph for this function:

int fits_set_noise_bits ( fitsfile fptr,
int  noisebits,
int *  status 
)

THIS ROUTINE IS PROVIDED ONLY FOR BACKWARDS COMPATIBILITY; ALL NEW SOFTWARE SHOULD CALL fits_set_quantize_level INSTEAD

This routine specifies the value of the noice_bits parameter that should be used when compressing floating point images. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.

Since
Feb 2008: the "noisebits" parameter has been replaced with the more general "quantize level" parameter.
Parameters
[in]fptrFITS file pointer
[in]noisebitsnoise_bits parameter value (default = 4)
[in,out]statuserror status

Here is the call graph for this function:

int fits_set_quantize_dither ( fitsfile fptr,
int  dither,
int *  status 
)

the name of this routine has changed. This is kept here only for backwards compatibility for any software that may be calling the old routine.

Parameters
[in]fptrFITS file pointer
[in]ditherdither type
[in,out]statuserror status

Here is the call graph for this function:

int fits_set_quantize_level ( fitsfile fptr,
float  qlevel,
int *  status 
)

This routine specifies the value of the quantization level, q, that should be used when compressing floating point images. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.

Parameters
[in]fptrFITS file pointer
[in]qlevelfloating point quantization level
[in,out]statuserror status

Here is the caller graph for this function:

int fits_set_quantize_method ( fitsfile fptr,
int  method,
int *  status 
)

This routine specifies what type of dithering (randomization) should be performed when quantizing floating point images to integer prior to compression. A value of -1 means do no dithering. A value of 0 means use the default SUBTRACTIVE_DITHER_1 (which is equivalent to dither = 1). A value of 2 means use SUBTRACTIVE_DITHER_2.

Parameters
[in]fptrFITS file pointer
[in]methodquantization method
[in,out]statuserror status

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_set_tile_dim ( fitsfile fptr,
int  ndim,
long *  dims,
int *  status 
)

This routine specifies the size (dimension) of the image compression tiles that should be used when writing a FITS image. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.

Parameters
[in]fptrFITS file pointer
[in]ndimnumber of dimensions in the compressed image
[in]dimssize of image compression tile in each dimension default tile size = (NAXIS1, 1, 1, ...)
[in,out]statuserror status

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_uncompress_table ( fitsfile infptr,
fitsfile outfptr,
int *  status 
)

Uncompress the table that was compressed with fits_compress_table

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_unset_compression_param ( fitsfile fptr,
int *  status 
)

Here is the caller graph for this function:

int fits_unset_compression_request ( fitsfile fptr,
int *  status 
)

Here is the caller graph for this function:

int fits_write_compressed_img ( fitsfile fptr,
int  datatype,
long *  infpixel,
long *  inlpixel,
int  nullcheck,
void *  array,
void *  nullval,
int *  status 
)

Write a section of a compressed image.

Parameters
[in]fptrFITS file pointer
[in]datatypedatatype of the array to be written
[in]infpixel'bottom left corner' of the subsection
[in]inlpixel'top right corner' of the subsection
[in]intnullcheck 0 for no null checking 1: pixels that are = nullval will be written with the FITS null pixel value (floating point arrays only)
[in]arrayarray of values to be written
[in]nullvalundefined pixel value
[in,out]statuserror status

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_write_compressed_img_plane ( fitsfile fptr,
int  datatype,
int  bytesperpixel,
long  nplane,
long *  firstcoord,
long *  lastcoord,
long *  naxes,
int  nullcheck,
void *  array,
void *  nullval,
long *  nread,
int *  status 
)

in general we have to write the first partial row of the image, followed by the middle complete rows, followed by the last partial row of the image. If the first or last rows are complete, then write them at the same time as all the middle rows.

Parameters
[in]fptrFITS file
[in]datatypedatatype of the array to be written
[in]bytesperpixelnumber of bytes per pixel in array
[in]nplanewhich plane of the cube to write
[in]firstcoordof first pixel to write
[in]lastcoordof last pixel to write
[in]naxesof each image dimension
[in]nullcheck0 for no null checking 1: pixels that are = nullval will be written with the FITS null pixel value (floating point arrays only)
[in]arrayarray of values that are written
[in]nullvalvalue for undefined pixels
[out]nreadtotal number of pixels written
[in,out]statuserror status

Here is the call graph for this function:

Here is the caller graph for this function:

int fits_write_compressed_pixels ( fitsfile fptr,
int  datatype,
LONGLONG  fpixel,
LONGLONG  npixel,
int  nullcheck,
void *  array,
void *  nullval,
int *  status 
)

Write a consecutive set of pixels to a compressed image. This routine interpretes the n-dimensional image as a long one-dimensional array. This is actually a rather inconvenient way to write compressed images in general, and could be rather inefficient if the requested pixels to be written are located in many different image compression tiles.

The general strategy used here is to write the requested pixels in blocks that correspond to rectangular image sections.

Parameters
[in]fptrFITS file pointer
[in]datatypedatatype of the array to be written
[in]fpixel'first pixel to write
[in]npixelnumber of pixels to write
[in]nullcheck0 for no null checking 1: pixels that are = nullval will be written with the FITS null pixel value (floating point arrays only)
[in]arrayarray of values to write
[in]nullvalvalue used to represent undefined pixels
[in,out]statuserror status

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_calc_max_elem ( int  comptype,
int  nx,
int  zbitpix,
int  blocksize 
)

This function returns the maximum number of bytes in a compressed image line.

Parameters
[in]nxmaximum number of pixels in a tile
[in]blocksizeis only relevant for RICE compression

Here is the caller graph for this function:

int imcomp_compress_image ( fitsfile infptr,
fitsfile outfptr,
int *  status 
)

This routine does the following:

  • reads an image one tile at a time
  • if it is a float or double image, then it tries to quantize the pixels into scaled integers.
  • it then compressess the integer pixels, or if the it was not possible to quantize the floating point pixels, then it losslessly compresses them with gzip

writes the compressed byte stream to the output FITS file

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_compress_tile ( fitsfile outfptr,
long  row,
int  datatype,
void *  tiledata,
long  tilelen,
long  tilenx,
long  tileny,
int  nullcheck,
void *  nullflagval,
int *  status 
)

This is the main compression routine.

This routine does the following to the input tile of pixels:

  • if it is a float or double image, then it quantizes the pixels
  • compresses the integer pixel values
  • writes the compressed byte stream to the FITS file.

If the tile cannot be quantized than the raw float or double values are losslessly compressed with gzip and then written to the output table.

This input array may be modified by this routine. If the array is of type TINT or TFLOAT, and the compression type is HCOMPRESS, then it must have been allocated to be twice as large (8 bytes per pixel) to provide scratch space.

Note that this routine does not fully support the implicit datatype conversion that is supported when writing to normal FITS images. The datatype of the input array must have the same datatype (either signed or unsigned) as the output (compressed) FITS image in some cases.

Parameters
rowtile number = row in the binary table that holds the compressed data

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_convert_tile_tbyte ( fitsfile outfptr,
void *  tiledata,
long  tilelen,
int  nullcheck,
void *  nullflagval,
int  nullval,
int  zbitpix,
double  scale,
double  zero,
int *  intlength,
int *  status 
)

Prepare the input tile array of pixels for compression.

Here is the call graph for this function:

Here is the caller graph for this function:

Convert input float tile array in place to or byte ints for *If convert or byte ints and do null value substitution *Note that the calling routine must have allocated the input array big enough *to be able to do this *int imcomp_convert_tile_tdouble ( fitsfile outfptr,
long  row,
void *  tiledata,
long  tilelen,
long  tilenx,
long  tileny,
int  nullcheck,
void *  nullflagval,
int  nullval,
int  zbitpix,
double  scale,
double  zero,
int *  intlength,
int *  flag,
double *  bscale,
double *  bzero,
int *  status 
)

Prepare the input tile array of pixels for compression.

Here is the call graph for this function:

Here is the caller graph for this function:

Convert input integer *tile array in place to or byte ints for *If convert or byte ints and do null value substitution *Note that the calling routine must have allocated the input array big enough *to be able to do this *int imcomp_convert_tile_tfloat ( fitsfile outfptr,
long  row,
void *  tiledata,
long  tilelen,
long  tilenx,
long  tileny,
int  nullcheck,
void *  nullflagval,
int  nullval,
int  zbitpix,
double  scale,
double  zero,
int *  intlength,
int *  flag,
double *  bscale,
double *  bzero,
int *  status 
)

Prepare the input tile array of pixels for compression.

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_convert_tile_tint ( fitsfile outfptr,
void *  tiledata,
long  tilelen,
int  nullcheck,
void *  nullflagval,
int  nullval,
int  zbitpix,
double  scale,
double  zero,
int *  intlength,
int *  status 
)

Prepare the input tile array of pixels for compression. Convert input integer tile array in place to 4 or 8-byte ints for compression, If needed, do null value substitution.

Here is the call graph for this function:

Here is the caller graph for this function:

Convert input unsigned integer *tile array in place to or byte ints for *If convert or byte ints and do null value substitution *Note that the calling routine must have allocated the input array big enough *to be able to do this *int imcomp_convert_tile_tsbyte ( fitsfile outfptr,
void *  tiledata,
long  tilelen,
int  nullcheck,
void *  nullflagval,
int  nullval,
int  zbitpix,
double  scale,
double  zero,
int *  intlength,
int *  status 
)

Prepare the input tile array of pixels for compression.

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_convert_tile_tshort ( fitsfile outfptr,
void *  tiledata,
long  tilelen,
int  nullcheck,
void *  nullflagval,
int  nullval,
int  zbitpix,
double  scale,
double  zero,
double  actual_bzero,
int *  intlength,
int *  status 
)

Prepare the input tile array of pixels for compression. Convert input integer*2 tile array in place to 4 or 8-byte ints for compression, If needed, convert 4 or 8-byte ints and do null value substitution. Note that the calling routine must have allocated the input array big enough to be able to do this.

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_convert_tile_tuint ( fitsfile outfptr,
void *  tiledata,
long  tilelen,
int  nullcheck,
void *  nullflagval,
int  nullval,
int  zbitpix,
double  scale,
double  zero,
int *  intlength,
int *  status 
)

Prepare the input tile array of pixels for compression. Convert input unsigned integer tile array in place to 4 or 8-byte ints for compression, If needed, do null value substitution.

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_convert_tile_tushort ( fitsfile outfptr,
void *  tiledata,
long  tilelen,
int  nullcheck,
void *  nullflagval,
int  nullval,
int  zbitpix,
double  scale,
double  zero,
int *  intlength,
int *  status 
)

Prepare the input tile array of pixels for compression. Convert input unsigned integer*2 tile array in place to 4 or 8-byte ints for compression, If needed, convert 4 or 8-byte ints and do null value substitution. Note that the calling routine must have allocated the input array big enough to be able to do this.

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_copy_comp2img ( fitsfile infptr,
fitsfile outfptr,
int  norec,
int *  status 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_copy_img2comp ( fitsfile infptr,
fitsfile outfptr,
int *  status 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_copy_imheader ( fitsfile infptr,
fitsfile outfptr,
int *  status 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_copy_overlap ( char *  tile,
int  pixlen,
int  ndim,
long *  tfpixel,
long *  tlpixel,
char *  bnullarray,
char *  image,
long *  fpixel,
long *  lpixel,
long *  ininc,
int  nullcheck,
char *  nullarray,
int *  status 
)

copy the intersecting pixels from a decompressed tile to the output image. Both the tile and the image must have the same number of dimensions.

Parameters
[in]tilemulti dimensional array of tile pixels
[in]pixlennumber of bytes in each tile or image pixel
[in]ndimnumber of dimension in the tile and image
[in]tfpixelfirst pixel number in each dim. of the tile
[in]tlpixellast pixel number in each dim. of the tile
[in]bnullarrayarray of null flags; used if nullcheck = 2
[out]imagemulti dimensional output image
[in]fpixelfirst pixel number in each dim. of the image
[in]lpixellast pixel number in each dim. of the image
[in]inincincrement to be applied in each image dimen.
[in]nullcheck0, 1: do nothing; 2: set nullarray for nulls

Here is the caller graph for this function:

int imcomp_copy_prime2img ( fitsfile infptr,
fitsfile outfptr,
int *  status 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_decompress_tile ( fitsfile infptr,
int  nrow,
int  tilelen,
int  datatype,
int  nullcheck,
void *  nulval,
void *  buffer,
char *  bnullarray,
int *  anynul,
int *  status 
)

This routine decompresses one tile of the image

Parameters
[in]nrowrow of table to read and uncompress
[in]tilelennumber of pixels in the tile
[in]datatypedatatype to be returned in 'buffer'
[in]nullcheck0 for no null checking
[in]nulvalvalue to be used for undefined pixels
[out]bufferbuffer for returned decompressed values
[out]bnullarraybuffer for returned null flags
[out]anynulany null values returned?
[in]status)

Here is the caller graph for this function:

int imcomp_get_compressed_image_par ( fitsfile infptr,
int *  status 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_init_table ( fitsfile outfptr,
int  inbitpix,
int  naxis,
long *  naxes,
int  writebitpix,
int *  status 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_merge_overlap ( char *  tile,
int  pixlen,
int  ndim,
long *  tfpixel,
long *  tlpixel,
char *  bnullarray,
char *  image,
long *  fpixel,
long *  lpixel,
int  nullcheck,
int *  status 
)

Similar to imcomp_copy_overlap, except it copies the overlapping pixels from the 'image' to the 'tile'.

Parameters
[out]tilemulti dimensional array of tile pixels
[in]pixlennumber of bytes in each tile or image pixel
[in]ndimnumber of dimension in the tile and image
[in]tfpixelfirst pixel number in each dim. of the tile
[in]tlpixellast pixel number in each dim. of the tile
[in]bnullarrayarray of null flags; used if nullcheck = 2
[in]imagemulti dimensional output image
[in]fpixelfirst pixel number in each dim. of the image
[in]lpixellast pixel number in each dim. of the image
[in]nullcheck0, 1: do nothing; 2: set nullarray for nulls

Here is the call graph for this function:

Here is the caller graph for this function:

int imcomp_nulldoubles ( double *  fdata,
long  tilelen,
int *  idata,
int  nullcheck,
double  nullflagval,
int  nullval,
int *  status 
)

do null value substitution of the float array. If array value = nullflagval, then set the output value to FLOATNULLVALUE. Otherwise, inverse scale the integer value.

Here is the caller graph for this function:

int imcomp_nullfloats ( float *  fdata,
long  tilelen,
int *  idata,
int  nullcheck,
float  nullflagval,
int  nullval,
int *  status 
)

do null value substitution of the float array. If array value = nullflagval, then set the output value to FLOATNULLVALUE.

Here is the caller graph for this function:

int imcomp_nullscale ( int *  idata,
long  tilelen,
int  nullflagval,
int  nullval,
double  scale,
double  zero,
int *  status 
)

do null value substitution AND scaling of the integer array. If array value = nullflagval, then set the value to nullval. Otherwise, inverse scale the integer value.

int imcomp_nullscaledoubles ( double *  fdata,
long  tilelen,
int *  idata,
double  scale,
double  zero,
int  nullcheck,
double  nullflagval,
int  nullval,
int *  status 
)

do null value substitution of the float array. If array value = nullflagval, then set the output value to FLOATNULLVALUE. Otherwise, inverse scale the integer value.

Here is the caller graph for this function:

int imcomp_nullscalefloats ( float *  fdata,
long  tilelen,
int *  idata,
double  scale,
double  zero,
int  nullcheck,
float  nullflagval,
int  nullval,
int *  status 
)

do null value substitution of the float array. If array value = nullflagval, then set the output value to FLOATNULLVALUE. Otherwise, inverse scale the integer value.

Here is the caller graph for this function:

int imcomp_nullscalei2 ( short *  idata,
long  tilelen,
short  nullflagval,
short  nullval,
double  scale,
double  zero,
int *  status 
)

do null value substitution AND scaling of the integer array. If array value = nullflagval, then set the value to nullval. Otherwise, inverse scale the integer value.

int imcomp_nullvalues ( int *  idata,
long  tilelen,
int  nullflagval,
int  nullval,
int *  status 
)

do null value substitution. If array value = nullflagval, then set the value to nullval.

int imcomp_nullvaluesi2 ( short *  idata,
long  tilelen,
short  nullflagval,
short  nullval,
int *  status 
)

do null value substitution. If array value = nullflagval, then set the value to nullval.

int imcomp_scalevalues ( int *  idata,
long  tilelen,
double  scale,
double  zero,
int *  status 
)

do inverse scaling the integer values.

int imcomp_scalevaluesi2 ( short *  idata,
long  tilelen,
double  scale,
double  zero,
int *  status 
)

do inverse scaling the integer values.

int imcomp_test_overlap ( int  ndim,
long *  tfpixel,
long *  tlpixel,
long *  fpixel,
long *  lpixel,
long *  ininc,
int *  status 
)

test if there are any intersecting pixels between this tile and the section of the image defined by fixel, lpixel, ininc.

Parameters
[in]ndimnumber of dimension in the tile and image
[in]tfpixelfirst pixel number in each dim. of the tile
[in]tlpixellast pixel number in each dim. of the tile
[in]fpixelfirst pixel number in each dim. of the image
[in]lpixellast pixel number in each dim. of the image
[in]inincincrement to be applied in each image dimen.

Here is the caller graph for this function:

int imcomp_write_nocompress_tile ( fitsfile outfptr,
long  row,
int  datatype,
void *  tiledata,
long  tilelen,
int  nullcheck,
void *  nullflagval,
int *  status 
)

Write the uncompressed image tile pixels to the tile-compressed image file. This is a special case when using NOCOMPRESS for diagnostic purposes in fpack. Currently, this only supports a limited number of data types and does not fully support null-valued pixels in the image.

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

float* fits_rand_value = 0
char results[999][30]