ImFusion C++ SDK 4.5.0
ImFusion::ImageDescriptorUtils Namespace Reference

Collection of functions for pixel grid aligned cropping Utilities to build pixel-aligned ImageDescriptorWorld regions: crops from axis-aligned bounds (world or pixel coordinates) and resampling to new voxel spacing while remaining aligned with the input volume’s pixel grid. More...

Detailed Description

Collection of functions for pixel grid aligned cropping Utilities to build pixel-aligned ImageDescriptorWorld regions: crops from axis-aligned bounds (world or pixel coordinates) and resampling to new voxel spacing while remaining aligned with the input volume’s pixel grid.

Functions

std::optional< ImageDescriptorWorldgridAlignedCropWorld (const ImageDescriptorWorld &input, const Geometry::AlignedBox &boundsWorld, double paddingWorld=0)
 Creates a descriptor for the smallest pixel grid aligned sub-volume that fully contains the given world axis-aligned box, relative to input.
std::optional< ImageDescriptorWorldgridAlignedCropPixel (const ImageDescriptorWorld &input, const Geometry::AlignedBox &boundsPixel, int paddingPx=0)
 Creates a descriptor for a pixel-aligned crop from bounds expressed in input’s pixel coordinates (same indexing as ImageDescriptorWorld::worldToPixel / ImageDescriptorWorld::pixelToWorld).
std::optional< ImageDescriptorWorldgridAlignedResample (const ImageDescriptorWorld &input, const vec3 &newSpacing, std::optional< Geometry::AlignedBox > boundsPixel=std::nullopt)
 After optionally restricting to a grid sub-volume, resamples the pixel grid according to newSpacing.
std::optional< ImageDescriptorWorldgridAlignedResampleInteger (const ImageDescriptorWorld &input, const vec3 &approxNewSpacing, std::optional< Geometry::AlignedBox > boundsPixel=std::nullopt)
 Like gridAlignedResample, but chooses a spacing that is an integer multiple or divisor of the original spacing (so that input and output grid are guaranteed to have the same bounds), as close as possible to approxNewSpacing.

Function Documentation

◆ gridAlignedCropWorld()

std::optional< ImageDescriptorWorld > ImFusion::ImageDescriptorUtils::gridAlignedCropWorld ( const ImageDescriptorWorld & input,
const Geometry::AlignedBox & boundsWorld,
double paddingWorld = 0 )

Creates a descriptor for the smallest pixel grid aligned sub-volume that fully contains the given world axis-aligned box, relative to input.

Padding expands the box symmetrically in world units before conversion to pixels.

Parameters
inputThe input descriptor.
boundsWorldThe axis-aligned box in world coordinates.
paddingWorldOptional, non-negative extra margin added on each side along each axis (world units).
Returns
Descriptor for the crop, or std::nullopt, in case of invalid input.

◆ gridAlignedCropPixel()

std::optional< ImageDescriptorWorld > ImFusion::ImageDescriptorUtils::gridAlignedCropPixel ( const ImageDescriptorWorld & input,
const Geometry::AlignedBox & boundsPixel,
int paddingPx = 0 )

Creates a descriptor for a pixel-aligned crop from bounds expressed in input’s pixel coordinates (same indexing as ImageDescriptorWorld::worldToPixel / ImageDescriptorWorld::pixelToWorld).

The output keeps the input spacing.

Parameters
inputThe input descriptor.
boundsPixelAxis-aligned box in pixel coordinates of input.
paddingPxInteger offset added to the bounds before cropping.
Returns
Descriptor for the crop, or std::nullopt, in case of invalid input.

◆ gridAlignedResample()

std::optional< ImageDescriptorWorld > ImFusion::ImageDescriptorUtils::gridAlignedResample ( const ImageDescriptorWorld & input,
const vec3 & newSpacing,
std::optional< Geometry::AlignedBox > boundsPixel = std::nullopt )

After optionally restricting to a grid sub-volume, resamples the pixel grid according to newSpacing.

If the new and old spacings are not integer multiples of each other, the output grid borders will slightly overshoot the input grid ones. i.e. the output grid will have the minimum amount of pixels (with the new spacing) to fully enclose the input grid.

Parameters
inputThe input descriptor.
newSpacingNew voxel spacing along each axis (same units as input’s spacing).
boundsPixelIf set, crop to this pixel-space axis-aligned box first; if not set, uses the full index range [0, dim-1] on each axis.
Returns
Descriptor with updated spacing and dimensions, or std::nullopt, in case of invalid input.

◆ gridAlignedResampleInteger()

std::optional< ImageDescriptorWorld > ImFusion::ImageDescriptorUtils::gridAlignedResampleInteger ( const ImageDescriptorWorld & input,
const vec3 & approxNewSpacing,
std::optional< Geometry::AlignedBox > boundsPixel = std::nullopt )

Like gridAlignedResample, but chooses a spacing that is an integer multiple or divisor of the original spacing (so that input and output grid are guaranteed to have the same bounds), as close as possible to approxNewSpacing.

Parameters
inputThe input descriptor.
approxNewSpacingTarget voxel spacing along each axis (same units as input’s spacing).
boundsPixelIf set, crop to this pixel-space axis-aligned box first; if not set, uses the full index range [0, dim-1] on each axis.
Returns
Descriptor with updated spacing and dimensions, or std::nullopt, in case of invalid input.
Search Tab / S to search, Esc to close