extract

From DavinciWiki
Jump to: navigation, search


64-bit SafeYes

Description

Extracts portions of a VAL orthogonal to a given mask

Arguments and Return Values

Arguments: A data array and a mask array

Return Value: A data array extracted from input

Usage

Syntax: extract(object = VAL, mask = VAL [, axis = STRING])

'object' - data to extract from

'mask' - non-zero location specifies data to extract

'axis' - indicates how to arrange extracted pieces

This routine will extract portions of the object orthogonal to the mask and coresponding to the points where the mask is set. This function is intended to speed the extraction of higher dimensional data from lower dimensional masks. For example, the commands:

obj = create (10,10,10);
mask = create(10,10,1, format=BYTE, start=0, step=0);
mask[1,1] = mask[2,2] = mask[3,3] = 1;
data = extract (obj, mask, axis="x");

would extract and return 'data' as a 3x1x10 VAR. The extract() function locates each non-zero bit in 'mask', and grabs the portion of 'obj' that is specified by that mask bit. Visualize the 10x10x1 'mask' as a 2D plane and the 10x10x10 'obj' as a 3D cube. Any point in the 2D 'mask' plane then uniquely specifies a 1x1x10 line in the 'obj' cube.

The extract() function extracts each of these 1x1x10 objects and stacks them together. The pieces can be stacked together along either the x or y axes. Since the function has no assumptions about what the user wants, the user must specify the axis that pieces should be added along. To get a 1x3x10 VAR in 'data', the user could have specified axis="y" instead.

When the mask can be described as a 1D line and the object as a 3D cube, each mask bit specifies a 2D plane. The planes can be stacked together in only one way, so the user does not have to specify an axis in that case.

The VAL/mask combinations are listed below, with example sizes in the last three columns. The N used in the outputs is the number of mask bits set.

  • VAL Mask Pieces VAL Mask Output
  • 1D 1D points 5x1x1 5x1x1 Nx1x1 (axis="x")
  • 2D 2D points 5x5x1 5x5x1 Nx1x1 (axis="x")
  • 3D 3D points 5x5x5 5x5x5 Nx1x1 (axis="x")
  • 2D 1D lines 5x5x1 1x5x1 5xNx1 (axis="y")
  • 3D 2D lines 5x5x5 5x5x1 Nx1x5 (axis="x")
  • 3D 1D planes 5x5x5 1x1x5 5x5xN (axis may be omitted)
  • 1D 2D n/a n/a n/a n/a
  • 1D 3D n/a n/a n/a n/a
  • 2D 3D n/a n/a n/a n/a

Examples

dv> # load PDS qube to select spectra from

dv> qube = load_pds(filename).qube.data;


dv> # user wants to view the spectra under every 20th pixel in the x/y plane

dv> mask = create(dim(qube)[1],dim(qube)[2],1, format=BYTE);

dv> mask[] = 0;

dv> mask[1::20,1::20] = 1;


dv> # extract the selections and shape them into Nx1xZ VAR, where N is the

dv> # num. of mask bits set and Z is the num. of bands in the qube.

dv> spectra = extract (qube,mask,axis="x");


dv> # plot the selections
 
dv> xplot (spectra, axis=z);

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left


Recent Core Changes

Modified On: 07-06-2009

Personal tools