CImage:DivFlatFrame


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

Syntax

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

bullet.gif    Flat is a CImage containing the flat field frame.

bullet.gif    The optional pixel_type specifies the output pixel type as a number or string.

bullet.gif    On success, this method returns true.

bullet.gif    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 pixel 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 pixel types between the source image and the flat frame. The default value when you do not specify the pixel_type is nil, which causes Mira to process the image without changing its pixel_type.

Before using this method, the flat field frame should have been normalized to a reference value near 1.0 and converted to a real pixel 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 loads an image and applies a flat field correction by dividing a flat frame. The output pixel 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 = new_image()

-- create a new CImage

I:Open(sPath)

-- load the image from file sPath

Flat = new_image()

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

CImage, SetMathErrVal , DivFlatNorm


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.