ResampleParams Table


The ResampleParams table contains properties used for resampling image pixels. The values in this data structure are used by various CImage class methods such as Scale and Rotate . Values in this structure must be passed to the script using the SetResampleParams function. Default resampling parameters are used unless you set them using this structure; see the Remarks section, below.

Syntax

Data from the ResampleParams table may be set using the table name, ResampleParams , followed by a dot and the member name, like this: ResampleParams.bMedianEdge accesses the table member named bMedianEdge.

ResampleParams Table Members

bMedianEdge

Specifies whether a blank image edge after resampling is filled with the median value of edge pixels (true) or uses the value of the sEdgeValue member (false).

bConserveFlux

If true, flux (signal per unit area) is conserved during geometric scaling.

sEdgeValue

Specifies the new edge value for blank pixels when the bMedianEdge is false. This is a string value, with the default “0”. If working with an RGB image, you can assign independent values to the 3 channels, like this: “100,214,55”.

sFilter

Specifies the resampling filter by the values “bi-cubic”. Only these values are supported.

Remarks

At startup, Mira sets default values for all ResampleParams members. The default values are as follows:

bullet.gif    bMedianEdge = true

bullet.gif    bConserveFlux = true

bullet.gif    sEdgeValue = “0”

bullet.gif    sFilter = ”bi-cubic”

Usually you use the same parameters for various processes that resample. If the defaults are not what you want, set the values and use SetResampleParams to change them in the script. You might do this in a separate source file and use Include at the beginning of your script..

Examples

Example 1. This script sets resampling parameters for use by the CImage:ScaleXy method. In particular, this script changes the edge value assignment, switches to bi-linear filtering, and does not conserve flux in the scaled image:

R = ResampleParams

-- Alias the structure name to reduce typing

R.bMedianEdge = false

-- force a specific value for blank edge pixels

R.sEdgeValue = “100”

-- set blank edge pixels to a value of 100

R.bConserveFlux = false

-- do not conserve flux

R.sFilter = “bi-linear”

-- choose the bi-linear resampling method

SetResampleParams( R )

-- assign the parameters to the script

I = V:GetImage()

-- attach an image from the CImageView

I:ScaleXy( 1.55, 1.423 )

-- scale the image, but do not conserve flux

Example 2. Suppose you want to use the same resampling parameters all the time. To do the same thing using the Include() strategy (see Remarks, above), use the script below. The first script is saved in a file named ‘ResampleDefs.lua’ which is saved in the ‘[Mira]\Scripts\Include’ folder:

R = ResampleParams

-- Alias the structure name to reduce typing

R.bMedianEdge = false

-- force a specific value for blank edge pixels

R.sEdgeValue = “100.5”

-- set blank edge pixels to a value of 100

R.bConserveFlux = false

-- do not conserve flux

R.sFilter = “bi-linear”

-- choose the bi-linear resampling method

SetResampleParams( R )

-- assign the parameters to the script

You can include ‘ResampleDefs.lua’ into your scripts, like this:

Include(“ResampleDefs.lua”)

-- include the resampling parameters

-- do some processing:

 

I = V:GetImage()

-- attach an image from the CImageView

I:ScaleXy( 1.55, 1.423 )

-- scale the image, but do not conserve flux

I:Rotate( 30.66, true )

-- rotate the image using same resampling

Related Topics

SetResampleParams, CImage Class, Image Geometry commands


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