The Solar-Stellar Spectrograph

[ Home | About | Tech Info & Data | Publications | References ]      [ Site by Jeffrey Hall | Research funded by NSF ]



The Image class performs general 2D image manipulation. It inherits Filelink.

This class is generally used in conjunction with a BasicFITSHeader class to handle the two components of a typical spectroscopic data file.

Version History

2008 July 09 - Documentation written.


Data Members

string id

string imStat

string dataType

int xDim

int yDim

pointer image


Method List





get_data_type( )

get_dimensions( )

get_image_ptr( )

get_subimage( )

init( )

is_valid( )





set_data_type( )




write( )


Method Descriptions


PRO byteswap

keyword bool ifBig

keyword bool ifLittle

Swaps the byte order of the image data. If either of the keywords is set, the data will only be byteswapped if they are already of the specified endian form (e.g., if ifBig is set, the data will only be swapped if they are big-endian).


PRO cleanup

Calls Filelink::cleanup

Destructor. Clears its history list by calling Filelink::cleanup, and freeing its own image pointer. Never call this procedure directly; it is invoked by IDL's Obj_Destroy function.


PRO define

Structure definition. Specifies the contents of the IDL structure instantiated by the Image class. Used by Obj_New; do not invoke directly.


PRO dump_stat

Calls Filelink::dump_stat

This is a standard OIL class method. For the Image class, it dumps the current data members, as well as the validity state of the image pointer, followed by the data members of the parent Filelink object, to the command output window. The dump will look best if the output font is fixed rather than proportional width.


FUNCTION get_data_type

Return string dataType

Returns the value of the dataType member.


FUNCTION get_dimensions

Return int[ 2 ] [ xDim, yDim ]

Returns the xDim and yDim data members as a two element integer array.


FUNCTION get_image_ptr

Return pointer p

Returns a pointer to the image data member.


FUNCTION get_subimage

argument int left

argument int bottom

argument int right

argument int top

Return pointer subImage

Returns a pointer to a subset of the image data specified by the coordinates given in the arguments. A new data array is created in memory containing the subimage data, and the pointer returned. The pointer should be freed after use to avoid memory leaks.



keyword string id

keyword string imstat

keyword string dataType

keyword int xDim

keyword int yDim

keyword struct _EXTRA

Return bool TRUE

Calls Image::new_data_array, Root::add_history

Constructor. The obect's data members are set to the values specified in the keywords. If keywords are omitted, the contructor takes the following default actions: id = 'NULL', imStat = 'raw', dataType = 'int', and xDim and yDim are both 512. After making sure all data members have valid values, it calls new_data_array to create the image data member. Never call this function directly; it is invoked by IDL's Obj_New function.


FUNCTION is_valid

Calls Root::add_history, Filelink::is_valid

Return long[3] valid

Each OIL class has an is_valid function that performs class-specific tests on its data members. If all members are found to be valid, however validity is defined for that class, this funtion returns 1. Otherwise, a negative number is returned that contains a bitwise combination of all errors detected. In the case of Image, the bitwise error codes are: -1 if the image pointer is invalid, -2 if either dimension is less than 1, -4 if the dimensions given by the data members are not equal to the number of elements in the corresponding dimension of the data array, -8 if the dataType data member is NULL, and -16 if the dataType data member does not match the type of the image data. The function returns a three-element array of longs, the first element containing the validity state of the Root, the second that of the Filelink, and the last that of the Image. A warning is written to the log if the Image is invalid.


PRO new_data_array

argument string dataType

argument int x

argument int y

argument pointer image

Calls Root::add_history

Creates (or re-initializes) the data array. The object's data member Self.image is set to the data array pointed to by the argument image. The dataType, xDim, and yDim data members are updated to the values specified by the corresponding arguments. To ensure there are no memory leaks, the object's image data pointer is freed first if it is valid.



keyword bool skipBasicFITS

keyword long offset

Calls Filelink::open_datafile, Filelink::close_datafile, Root::add_history

Return bool TRUE, FALSE

Reads data from the specified file into the object's image data. It sets the LUN offset to 2880 if skipBasicFITS is set, and to offset if that keyword is set. Otherwise, it reads from the start of the file (offset 0). It returns TRUE if the read succeeded, false otherwise.


PRO rotate

argument int deg

keyword bool flip

Rotates the image clockwise by deg degrees. Set deg to 90, 180, or 270. Set flip to also flip the image about its central row.


PRO scale_to

argument int minVal

argument int maxVal

Scales the image data to fit in the range [ minVal, maxVal ].


FUNCTION set_data_type

argument string type

Calls Filelink::modified, Root::add_history

Return bool TRUE, FALSE

Changes the data type of the image data. The type argument must be 'byte', 'int', 'uint', 'float', or 'double'. It returns TRUE if the type change succeeded, false otherwise.


PRO set_id

argument string id

Calls Root::add_history

Sets the id data member.


PRO set_imstat

argument string imstat

Calls Root::add_history

Sets the imstat data member.


PRO show

argument int xOff

argument int xYff

keyword bool scale

keyword bool resize

Displays the image. The offset arguments are passed to the analogous arguments in TV or TVScl. If the scale keyword is set, TVScl is called. The resize keyword can be used to rebin the image to a fractional value of its original size; i.e., set resize to 0.5 if you want the image to be half its original size in the displayed image.



keyword bool a

Calls Filelink::open_datafile, Filelink::close_datafile, Root::add_history

Return bool TRUE, FALSE

Writes the image to the linked file. Set the a keyword to open the file in append mode; otherwise it will be opened in write mode. It returns TRUE if the read succeeded, false otherwise.


Sample Usage

obj = Obj_New( 'Image', xDim=1024, yDim=1024, dataType='int' )

Obj_Destroy( obj )


[Back to contents]

Supported by grants from the National Science Foundation.
[ Back to my home page | Email me: jch [at] lowell [dot] edu ]
The SSS is publicly funded. Unless explicitly noted otherwise, everything on this site is in the public domain.
If you use or quote our results or images, we appreciate an acknowledgment.
This site is best viewed with Mozilla Firefox.