CImage:CreatePixelMask

CImage:ApplyPixelMask


The ApplyPixelMask method repairs point defects identified by locations stored in a pixel mask file. This is effective for repairing point defects as well as single row and single column artifacts.

Syntax

bResult = CImage:ApplyPixelMask( nMethod, sMaskFile, CRect=nil )

bullet.gif    nMethod is a number corresponding to the repair method (see Remarks).

bullet.gif    sMaskFile is the name of the text file containing the pixel mask.

bullet.gif    The rectangular region to repair is specified by a CRect, with 1-based coordinates. If omitted, the entire image is repaired.

bullet.gif    On success, this method returns true.

bullet.gif    On failure, false is returned.

Remarks

This method replaces point values using a statistic computed from pixels in the neighborhood. The neighborhood method is described in the table below.

Pixel Mask Neighborhood Methods

Method

Description

1

Replaces the pixel by the mean value from its 4 nearest neighbors.

2

Replaces the pixel by the median value from its 4 nearest neighbors.

3

Replaces the pixel by the median value from its 8 nearest neighbors. Use this method for repairing 1 pixel wide line defects.

Point locations in need of repair are identified by pixel coordinates in a Pixel Mask File. A related pixel repair method is SetMaskedValue which replaces pixels with a specific value rather than a computed neighborhood value.

Example

Assume that a pixel mask file named sMaskFile exists. The following script repairs point values in the image in a file named sPath using defect coordinates from the pixel mask file. Points in the central 50% of the image are repaired by replacing them with the median of their 8 nearest neighbors:

 

I = new_image()

-- Create a CImage

I:Open( sPath )

-- Open the image from sPath.

w = I:Cols() ; h = I:Rows()

-- get image width and height

R = new_rect()

-- create a rectangle

R:Set( 0.25*w, 0.75*w, 0.25*h, 0.25*h ) )

-- central 50% of columns and rows

I:ApplyPixelMask( 3, sMaskFile, R )

-- apply the pixel mask

I:Save()

-- save the image

I:delete()

-- delete the CImage from memory

R:delete()

-- delete the CRect from memory

Related Topics

CImage class, SetMaskedValue, Pixel Mask File


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