downsize


Synopsis

resample a field to reduce (or increase) its size

Input Ports

in_field

any Mesh_Struct + Node_Data

ui_parent

user interface parent object

 

Parameters

Integer Sliders

UItoggle

constrain factors to be integers

I downsize factor

UIslider

skip number of indices in I dimension

J downsize factor

UIslider

skip number of indices in J dimension

K downsize factor

UIslider

skip number of indices in K dimension

 

Output Ports

out_fld

same Mesh_Struct + Node_Data

out_obj

output renderable object

 

Description

downsize resamples a field using a scaling factor. When the factor is greater than 1, downsize reduces the size of the field, saving processing time and memory by "thinning out" the data. When the factor is less than 1, downsize increases the size of the field by duplicating data.

Algorithm

The following steps describe how downsize works. For each dimension i (X, Y, and Z),

1.      dims_out[i] = dims_in[i] / factor[i]

Round dims_out to the nearest whole integer.

Note that the two endpoints are always preserved in the output data and the extents of the input field are preserved in the output field.

2.      Calculate the ratio of the intervals between nodes dims_in: dims_out and calculate new array indices.

3.      For each new array index, find the nearest whole integer by rounding up or down.

4.      Use the node data and coordinates in the input field that are found by these index values as the node data and coordinates for the output field.

Note that throughout the process, the actual node data values and coordinate values are irrelevant. All that is manipulated are the indices into these arrays.

For example, given a factor of 1.2 and the following 1D input field:

GENERATE/FH794135.gif

dims_out[1] = dims_in[1] / factor
= 5 / 1.2
= 4.1666

After rounding dims_out to the nearest whole integer, dims_out[1] = 4.

The number of intervals in dims_in is 4 and the number of intervals in dims_out is 3, so the ratio of the intervals between nodes dims_in: dims_out is 4 /3 or 1.333. Therefore, the four indices for dims_out are 0, 1.333, 2.666, and 3.999.

For each new array index, the nearest whole integer is 0, 1, 3, and 4.

The result of using the coordinates and node data in the input field at these index values as the coordinates and node data for the output field is:

GENERATE/FH412166.gif

Input Ports

in_field

The input must contain a structured mesh object (Mesh_Struct, Mesh_Rect, or Mesh_Unif), and a single Node_Data object. The mesh can be 1D, 2D, or 3D.

ui_parent

A port to connect to a user interface object that contains the macro's widgets. By default, it is connected to the default user interface object in the application in which the macro is instanced. (This default connection is not drawn.)

Parameters

Integer Sliders

UItoggle. When on, the downsize factor sliders are constrained to integers rather than floats. The default is on.

I downsize factor
J downsize factor
K downsize factor

Float UIsliders to specify the scaling coefficient. The output field's values (and coordinates for irregular data) are:

dims_out[i] = dims_in[i] / factor [i]

where i cycles through the dims of the field, either 1D, 2D, or 3D.

Note: factors < 1 make the output field larger. For example, a factor of .5 doubles the size of the output field.

You control the factor for each dimension separately. The default for all factors is 8. The range for all factors is 0.0 to 12.0.

All three controls appear no matter what the dimensionality of the input data. You only use the controls that are meaningful for the input data.

Output Ports

out_fld

The output field contains a new structured mesh of the same type as the input mesh, and a new Node_Data object containing the data associated with the downsized region.

The output mesh's points array (extents) will occupy the same "space" as the input field's Mesh.

out_obj

This is a renderable version of the output field.

Example

Libraries.Examples.Vizualization.Downsize
examples/down.v
Libraries.Examples.Visualization.Mirror_Scale
examples/mirr_scl.v

File

v/modules.v

See also