CImage:FiltClipLow CImage:DivFlatNorm

CImage:DivFlatFrame


The DivFlatFrame method applies a flat field correction to an image. The result replaces the current image.

Syntax

bResult = CImage:DivFlatFrame( Flat, datatype=nil )

    Flat is a CImage containing the flat field frame.

    The optional datatype specifies the output

    The optional data type is a number or string.

    On success, this method returns true.

    On failure, false . is returned.

Remarks

This method applies a flat field correction to the image and updates the image header with the appropriate history and other keywords. The data type of the image may be changed as part of the flat field correction, for example, to maximize the precision of the calculations. Mira automatically handles mixing different data types between the source image and the flat frame. The default value when you do not specify the datatype is nil, which causes Mira to process the image without changing its datatype.

Before using this method, the flat field frame should have been normalized to a reference value near 1.0 and converted to a real data type such as "float" or "double". Usually the normalization reference region is located at or near the center of the image.

Since the flat field correction is a division process, there is a possibility of a divide-by-zero error if the flat frame has a zero value pixel. Mira traps such errors and replaces the output pixel with the value specified using the global SetMathErrVal function. The best strategy is to clean the flat field frame of zero values before applying it to images.

Example

The following script fragment loads an image and applies a flat field correction by dividing a flat frame. The output data type is changed to "float" to maintain precision of the correction process. In practice you might maintain the flat frame in memory inside a loop where you apply other calibrations in addition to the flat field method.

Assume the file to process is named sPath and the flat field frame is in the file named sFlatPath. We first create a CImage object and open the target file sPath into that object. We do the same for the flat frame in the file sFlatPath. Then we call the CImage class method DivFlatFrame() and save the processed image.

I = CImage:new()

-- create a new CImage

I:Open(sPath)

-- load the image from file sPath

Flat = CImage:new()

-- create a new CImage

Flat:Open(sFlatPath)

-- load the flat frame from sFlatName

I:DivFlatFrame(Flat,"float")

-- apply the flat field correction to image I

I:Save()

 -- save the image

I:delete()

 -- delete the image from memory

Flat:delete()

 -- delete the flat frame from memory

Related Topics

C Image, SetMathErrVal , DivFlatNorm