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 class.

Usage

Construction

Object = CImage:new()

Destruction

Object:delete()

Data Members

ptr

A pointer to the Mira image object in memory. The pointer is nil if no image is open, created, or attached to the CImage object.

Note: It is usually not safe practice to work directly with the value of ptr. Instead, use the GetImagePtr or Attach method.

Methods

Construction

Create, copy, and delete CImage objects

Coordinates

Work with pixel and world coordinates, distances, and measurements.

Filtering

Perform filtering operations such as smoothing and enhancing.

General Methods

Open files, Create, Save, and Attach images, etc.

Calibration

These methods perform high level operations for calibrating CCD images.

Geometry

Perform geometric operations such as scale, rotate, expand, etc.

Properties

Retrieve image properties such as name, columns, exposure time, filter, image type, etc.

Keyword Operations

Work with image headers; retrieve and set header keywords.

Math

Perform math operations such as multiple, exp, etc.

Measurements

Perform image measurements including distance, angle, and luminance.

Construction

new

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.

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.

Math Operations

Abs

Computes the absolute value of the image pixels.

Add

Adds an operand image.

AddNoise

Adds Gaussian random noise to a region.

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.

RgbExtract

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.

SetDatatype

Changes the image Data type specified by an index value.

SetRegionVal

Sets the values of pixels inside a rectangular region.

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 kernel.

FiltClipHigh

Replaces pixel values above a threshold value.

FiltClipLow

Replaces pixel values below a threshold value.

FiltEllipse

Smooths the image using an equal weight elliptical kernel.

FiltGaussian

Smooths the image using a Gaussian weight elliptical kernel.

FiltGradient

Applies a directional derivative gradient filter.

FiltKernel

Applies a user-defined kernel.

FiltLaplacian

Applies a Laplacian filter, usually for edge detection.

FiltLine

Applies a directional line selection kernel.

FiltMax

Applies a maximum value filter.

FiltMedian

Applies a median filter.

FiltMin

Applies a minimum value filter.

FiltPrewitt

Applies a Prewitt directional gradient mask.

FiltRank

Applies a rank value filter.

FiltRect

Smooths the image using an equal weight rectangular kernel.

FiltRotGrad

Applies a rotational gradient filter to enhance rotational or "spoked" features.

FiltSharpen

Sharpens the image using a crispening filter.

FiltSobel

Applies a Sobel edge filter.

FiltUnsharpMask

Sharpens the image using unsharp masking.

Related Topics

Script Classes, CImageSet, CImageView, CImCombine, Image Coordinate System, Subpixel Coordinate Definition