CImage Class
he CImage class encapsulates functionality for working with images and CImage objects derived from other data arrays such as lua tables as well as instances of CArray and CMatrix objects. The CImage class consists of a multi-dimensional data array and properties that describe the data. Included in this rich 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. Many class methods also can convert between the native table type and a CImage object.
The CImage class supports numerous Operators as a shorthand for several common operations between images and numbers In this version of MX Script, some class methods are obsolete; see Deprecated CImage Methods.
Construction |
Object = CImage:new() Object = CImage:newarray() |
Destruction |
Object:delete() |
The CImage class contains a rich collection of operators that cab greatly simply scripts. For example, assume these exist two CImage objects, I and I2. Then you might write the following: I = (I+5)^1.25 / I2.
Create and Copy new CImage objects. |
|
Perform filtering operations such as smoothing and enhancing. |
|
Open files, Create, Save, and Attach images. |
|
Perform geometric operations such as scale, rotate, expand, etc. |
|
Perform high level operations for calibrating CCD images. |
|
Work with image headers, retrieve, and set header keywords. |
|
Perform math operations such as add, exp, pow, etc. |
|
Perform image measurements including distance, angle, and luminance. |
|
Work with the image array, such as setting values of pixels, rows, or regions. |
|
Create and work with synthetic images. |
|
Accessors |
|
Retrieve properties of the image array such as number of axes, data type, number of rows, etc. |
|
Retrieve image properties such as name, exposure time, filter, etc. |
Creates a new instance of a CImage object. |
|
Creates a CImage from a Lua array (table). |
|
Extracts the CImage data into a Lua array (table). |
|
Copies an existing CImage object into this object. |
|
Duplicates this CImage object to a new CImage. |
|
Attaches the pointer from an image in a CImageView. |
|
Creates a new CImage and attaches an image selected from the list of images in a CImageView. |
|
Deletes the instance of the CImage object and deletes its image from memory. |
Also see the list of methods for working with synthetic images, below.
Closes the image to free memory but does not delete this CImage object. |
|
Creates an image of specified size and data type. |
|
Displays an image in a new image view window. |
|
Returns a pointer to the Mira image object. |
|
Opens an image from a file. |
|
Saves the image to its file. |
|
Saves the image to a new file name by prompting the user. |
|
Saves the image to a new file name without prompting. |
These methods create and manipulate synthetic images.
Creates a new synthetic image using properties from an CImSynthInfo object. |
|
Returns the number of stars created in the synthetic image. |
|
Returns a table of data for each star created in the synthetic image. |
Returns the angle formed by the line between 2 pixel coordinates. |
|
Returns the angle formed by the line between 2 world coordinates. |
|
Returns the worldcoordinate units for area measurements. |
|
Returns the distance between 2 worldcoordinates. |
|
Returns the distance between 2 pixel coordinates. |
|
Returns the world coordinate units for distance measurements. |
|
Returns as a string the distance between 2 world coordinates. |
Returns the 1-based coordinates of alinear pixel offset into the image array. This is the inverse of the Pos method. |
|
Returns the coordinate units for an image axis. |
|
Returns the coordinate label for an image axis. |
|
Returns the image scale in world coordinates per pixel. |
|
Returns the x and y axis image scale of the x and y axis in world coordinates per pixel. |
|
Returns the linear array position of the specified pixel coordinates. This is the inverse of the CoordOf method. |
|
Returns the linear array position of the first element satisfying a comparison with threshold values. |
|
Returns the coordinates of the first pixel with value >= target value. |
|
Returns the coordinates of the first pixel with value >= value1 or <= value2. |
|
Returns true if a pixel coordinate is inside the image. |
|
For a worldcoordinate, returns the pixel coordinate. |
|
Returns true if the image has an equatorial world coordinate calibration. |
|
For a pixel coordinate, returns the world coordinate in numeric form. |
|
For a pixel coordinate, returns the world coordinate in string form. |
Compares whether all the image pixels are equal to the values of another other image. Also see the == operator in Math Operators. |
|
Compares whether all the image pixels are less than or equal to the values of another image. Also see the <= operator in Math Operators. |
|
Compares whether all the image pixels are less than the values of another image. Also see the < operator in Math Operators. |
|
Extracts an image consisting of a specific byte plane. |
|
Creates an image consisting of a color channel from an RGB image. |
|
Returns the pixel value at a pixel coordinate in the form of a number. This works for images of any data type. |
|
Returns the pixel value from a numeric image at a pixel coordinate in the form of a number. |
|
Returns the pixel value from an RGB image at a pixel coordinate in the form of a string. |
|
Returns the image value at a pixel coordinate in the form of a string. This works for images of any data type. |
|
Creates an image consisting of a color channel from an RGB image. |
|
Sets the values in an image column to those in a table or to a single value. |
|
Sets the pixels in a rectangular region to the values in a Lua table or to a value with or without noise. |
|
Sets the values of pixels inside a rectangular region. |
|
Sets the values in an image row to those in a table or to a single value. |
|
Sets a pixel value at a pixel coordinate. |
|
Sets a pixel value for a numeric data type image. |
|
Sets a pixel value for an RGB data type image. |
Computes the absolute value of the image pixels. |
|
Adds an image or value. |
|
Adds Gaussian random noise to a region. |
|
Blends the values of the image with an operand image. |
|
Swaps the byte order of the pixels. |
|
Changes the sign of the image values. |
|
Divides by another image or value. |
|
Raises the base e to powers defined by the image pixels. |
|
Extracts an image consisting of a specific byte plane. |
|
Computes the base e logarithm of the pixel values. |
|
Computes the base 10 logarithm of the pixel values. |
|
Calculates the remainder of division by an image or value. |
|
Multiplies by an image or value. |
|
Returns the coordinate of the first pixel with value >= target value. |
|
Returns the coordinate of the first pixel with value >= value or <= value 2. |
|
Fits and subtracts a polynomial from the image. |
|
Fits and divides a polynomial into the image. |
|
Fit a polynomial and evaluate it in the image. |
|
Raises the image values to a power. The power may be a number or the pixels of another image of identical dimensions. |
|
Raises a base value to powers defined by the image pixels. |
|
Computes the reciprocal of the pixel values. |
|
Creates an image consisting of a color channel from an RGB image. |
|
Applies a linear scaling to the pixel values. |
|
Applies a polynomial intensity correction. |
|
Sets the values in an image column to those in a table or to a single value. |
|
Changes the image Data type specified by an index value. |
|
Sets the pixels in a rectangular region to the values in a Lua table or to a value with or without noise. |
|
Sets the values of pixels inside a rectangular region. |
|
Sets the values in an image row to those in a table or to a single value. |
|
Sets the value at the specified pixel coordinates. |
|
Computes the square root of the image values. |
|
Subtracts an image or value. |
|
Divides the image values into a numeric value. |
|
Subtracts the image values from a numeric value. |
Applies an affine transformation of shift, scale, and rotation. |
|
Averages pixel values into m x n super-pixels. |
|
Sums pixel values into m x n super-pixels. |
|
Crops the image to a smaller size along one or more axes. |
|
Tests whether two images have the same dimensions. |
|
Expands the image to larger dinension along one or more axes. The image also can be shifted along the expansion axis as part of the operation. |
|
Expands a 1-D image. The image also can be shifted along the column direction as part of the operation. |
|
Expands a 2-D image along an axis. The image also can be shifted as part of the operation. |
|
Flips the image horizontally. |
|
Imbeds another image at a specified location. |
|
Reverses the image about one or more axes. |
|
Offsets the image by an integral number of elements along one or more axes. |
|
Offsets the image by an integral number of elements along the column axis. |
|
Offsets the image by an integral number of elements along the column and row axes. |
|
Reorients the image in various quadrant transformations. |
|
Rotates the image 180 degrees about the chosen axes. |
|
Rotates the image 270 degrees about the chosen axes. |
|
Rotates the image 90 degrees about the chosen axes. |
|
Rotates the image by an angle about its center. |
|
Rotates the image by an angle about a point. |
|
Scales the image by a magnification factor. |
|
Scales the image independently by magnification factors in the x and y directions. |
|
Shifts the image about the chosen axes. |
|
Flips the image about the main diagonal of the chosen axes. |
|
Flips the image vertically. |
Deletes a keyword from the image header. |
|
Returns true if the named keyword exists in the image header. |
|
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. |
|
Returns a DMS angle for a string keyword plus a boolean flag indicating that the keyword is in the image header. |
|
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. |
|
Returns an HMS time for a string keyword plus a boolean flag indicating that the keyword is in the image header. |
|
Returns a numeric value keyword. |
|
Returns a numeric value keyword plus a boolean flag indicating that the keyword is in the image header. |
|
Returns the 4 column and row limits stored in a region section keyword, like BIASSEC. |
|
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. |
|
Returns a string value keyword. |
|
Returns a string value keyword plus a boolean flag indicating that the keyword is in the image header. |
|
Returns the value of a keyword in any format (string, number, etc.) as a string. |
|
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. |
|
Adds a blank keyword to the image header. |
|
Adds a blank keyword with string value to the image header. |
|
Sets the value of a boolean T/F keyword or adds the keyword to the image header. |
|
Adds a comment keyword to the image header. |
|
Sets the value of a date keyword or adds the keyword to the image header. |
|
Adds a history keyword to the image header. |
|
Sets the value of a numeric keyword or adds the keyword to the image header. |
|
Sets a region section keyword (e.g., BIASSEC) using the 4 column and row limits passed as numbers |
|
Sets the value of a string keyword or adds the keyword to the image header. |
|
Sets the value of a time keyword or adds the keyword to the image header. |
|
Sets the value of a keyword or adds the keyword to the image header. |
Applies a pixel mask to repair image blemishes. |
|
Creates a mask file for pixels above or below threshold values. |
|
Creates a mask file for pixels above a threshold value. |
|
Creates a mask file for pixels below a threshold value. |
|
Sets pixel values at coordinates identified in a pixel mask. |
|
Subtract a bias frame from the image. |
|
Subtract a bias value from the image. |
|
Subtract a reference bias value stored in a header keyword. |
|
Compute and apply a column bias correction. |
|
Compute and apply a row bias correction. |
|
Subtracts a dark frame from the image. |
|
Subtracts a time-scaled dark frame from the image. |
|
Subtracts a statistically optimized dark frame from the image. |
|
Divides the image by a flat field frame. |
|
Divides the image by a flat field frame while normalizing the flat during the calculation. |
Smooths the image using a binomial weight rectangular kernel. |
|
Replaces pixel values above a threshold value. |
|
Replaces pixel values below a threshold value. |
|
Smooths the image using an equal weight elliptical kernel. |
|
Smooths the image using a Gaussian weight elliptical kernel. |
|
Applies a directional derivative gradient filter. |
|
Applies a user-defined kernel. |
|
Applies a Laplacian filter, usually for edge detection. |
|
Applies a directional line selection kernel. |
|
Applies a maximum value filter. |
|
Applies a median filter. |
|
Applies a minimum value filter. |
|
Applies a Prewitt directional gradient mask. |
|
Applies a rank value filter. |
|
Smooths the image using an equal weight rectangular kernel. |
|
Applies a rotational gradient filter to enhance rotational or "spoked" features. |
|
Sharpens the image using a crispening filter. |
|
Applies a Sobel edge filter. |
|
Sharpens the image using unsharp masking. |
These methods return properties associated with the CImage including general properties and properties of the image data array.
Returns the number of image axes. |
|
Returns the number of bytes in the image pixel data. |
|
Returns the number of image columns (also see Axes ). |
|
Returns the image data type as a string, like "double". |
|
Returns true if the image is a color data type. |
|
Returns true if the image is an integer data type. |
|
Returns true if the image is a numeric data type. |
|
Returns true if the image is a real (floating point) data type. |
|
Returns the length of the specified image axis. |
|
Returns the number of bytes per pixel. |
|
Returns the number of pixels in the image. |
|
Returns the number of planes in the image (also see Axes). |
|
Returns the number of image rows (also see Axes). |
Returns the dark integration time for the image. |
|
Returns the date the image was acquired, in days. |
|
Returns the date of image acquisition as a string. |
|
Returns the image exposure time in seconds. |
|
Returns the name of the filter used for image acquisition. |
|
Returns the inverse gain in electrons per ADU. |
|
Returns the type of image, usually the value of the IMAGETYP keyword. |
|
Returns the object description. |
|
Returns the image file path. |
|
Returns the time of image acquisition as a number of seconds. |
|
Returns the time of image acquisition as a string. |