CImage Class

The CImage class encapsulates functionality for working with images. Included in this huge class are tools for working with image files, doing image math operations, changing image geometry, making measurements, and working with header data. Additional methods for combining and merging images are found in the CImCombine, CStats and other classes and built-in global array functions, or you can also do pixel-by-pixel processing at the script syntax level. These operations can be applied to data arrays by having the script convert between the array and a CImage object. Also see CImage Math Operators.

Categories of CImage Methods

Construction Methods that create, copy, and delete CImage objects.
Array Operations Methods that work directly with image values, such as setting the value of a pixel, row, or region.
Coordinates Methods that work with and world coordinates, distances, and measurements.
Filtering Methods that perform filtering operations such as smoothing and enhancing.
General Methods Methods that open files, create, save, and attach images.
Calibration Methods that perform high level operations for calibrating CCD images.
Geometry Methods that perform geometric operations such as scaling, rotating, expanding, etc.
Properties Methods that retrieve image properties such as name, number of columns, exposure time, filter, image type, etc.
Keyword Operations Methods that work with image headers and retrieve and set header keywords.
Math Operations Methods that perform mathematical operations between images and image values, including multiplication, exponentiation, etc.
Measurements Methods that measure features in images including distance, angle, luminance, etc.
Math Operators Syntax for using CImage objects as variables to simplify the syntax of complex operations, such as Image = 1.0082 * (I4 - ImBias / const)

Construction

newimage Global function that creates a new instance of the CImage class. See the class method  new.
new Class method that creates a new instance of the CImage class. Various constructors are available.
delete Deletes the instance of the CImage object and deletes its image from memory.
Copy Copies the image to a new image.
Attach Attaches the pointer from an image in a CImageView.
AttachFromList Creates a new CImage and attaches an image selected from the list of images in a CImageView.
ArrayToImage Converts a lua array (indexed table) to a CImage object.
ImageToArray Converts a CImage object to a lua array (indexed table).

General Methods

Close Closes the image and deletes it from memory.
Create Creates a new image of specified size and data type.
Display Displays an image in a new image view window.
GetImagePtr Returns a pointer to the Mira image object.
Open Opens an image from a file.
Save Saves the image to its file.
SaveAs Saves the image to a new file name by prompting the user.
SaveTo Saves the image to a new file name without prompting.

Image Properties

Axes Returns the number of image axes.
Bytes Returns the number of bytes in the image pixel data.
Cols Returns the number of image columns.
Darktime Returns the dark integration time for the image.
Date Returns the date the image was acquired, in days.
DateStr Returns the date of image acquisition as a string.
DatatypeStr Returns the image data type as a string.
Datatype Returns the image data type as a numeric index.
Exptime Returns the image exposure time in seconds.
Filter Returns the name of the filter used for image acquisition.
Gain Returns the inverse gain in electrons per ADU.
ImageType Returns the type of image, usually the value of the IMAGETYP keyword.
IsColor Returns true if the image is a color data type.
IsInteger Returns true if the image is an integer data type.
IsNumeric Returns true if the image is a numeric data type.
IsReal Returns true if the image is a real (floating point) data type.
Object Returns the object description.
Path Returns the image file path.
PixelBytes Returns the number of bytes per pixel.
Pixels Returns the number of pixels in the image.
Rows Returns the number of image rows.
Time Returns the time of image acquisition as a number of seconds.
TimeStr Returns the time of image acquisition as a string.

Measurements

Angle Returns the angle formed by the line between 2 pixel coordinates.
AngleWcs Returns the angle formed by the line between 2 world coordinates.
AreaUnits Returns the world coordinate units for area measurements.
DistanceWcs Returns the distance between 2 world coordinates.
Distance Returns the distance between 2 pixel coordinates.
DistanceUnits Returns the world coordinate units for distance measurements.
DistanceWcsStr Returns as a string the distance between 2 world coordinates.
Val Returns the pixel value at a pixel coordinate in the form of a number.
ValStr Returns the image value at a pixel coordinate in the form of a string.

Coordinates

CoordUnits Returns the coordinate units for an image axis.
GetAxisLabel Returns the coordinate label for an image axis.
GetImageScale Returns the image scale in world coordinates per pixel.
GetImageScaleXy Returns the x and y axis image scale of the x and y axis in world coordinates per pixel.
PtInside Returns true if a pixel coordinate is inside the image.
WcsToXy For a world coordinate, returns the pixel coordinate.
WcsIsEq Returns true if the image has an equatorial world coordinate calibration.
XyToWcs For a pixel coordinate, returns the world coordinate in numeric form.
XyToWcsStr For a pixel coordinate returns the world coordinate in string form.

Array Operations

CompareEQ Compares whether all the image pixels are equal to the values of another other image. also see Math Operators.
CompareLE Compares whether all the image pixels are less than or equal to the values of another image.
CompareLT Compares whether all the image pixels are less than the values of another image.
ExtractByte Extracts an image consisting of a specific byte plane.
ExtractChan Creates an image consisting of a color channel from an RGB image.
PixGE Returns the coordinate of the first pixel with value >= target value.
PixGELE Returns the coordinate of the first pixel with value >= value or <= value 2.
ExtractChan Creates an image consisting of a color channel from an RGB image.
SetColumn Sets the values in an image column to those in a table or to a single value.
SetRegion Sets the pixels in a rectangular region to the values in a lua table or to a value with or without noise.
SetRegionVal Sets the values of pixels inside a rectangular region.
SetRow Sets the values in an image row to those in a table or to a single value.
SetVal Sets the pixel value at a pixel coordinate.

Math Operations

Abs Computes the absolute value of the image pixels.
Add Adds an operand image.
AddNoise Adds Gaussian random noise to a rectangular region of an image.
Addx Adds a numeric value.
Blend Blends the values of the image with an operand image.
Blendx Blends the image values with a numeric value.
Byteswap Swaps the byte order of the pixels.
Chs Changes the sign of the image values.
Div Divides by an operand image.
Divx Divides by a numeric value.
Exp Raises base e to powers specified by the image pixels.
ExtractByte Extracts an image consisting of a specific byte plane.
Log Computes the base-e logarithm of the pixel values.
Log10 Computes the base-10 logarithm of the pixel values.
Mod Calculates the remainder of division by an operand image.
Modx Computes the remainder of division by a numeric value.
Mul Multiplies by an operand image.
Mulx Multiplies by a numeric value.
PixGE Returns the coordinate of the first pixel with value >= target value.
PixGELE Returns the coordinate of the first pixel with value >= value or <= value 2.
PolyFitSub Fits and subtracts a polynomial from the image.
PolyFitDiv Fits and divides a polynomial into the image.
PolyFitImage Fit a polynomial and evaluate it in the image.
Pow Raises the image values to a power.
Powa Raises a base value to powers specified by the image pixels.
Powab Raises the image pixels to the power defined by the pixels of an operand image.
Recip Computes the reciprocal of the pixel values.
ExtractChan Creates an image consisting of a color channel from an RGB image.
ScaleLinVal Applies a linear scaling to the pixel values.
ScalePolyVal Applies a polynomial intensity correction.
SetColumn Sets the values in an image column to those in a table or to a single value.
SetDatatype Changes the image Data type specified by an index value.
SetRegion Sets the pixels in a rectangular region to the values in a lua table or to a value with or without noise.
SetRegionVal Sets the values of pixels inside a rectangular region.
SetRow Sets the values in an image row to those in a table or to a single value.
SetVal Sets the pixel value at a pixel coordinate.
Sqrt Computes the square root of the image values.
Sub Subtracts an operand image.
Subx Subtracts a numeric value.
Xdiv Divides the image values into a numeric value.
Xsub Subtracts the image values from a numeric value.

Image Geometry

Affine Applies an affine transformation of shift, scale, and rotation.
BlockAvg Averages pixel values into m x n super-pixels.
BlockSum Sums pixel values into m x n super-pixels.
Crop Crops a smaller piece from the image.
DimEq Tests whether 2 images have the same dimensions.
Expand Expands the image into a larger canvas with specified border value and optional random noise.
Hflip Flips the image horizontally.
Imbed Imbed the image at a specific location in another image.
Reorient Reorients the image in various quadrant transformations.
Rot180 Rotates the image 180 degrees.
Rot270 Rotates the image 270 degrees.
Rot90 Rotates the image 90 degrees.
Rotate Rotates the image by an angle about its center.
RotatePt Rotates the image by an angle about a point.
Scale Scales the image by a magnification factor.
ScaleXy Scales the image independently by magnification factors in the x and y directions.
Shift Shifts the image horizontally and vertically.
Transpose Flips the image about its main diagonal.
Vflip Flips the image vertically.

Header Keyword Operations

KwdDelete Deletes a keyword from the image header.
KwdExists Returns true if the named keyword exists in the image header.
KwdGetDMS Returns a properly formatted angle string for a keyword value given in degrees, minutes, and seconds. Use this for keywords not in the standard format using : as a field delimiter.
KwdGetDmsEx Returns a DMS angle for a string keyword plus a boolean flag indicating that the keyword is in the image header.
KwdGetHMS Returns a MHS time string for a string keyword value given in hours, minutes, and seconds. Use this for keywords not in the standard format using : as a field delimiter.
KwdGetHmsEx Returns an HMS time for a string keyword plus a boolean flag indicating that the keyword is in the image header.
KwdGetNum Returns a numeric value keyword.
KwdGetNumEx Returns a numeric value keyword plus a boolean flag indicating that the keyword is in the image header.
KwdGetSect Returns the 4 column and row limits stored in a region section keyword, like BIASSEC.
KwdGetSectEx Returns the 4 column and row limits stored in a region section keyword (e.g., BIASSEC), plus a boolean flag indicating that the keyword is in the image header.
KwdGetStr Returns a string value keyword.
KwdGetStrEx Returns a string value keyword plus a boolean flag indicating that the keyword is in the image header.
KwdGetVal Returns the value of a keyword in any format (string, number, etc.) as a string.
KwdGetValEx Returns the value of a keyword in any format (string, number, etc.) as a string and also a boolean flag indicating that the keyword is in the header.
KwdSetBlank Adds a blank keyword to the image header.
KwdSetBlankStr Adds a blank keyword with string value to the image header.
KwdSetBool Sets the value of a boolean T/F keyword or adds the keyword to the image header.
KwdSetComment Adds a comment keyword to the image header.
KwdSetDate Sets the value of a date keyword or adds the keyword to the image header.
KwdSetHistory Adds a history keyword to the image header.
KwdSetNum Sets the value of a numeric keyword or adds the keyword to the image header.
KwdSetSect Sets a region section keyword (e.g., BIASSEC) using the 4 column and row limits passed as numbers
KwdSetStr Sets the value of a string keyword or adds the keyword to the image header.
KwdSetTime Sets the value of a time keyword or adds the keyword to the image header.
KwdSetVal Sets the value of a keyword or adds the keyword to the image header.

Image Calibration

ApplyPixelMask Applies a pixel mask to repair image blemishes.
CreatePixelMask Creates a mask file for pixels above or below threshold values.
CreatePixelMaskHigh Creates a mask file for pixels above a threshold value.
CreatePixelMaskLow Creates a mask file for pixels below a threshold value.
SetMaskedValue Sets pixel values at coordinates identified in a pixel mask.
SubBiasFrame Subtract a bias frame from the image.
SubBiasVal Subtract a bias value from the image.
SubBiasRef Subtract a reference bias value stored in a header keyword.
SubBiasCol Compute and apply a column bias correction.
SubBiasRow Compute and apply a row bias correction.
SubDarkFrame Subtracts a dark frame from the image.
SubDarkScaled Subtracts a time-scaled dark frame from the image.
SubDarkOpt Subtracts a statistically optimized dark frame from the image.
DivFlatFrame Divides the image by a flat field frame.
DivFlatNorm Divides the image by a flat field frame while normalizing the flat during the calculation.

Filtering Methods

FiltBinomial Smooths the image using a binomial weight rectangular filter to an image or rectangular region of an image.
FiltClipHigh Replaces image pixels above a threshold value.
FiltClipLow Replaces image pixels below a threshold value.
FiltEllipse Smooths the image using an equal weight elliptical filter to an image or rectangular region of an image.
FiltGaussian Smooths the image using a Gaussian weight elliptical filter to an image or rectangular region of an image.
FiltGradient Applies a directional derivative gradient filter to an image or rectangular region of an image.
FiltKernel Applies a user-defined filter to an image or rectangular region of an image.
FiltLaplacian Applies a Laplacian filter, usually for edge detection.
FiltLine Applies a directional line selection filter to an image or rectangular region of an image.
FiltMax Applies a maximum value filter to an image or rectangular region of an image.
FiltMedian Applies a median filter to an image or rectangular region of an image.
FiltMin Applies a minimum value filter to an image or rectangular region of an image.
FiltPrewitt Applies a Prewitt directional gradient mask.
FiltRank Applies a rank value filter to an image or rectangular region of an image.
FiltRect Smooths the image using an equal weight rectangular filter to an image or rectangular region of an image.
FiltRotGrad Applies a rotational gradient filter to enhance rotational or "spoked" features.
FiltSharpen Sharpens the image using a crispening filter to an image or rectangular region of an image.
FiltSobel Applies a Sobel edge filter to an image or rectangular region of an image.
FiltUnsharpMask Sharpens the image using unsharp masking.
 
 

Learn More

Name  *

E-mail  *

Item of Interest

Organization

Telephone

Application

Comments

Verification *