Read3D
Reads the pixel image data from an individual image in a FITS data cube, which is a FITS file that contains multiple images on separate planes.
Syntax
void* Read3D( imageNumber );
Parameters
int imageNumber
The index of the individual image to read. Zero based.
Returns
void * - Pointer to the pixel image data. In most cases this pointer should be cast as an unsigned short *. The pointer should not be freed by the user; the class will handle that task.
Required Headers
CFitsFile.h
Namespace
arc
Throws
std::runtime_error
Remarks
None
Example
        // This code prints out the pixel image data for the
        // 24th image in a 16-bit FITS data cube. The image 
        // dimensions and number of frames are read from the 
        // header.

        #include <iostream>
        #include "CFitsFile.h"

        using namespace std;
        using namespace arc;

        int main()
        {
            long naxes[ CFitsFile::NAXES_SIZE ] = { 0, 0, 0 };

            try {
                CFitsFile cFits( "Image.fit" );

                cFits.GetParameters( naxes );

                //
                // Make sure there are at least 24 images
                // in the data cube.
                //
                if ( naxes[ CFitsFile::NAXES_NOF ] < 24 )
                {
                    cerr << "Error: Too few frames in data cube!" << endl;
                    exit( 1 );
                }

                //
                // Read the 24th image ( zero based )
                //
                unsigned short *pBuf = ( unsigned short * )cFits.Read3D( 23 );

                if ( pBuf == NULL )
                {
                    cerr << "Error: NULL image buffer!" << endl;
                    exit( 1 );
                }

                //
                // Print out the pixel values
                //
                for ( int r=0; r<naxes[ CFitsFile::NAXES_ROW ]; r++ )
                {
                    for ( int c=0; c<naxes[ CFitsFile::NAXES_COL ]; c++ )
                    {
                        cout << "pix[ " << ( c + r * naxes[ CFitsFile::NAXES_COL ] )
                             << " ]: " << pBuf[ c + r * naxes[ CFitsFile::NAXES_COL ] ]
                             << endl;
                    }
                }
            }
            catch ( std::exception &e )
            {
                cerr << "Exception Occurred: " << e.what() << endl;
            }
        }

© Astronomical Research Cameras, Inc.