long llrow |
Lower left row pixel. |
long llcol |
Lower left column pixel. |
long urrow |
Upper right row pixel. |
long urcol |
Upper right column pixel. |
// This code demonstrates how to read a 100x300
// pixel sub-image at position ( 300, 100 ),
// ( 600, 200 ).
//
// Primary Image
// +----------------------------------------+
// | 600 |
// |<--------------------------> |
// | +----------------+ ^ |
// | | Sub-Image | | |
// | 300 | ( 100x140 ) | | |
// |<------->+----------------+ | 200 |
// | ^ | |
// | | 100 | |
// | V V |
// +----------------------------------------+
//
#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" );
unsigned short *pBuf = ( unsigned short * )
cFits.ReadSubImage( 100, 300, 200, 600 );
if ( pBuf == NULL )
{
cerr << "Error: NULL image buffer!" << endl;
exit( 1 );
}
cFits.GetParameters( naxes );
for ( int r=0; r<( 200 - 100 ); r++ )
{
for ( int c=0; c<( 600 - 300 ); 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.