The Map-Reduce slang abstracts the parallel evaluation of a mapping function followed by a 3D reduction operation. The user specifies a function that maps voxel attributes of (multiple) input volume(s) to one output value. The mapping function is then passed to one of the predefined reduction operations addition, minimum, maximum or multiplication. With the Map-Reduce slang the user can quickly implement reduction operations that are executed on the GPU. Typical algorithms that can be implemented by the user include: counting all voxels that are true in a vset, or finding the maximum of all voxels in a vlabel. More complex mapping functions can be used to query for certain value ranges, for instance, to count voxels or to compute the centroid of a connected component with a specific id in a vlabel volume. For multiple input volumes, the computation of properties of intersections and unions is possible as well as performing more complex filtering operations.
The grammar of the Map-Reduce slang consists of the mapping function declaration and reduction function call. The grammar of the mapping function declaration accepts a subset of the main language’s function declaration. Statements like linking and unlinking as well as triggers are not permitted in the mapping function’s body. Here is a short description of the reduction function call grammar:
The reduction-operation is one of the keywords sum, min, max or mul. The voxel-declaration-list is a comma-separated list of voxel-declarations as defined for the volume predicate slang. The function-identifier is the name of a mapping function, and the arglist is the list of arguments for the mapping function.
This example shows a mapping function that returns the position of a voxel if the voxel’s value equals id. Using the min and max operation, this mapping function is used to calculate the bounding box of the region with id=1 in this example.
Copyright © 2015-2018 vislang.net