int imageNumber |
The index of the individual image to read. Zero based. |
// 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.