ResampleParams
The ResampleParams table contains information used by Mira when 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. Mira MX Script adopts default values if you do not set them using this structure.
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 name. Options are "nearest", "bilinear", and "bicubic". The default is “bilinear”. |
At startup, Mira sets default values for all ResampleParams members. The default values in efect the fist time you run a script are as follows:
bMedianEdge = true
bConserveFlux = true
sEdgeValue = “0”
sFilter = ”bilinear”
Is you change then using the SetResampleParams function, then the new values become the defaults until you again change them. Usually you use the same parameters for various processes that resample.
The following 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:
|
-- Alias the structure name to reduce typing |
|
-- force a specific value for blank edge pixels |
|
-- set blank edge pixels to a value of 100 |
|
-- do not conserve flux |
|
-- choose the bi-linear resampling method |
|
-- assign the parameters to the script |
|
-- attach an image from the CImageView |
|
-- scale the image, but do not conserve flux |
Suppose you want to use the same resampling parameters all the time. To do the same thing using theInclude() strategy (see 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:
|
-- Alias the structure name to reduce typing |
|
-- force a specific value for blank edge pixels |
|
-- set blank edge pixels to a value of 100 |
|
-- do not conserve flux |
|
-- choose the bi-linear resampling method |
|
-- assign the parameters to the script |
The next script uses the Include command to merge ‘ResampleDefs.Lua’ into your scripts:
|
-- include the resampling parameters |
-- do some processing: |
|
|
-- attach an image from the CImageView |
|
-- scale the image, but do not conserve flux |
|
-- rotate the image using same resampling |