Classes
mirtk::ForEachVoxelDomain Namespace Reference

Classes

struct  AboveBackgroundLevel
 
struct  Background
 
struct  BackgroundValue
 
struct  Foreground
 
struct  InMask
 
struct  InSpatialMask
 
struct  NotBackgroundValue
 

Detailed Description

Types which implement inside/outside image domain checks

This namespace defines auxiliary types which implement inside/outside image domain checks for voxels as static methods. These types can be used as Domain template argument as used by the ForEachVoxelIf and ParallelForEachVoxelIf template functions to restrict the evaluation of the voxel function to a specific subdomain of the image(s). Moreover, if it is known how the subdomain is defined, e.g., by a binary mask, a background value, a lower foreground threshold, or an interpolation domain, a specialized inside/outside domain check is more efficient as it only needs to test one particular condition. The more generic default domain check has to evaluate multiple conditions to first decide how the domain is being defined and then evaluate the actual inside/outside condition for this domain. This requires multiple if-statements and can be expensive when all these if-statements have to be evaluated for each voxel. Therefore, whenever possible use a specialized domain check to focus on the condition that matters.

Example:

#include "mirtk/GenericImage.h"
#include "mirtk/VoxelFunction.h"
#include "mirtk/VoxelDomain.h"
namespace mirtk {
void ProcessImageVoxelByVoxel(GreyImage &image)
{
using namespace ForEachVoxelDomain;
ForEachVoxelIf<AboveBackgroundLevel>(image, func);
}
} // namespace mirtk
Note
The last image passed to ForEachVoxelIf/ParallelForEachVoxelIf is the one which defines the image domain over which to iterate as it is often an output image. Therefore, this last image is passed on to the domain checks defined within the ImageDomain namespace.