DVdownsize_struct


Synopsis

resample a structured field to reduce (or increase) its size


group DVdownsize {
Mesh_Struct+Node_Data+Iparam &in {
xform+nonotify;
nnodes+req;
};
float+Iparam factor[in.ndim];
Mesh_Struct+Node_Data+Oparam out{
&xform<weight=-1> => in.xform;
};
method+notify_val+notify_inst upd_downsize = "downsize";
} ;

Description

DVdownsize_struct resamples a structured field (mesh type Mesh_Struct) using a scaling factor. Where the factor is > 1, DVdownsize_struct reduces the size of the field, saving processing time and memory by "thinning out" the data. Where factor < 1, DVdownsize_struct increases the size of the field by duplicating data.

DVdownsize_struct works like this (see the 1D example on the following page):

fh412062.gif  

For each dimension i (X, Y, and Z) calculate:

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

•      Round dims_out up or down to the nearest whole integer.

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

•      Calculate the ratio of the intervals between nodes dims_in : dims_out

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

•      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: Throughout the process, the actual node data values and coordinate values are irrelevant. All that is being manipulated are the indexes into these arrays.

Input

&in

A reference to an input field containing a Mesh_Struct and Node_Data.

factor[in.ndim]

A float array used as a 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.

The length of the factor array (1D: just X; 2D: X and Y; 3D: X, Y and Z) is taken from the ndim of the Grid_Struct. You control the factor for each dimension separately.

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

Output

out

The output is a new object that contains a new Mesh_Struct. The new Mesh_Struct's points array (extents) will occupy the same "space" as the input field's Mesh_Struct.

The output field also contains a new Node_Data object containing the data associated with the downsized region.

Files

v/dv.v
modules/down.c

Example

Libraries.Main.Filters.downsize

See also