ImFusion SDK 4.3
ImFusion::ImageProcessing Namespace Reference

Low-level algorithms for image processing. More...

Detailed Description

Low-level algorithms for image processing.

Depending on the kind of processing algorithm, different overload sets are offered:

  • Algorithms that do not change the ImageDescriptor and can be implemented in-place offer only a single computeXYZ() variant, e.g. computeFlipped().
  • Algorithms that change the ImageDescriptor will never work in-place and offer two variants:
    • The createXYZ() variant will allocate a new image to store the result of the image processing algorithm.
    • The computeXYZ() variant will accept an additional output image that must already be allocated by the caller. This allows to minimize the number of needed allocations when the output image can be reused such as in streaming use cases for instance.

Algorithms that create output images of the same type than the input images offer two overloads: A strong TypedImage<T> overload as well as an overload taking the MemImage base class.

Enumerations

enum class  Axis { X = 0 , Y = 1 , Z = 2 }
 Enumeration of image axes for processing options. More...
 
enum class  ColorWeighting { Average = 0 , LumaBT601 = 1 , LumaBT709 = 2 }
 Enumeration for the methods used for converting color (3 channels) to grayscale image. More...
 
enum class  BayerPattern { BGGR = 0 , GBRG = 1 , GRGB = 2 , RGGB = 3 }
 Enumeration of bayer patterns https://docs.opencv.org/3.4/de/d25/imgproc_color_conversions.html.
 
enum  ThresholdingOptions {
  AcceptAboveOrEqual = 1 << 0 , AcceptBelow = 1 << 1 , AcceptInside = 1 << 2 , AcceptOutside = 1 << 3 ,
  UseStorageValues = 1 << 4 , UseOriginalValues = 1 << 5 , MergeChannels = 1 << 6
}
 Bitmask of options that can be passed to createThresholded() and computeThresholded(). More...
 
enum class  Normalization { None = 0 , TypeRange = 1 , ValueRange = 2 , ApplyShiftAndScale = 3 }
 List of available normlization options for createFloat(). More...
 
enum class  ValueDomain { StorageValues , OriginalValues }
 Enumeration of available pixel value domains, cf. Pixel Value Domains. More...
 

Functions

bool copyPixelData (const MemImage &src, const vec3i &srcOffset, MemImage &dst, const vec3i &dstOffset, const vec3i &size)
 Perform a copy of continuous raw image data between two images using all channels.
 
bool copyPixelData (const MemImage &src, const vec3i &srcPixelOffset, int srcChannelOffset, MemImage &dst, const vec3i &dstPixelOffset, int dstChannelOffset, const vec3i &size, int numChannels)
 Perform a copy of continuous raw image data between two images that can have different numbers of channels.
 
std::unique_ptr< TypedImage< unsigned char > > createRGBFromBayerPattern (MemImage &image, BayerPattern bayerPattern)
 convert Bayer Pattern Image to a color image
 
void computeFlipped (MemImage &image, Axis flipAxis)
 Flip the given image in-place.
 
void computeInverted (MemImage &image, bool useImageRange)
 Invert the pixel intensities of the given image in-place.
 
void computeClamped (MemImage &image, const vec2 &range, ValueDomain valueDomain)
 Clamp the image intensity of all pixels to the given range (in-place).
 
void swapEndianness (MemImage &image)
 Reverses the order of bytes for all pixels in the image pixel buffer.
 

Rotate images around their main axes

template<typename T>
std::unique_ptr< TypedImage< T > > createRotated (const TypedImage< T > &input, Axis rotationAxis, int angle, Axis flipAxis=Axis(-1))
 Create a rotated version of the input image.
 
std::unique_ptr< MemImagecreateRotated (const MemImage &input, Axis rotationAxis, int angle, Axis flipAxis=Axis(-1))
 Create a rotated version of the input image.
 
bool computeRotated (const MemImage &input, MemImage &output, Axis rotationAxis, int angle, Axis flipAxis=Axis(-1))
 Create a rotated version of the input image.
 
bool isOrthogonalRotationMatrix (const mat3 &rotationMatrix, double tolerance=0.0)
 Test whether the given matrix forms an orthogonal rotation matrix that can be passed to the corresponding overloads of createRotated() and computeRotated().
 
template<typename T>
std::unique_ptr< TypedImage< T > > createRotated (const TypedImage< T > &input, const mat3 &rotationMatrix, double tolerance=0.0)
 Create a rotated version of the input image.
 
std::unique_ptr< MemImagecreateRotated (const MemImage &input, const mat3 &rotationMatrix, double tolerance=0.0)
 Create a rotated version of the input image.
 
bool computeRotated (const MemImage &input, MemImage &output, const mat3 &rotationMatrix, double tolerance=0.0)
 Create a rotated version of the input image.
 

Crop/pad images

template<typename T>
std::unique_ptr< TypedImage< T > > createCropped (const TypedImage< T > &input, vec3i newSize, vec3i offset=vec3i(-1, -1, -1))
 Create a cropped version of the input image.
 
std::unique_ptr< MemImagecreateCropped (const MemImage &input, const vec3i &newSize, const vec3i &offset)
 Create a cropped version of the input image.
 
bool computeCropped (const MemImage &input, MemImage &output, const vec3i &offset=vec3i(-1, -1, -1))
 Create a cropped version of the input image.
 
template<typename T>
std::unique_ptr< TypedImage< T > > createPadded (const TypedImage< T > &input, PaddingMode paddingMode, const vec3i &paddingLLF, const vec3i &paddingURB, bool legacyMirrorPadding=true)
 Create a padded version of the input image where the additional border pixels have a specified value.
 
std::unique_ptr< MemImagecreatePadded (const MemImage &input, PaddingMode paddingMode, const vec3i &paddingLLF, const vec3i &paddingURB, bool legacyMirrorPadding=true)
 Create a padded version of the input image where the additional border pixels have a specified value.
 
bool computePadded (const MemImage &input, MemImage &output, PaddingMode paddingMode, const vec3i &paddingLLF, const vec3i &paddingURB, bool legacyMirrorPadding=true)
 Create a padded version of the input image where the additional border pixels have a specified value.
 

Resample images

template<typename T>
std::unique_ptr< TypedImage< T > > createDownsampled (const TypedImage< T > &input, int dx, int dy, int dz=1, bool zeroMask=false, ReductionMode reductionMode=ReductionMode::Average)
 Create a downsampled version of the input image, where the new image size is specified by an integer factor.
 
std::unique_ptr< MemImagecreateDownsampled (const MemImage &input, int dx, int dy, int dz=1, bool zeroMask=false, ReductionMode reductionMode=ReductionMode::Average)
 Create a downsampled version of the input image, where the new image size is specified by an integer factor.
 
bool computeDownsampled (const MemImage &input, MemImage &output, int dx, int dy, int dz=1, bool zeroMask=false, ReductionMode reductionMode=ReductionMode::Average)
 Create a downsampled version of the input image, where the new image size is specified by an integer factor.
 
template<typename T>
std::unique_ptr< TypedImage< T > > createResampledToSpacing (const TypedImage< T > &input, SpacingMode spacingAdjustment, const vec3 &spacing, bool zeroMask=false, ReductionMode reductionMode=ReductionMode::Average, InterpolationMode interpolationMode=InterpolationMode::Linear, bool allowDimensionChange=false)
 Create a resampled version of the input image with a dedicated target spacing.
 
std::unique_ptr< MemImagecreateResampledToSpacing (const MemImage &input, SpacingMode spacingAdjustment, const vec3 &spacing, bool zeroMask=false, ReductionMode reductionMode=ReductionMode::Average, InterpolationMode interpolationMode=InterpolationMode::Linear, bool allowDimensionChange=false)
 Create a resampled version of the input image with a dedicated target spacing.
 
bool computeResampledToSpacing (const MemImage &input, MemImage &output, SpacingMode spacingAdjustment, const vec3 &spacing, bool zeroMask=false, ReductionMode reductionMode=ReductionMode::Average, InterpolationMode interpolationMode=InterpolationMode::Linear, bool allowDimensionChange=false)
 Create a resampled version of the input image with a dedicated target spacing.
 
template<typename T>
std::unique_ptr< TypedImage< T > > createResampledToDimensions (const TypedImage< T > &input, const vec3i &dimensions, bool zeroMask=false, ReductionMode reductionMode=ReductionMode::Average, InterpolationMode interpolationMode=InterpolationMode::Linear)
 Create a resampled version of the input image with a dedicated target resolution.
 
std::unique_ptr< MemImagecreateResampledToDimensions (const MemImage &input, const vec3i &dimensions, bool zeroMask=false, ReductionMode reductionMode=ReductionMode::Average, InterpolationMode interpolationMode=InterpolationMode::Linear)
 Create a resampled version of the input image with a dedicated target resolution.
 
bool computeResampledToDimensions (const MemImage &input, MemImage &output, const vec3i &dimensions, bool zeroMask=false, ReductionMode reductionMode=ReductionMode::Average, InterpolationMode interpolationMode=InterpolationMode::Linear)
 Create a resampled version of the input image with a dedicated target resolution.
 

Binary thresholding based on pixel values

std::unique_ptr< TypedImage< unsigned char > > createThresholded (const MemImage &input, double value, Flags< ThresholdingOptions > options)
 Create a binary mask image based on the input image's pixel values.
 
bool computeThresholded (const MemImage &input, TypedImage< unsigned char > &output, double value, Flags< ThresholdingOptions > options)
 Create a binary mask image based on the input image's pixel values.
 
std::unique_ptr< TypedImage< unsigned char > > createThresholded (const MemImage &input, vec2 interval, Flags< ThresholdingOptions > options)
 Create a binary mask image based on the input image's pixel values.
 
bool computeThresholded (const MemImage &input, TypedImage< unsigned char > &output, vec2 interval, Flags< ThresholdingOptions > options)
 Create a binary mask image based on the input image's pixel values.
 

Change the pixel representation/format

template<typename InputT, typename OutputT>
std::unique_ptr< TypedImage< OutputT > > createConverted (const TypedImage< InputT > &input, std::optional< std::pair< InputT, InputT > > inputRange=std::nullopt, std::optional< std::pair< OutputT, OutputT > > outputRange=std::nullopt)
 Performs a type conversion from a TypedImage<InputT> to a newly created TypedImage<OutputT>.
 
template<typename OutputT>
std::unique_ptr< TypedImage< OutputT > > createConverted (const MemImage &input, std::optional< std::pair< double, double > > inputRange=std::nullopt, std::optional< std::pair< OutputT, OutputT > > outputRange=std::nullopt)
 Performs a type conversion from any MemImage to a newly created TypedImage<OutputT>.
 
std::unique_ptr< TypedImage< float > > createFloat (const MemImage &input, Normalization valueMapping)
 Create a floating point version of the input image.
 
bool createFloat (const MemImage &input, TypedImage< float > &output, Normalization valueMapping)
 Create a floating point version of the input image.
 
template<typename T>
std::unique_ptr< TypedImage< T > > createGrayscale (const TypedImage< T > &input, int numChannels=-1, ColorWeighting method=ColorWeighting::Average)
 Create a single-channel version of the input image by averaging pixel values over the first N (or all if -1) channels.
 
bool computeGrayscale (const MemImage &input, MemImage &output, int numChannels=-1, ColorWeighting method=ColorWeighting::Average)
 Create a single-channel version of the input image by averaging pixel values over first N (or all if -1) channels.
 
std::unique_ptr< MemImagecreateGrayscale (const MemImage &input, int numChannels=-1, ColorWeighting method=ColorWeighting::Average)
 Create a single-channel version of the input image by averaging pixel values over first N (or all if -1) channels.
 

Compute gradients

template<typename T>
void computeGradientMagnitude (const TypedImage< T > *img, TypedImage< float > *gradient, bool normalizeResult=true, TypedImage< float > *orientation=0)
 Compute normalized gradient magnitude using 3x3 Sobel filter.
 
template<typename T>
void computeGradient (const TypedImage< T > *img, TypedImage< float > *gx, TypedImage< float > *gy, TypedImage< float > *gNorm=0)
 
template<typename T>
void computeGradient2D (const TypedImage< T > *img, TypedImage< float > *gx, TypedImage< float > *gy)
 
template<typename T>
void computeGradient3D (const TypedImage< T > *img, TypedImage< float > *gx, TypedImage< float > *gy, TypedImage< float > *gz)
 
template<typename T>
std::unique_ptr< TypedImage< T > > addOrRemoveAlphaChannel (const TypedImage< T > &img)
 
std::unique_ptr< MemImageaddOrRemoveAlphaChannel (const MemImage &input)
 
void computeSubpixelEdgeLocationAndOrientation2D (const TypedImage< float > *g, const TypedImage< float > *gx, const TypedImage< float > *gy, float threshold, std::vector< std::pair< vec2, vec2 > > &location)
 
void computeSubpixelEdgeLocationAndOrientation3D (const TypedImage< float > *g, const TypedImage< float > *gx, const TypedImage< float > *gy, const TypedImage< float > *gz, float threshold, std::vector< std::pair< vec3, vec3 > > &location)
 

Enumeration Type Documentation

◆ Axis

enum class Axis
strong

Enumeration of image axes for processing options.

Enumerator

X axis.

Y axis.

Z axis.

◆ ColorWeighting

enum class ColorWeighting
strong

Enumeration for the methods used for converting color (3 channels) to grayscale image.

if the number of channels considered during the conversion is different to 3, then the Average is used independent of the user choice

Note
the problems of color averaging method can be found in: https://www.tutorialspoint.com/dip/grayscale_to_rgb_conversion.htm
opencv uses LumaBT601: https://docs.opencv.org/3.4/de/d25/imgproc_color_conversions.html
for more info about the difference between BT601 and BT709: https://en.wikipedia.org/wiki/Luma_(video)
Enumerator
Average 

Grayscale = R / 3 + G / 3 + B / 3.

LumaBT601 

Grayscale = 0.299R + 0.587G + 0.114B (used in opencv and most digital standard definition formats)

LumaBT709 

Grayscale = 0.2126R + 0.7152G + 0.0722B.

◆ ThresholdingOptions

Bitmask of options that can be passed to createThresholded() and computeThresholded().

Note
Not all combinations of options are valid.
Enumerator
AcceptAboveOrEqual 

All pixels above or equal to the threshold will be marked 1; only valid for the float overload.

AcceptBelow 

All pixels below the threshold will be marked 1; only valid for the float overload.

AcceptInside 

All pixels inside the closed interval will be marked 1; only valid for the vec2 overload.

AcceptOutside 

All pixels outside the closed interval will be marked 1; only valid for the vec2 overload.

UseStorageValues 

The value/interval parameter describes storage values.

UseOriginalValues 

The value/interval parameter describes original values.

MergeChannels 

Compute threshold value based on average intensity of all channels and return a single channel threshold image.

◆ Normalization

enum class Normalization
strong

List of available normlization options for createFloat().

Enumerator
None 

Do not perform any normalization, simply cast the pixel value to float.

TypeRange 

Use entire type range to normalize values to [0..1] range.

ValueRange 

Use minimum/maximum pixel intensity as normalization range;.

ApplyShiftAndScale 

Do not perform normalization but apply shift and scale to convert to original values.

◆ ValueDomain

enum class ValueDomain
strong

Enumeration of available pixel value domains, cf. Pixel Value Domains.

Enumerator
StorageValues 

Values as stored in memory.

OriginalValues 

Values as recorded in the original source if available (e.g. Hounsfield Units for CT images)

Function Documentation

◆ copyPixelData() [1/2]

bool copyPixelData ( const MemImage & src,
const vec3i & srcOffset,
MemImage & dst,
const vec3i & dstOffset,
const vec3i & size )

Perform a copy of continuous raw image data between two images using all channels.

The image sizes do not need to match, you can specify any subregion in both the source and destination image. If the specified region exceeds any of the input/output images' dimensions it will be clamped to fit. Both the image type and the number of channels of src and dst must match.

Parameters
srcSource image to copy data from
srcOffsetPixel offset in source subvolume to copy pixel data from
dstDestination image to copy data to
dstOffsetPixel offset in destination subvolume to copy pixel data to
sizeSize of subvolume to copy

◆ copyPixelData() [2/2]

bool copyPixelData ( const MemImage & src,
const vec3i & srcPixelOffset,
int srcChannelOffset,
MemImage & dst,
const vec3i & dstPixelOffset,
int dstChannelOffset,
const vec3i & size,
int numChannels )

Perform a copy of continuous raw image data between two images that can have different numbers of channels.

Neither the image sizes nor the number of channels do need to match, you can specify any subregion in both the source and destination image. If the specified regions exceed any of the input/output images' dimensions/number of channels they will be clamped to fit. The image type of src and dst must match.

Parameters
srcSource image to copy data from
srcPixelOffsetPixel offset in source subvolume to copy pixel data from
srcChannelOffsetFirst channel in source subvolume to copy channel data from for each pixel, must be >= 0
dstDestination image to copy data to
dstPixelOffsetPixel offset in destination subvolume to copy pixel data to
dstChannelOffsetFirst channel in destination subvolume to copy channel data to for each pixel, must be >= 0
sizeSize of subvolume to copy
numChannelsNumber of channels to copy for each pixel

◆ createRotated() [1/4]

template<typename T>
std::unique_ptr< TypedImage< T > > createRotated ( const TypedImage< T > & input,
Axis rotationAxis,
int angle,
Axis flipAxis = Axis(-1) )

Create a rotated version of the input image.

This function does only support orthogonal rotations.

Parameters
inputInput image, will not be modified
rotationAxisRotation axis to rotate around
angleRotation angle in degrees, must be a multiple of 90. A positive angle refers to a counter-clockwise rotation around the rotation axis. For more information about the coordinate system conventions see Coordinate Systems.
flipAxisOptional axis to perform an additional flip of the pixel data in.

◆ createRotated() [2/4]

std::unique_ptr< MemImage > createRotated ( const MemImage & input,
Axis rotationAxis,
int angle,
Axis flipAxis = Axis(-1) )

Create a rotated version of the input image.

This function only supports orthogonal rotations.

Parameters
inputInput image, will not be modified
rotationAxisRotation axis to rotate around
angleRotation angle in degrees, must be a multiple of 90 within the interval [-270, 270]. A positive angle refers to a counter-clockwise rotation around the rotation axis. For more information about the coordinate system conventions see Coordinate Systems.
flipAxisOptional axis to perform an additional flip of the pixel data.

◆ computeRotated() [1/2]

bool computeRotated ( const MemImage & input,
MemImage & output,
Axis rotationAxis,
int angle,
Axis flipAxis = Axis(-1) )

Create a rotated version of the input image.

This function only supports orthogonal rotations.

Parameters
inputInput image, will not be modified
outputUser provided output image, its descriptor must be compatible with the processing applied to the input image. In case it's not the function returns false.
rotationAxisRotation axis to rotate around
angleRotation angle in degrees, must be a multiple of 90 within the interval [-270, 270]. A positive angle refers to a counter-clockwise rotation around the rotation axis. For more information about the coordinate system conventions see Coordinate Systems.
flipAxisOptional axis to perform an additional flip of the pixel data.

◆ isOrthogonalRotationMatrix()

bool isOrthogonalRotationMatrix ( const mat3 & rotationMatrix,
double tolerance = 0.0 )

Test whether the given matrix forms an orthogonal rotation matrix that can be passed to the corresponding overloads of createRotated() and computeRotated().

Parameters
rotationMatrixRotation matrix to decompose, will fail if not orthogonal.
toleranceMaximum allowable deviation of the euler angles from an orthogonal configuration in degrees.

◆ createRotated() [3/4]

template<typename T>
std::unique_ptr< TypedImage< T > > createRotated ( const TypedImage< T > & input,
const mat3 & rotationMatrix,
double tolerance = 0.0 )

Create a rotated version of the input image.

This function does only support 3D volumes and orthogonal rotations.

Parameters
inputInput image, will not be modified
rotationMatrixRotation matrix to apply, must be orthogonal.
toleranceMaximum allowable deviation of the euler angles from an orthogonal configuration in degrees.

◆ createRotated() [4/4]

std::unique_ptr< MemImage > createRotated ( const MemImage & input,
const mat3 & rotationMatrix,
double tolerance = 0.0 )

Create a rotated version of the input image.

This function does only support 3D volumes and orthogonal rotations.

Parameters
inputInput image, will not be modified
rotationMatrixRotation matrix to apply, must be orthogonal.
toleranceMaximum allowable deviation of the euler angles from an orthogonal configuration in degrees.

◆ computeRotated() [2/2]

bool computeRotated ( const MemImage & input,
MemImage & output,
const mat3 & rotationMatrix,
double tolerance = 0.0 )

Create a rotated version of the input image.

This function does only support 3D volumes and orthogonal rotations.

Parameters
inputInput image, will not be modified
outputUser provided output image, its descriptor must be compatible with the processing applied to the input image. In case it's not the function returns false.
rotationMatrixRotation matrix to apply, must be orthogonal.
toleranceMaximum allowable deviation of the euler angles from an orthogonal configuration in degrees.

◆ createCropped() [1/2]

template<typename T>
std::unique_ptr< TypedImage< T > > createCropped ( const TypedImage< T > & input,
vec3i newSize,
vec3i offset = vec3i(-1, -1, -1) )

Create a cropped version of the input image.

Parameters
inputInput image, will not be modified
newSizeSize of the cropped image
offsetPixel offset of cropping region in input image. An offset of -1 will keep put the cropping region in the center of the corresponding axis.

◆ createCropped() [2/2]

std::unique_ptr< MemImage > createCropped ( const MemImage & input,
const vec3i & newSize,
const vec3i & offset )

Create a cropped version of the input image.

Parameters
inputInput image, will not be modified
newSizeSize of the cropped image
offsetPixel offset of cropping region in input image. An offset of -1 will keep put the cropping region in the center of the corresponding axis.

◆ computeCropped()

bool computeCropped ( const MemImage & input,
MemImage & output,
const vec3i & offset = vec3i(-1, -1, -1) )

Create a cropped version of the input image.

Parameters
inputInput image, will not be modified
outputUser provided output image, its descriptor is used for the cropping dimensions.
offsetPixel offset of cropping region in input image. An offset of -1 will keep put the cropping region in the center of the corresponding axis.

◆ createPadded() [1/2]

template<typename T>
std::unique_ptr< TypedImage< T > > createPadded ( const TypedImage< T > & input,
PaddingMode paddingMode,
const vec3i & paddingLLF,
const vec3i & paddingURB,
bool legacyMirrorPadding = true )

Create a padded version of the input image where the additional border pixels have a specified value.

Parameters
inputInput image, will not be modified
paddingModePadding mode specifying what pixel values to assign to the additional border pixels
paddingLLFNumber of padding pixels in X, Y, and Z direction at the lower left front corner.
paddingURBNumber of padding pixels in X, Y, and Z direction at the upper right back corner.
legacyMirrorPaddingBefore SUITE-3748, mirror padding was not computed correctly on URB side. This flag allows to continue use the wrong definition of mirror padding to avoid regressions. Note: this is a temporary parameter and will be deprecated/removed soon.

◆ createPadded() [2/2]

std::unique_ptr< MemImage > createPadded ( const MemImage & input,
PaddingMode paddingMode,
const vec3i & paddingLLF,
const vec3i & paddingURB,
bool legacyMirrorPadding = true )

Create a padded version of the input image where the additional border pixels have a specified value.

Parameters
inputInput image, will not be modified
paddingModePadding mode specifying what pixel values to assign to the additional border pixels
paddingLLFNumber of padding pixels in X, Y, and Z direction at the lower left front corner.
paddingURBNumber of padding pixels in X, Y, and Z direction at the upper right back corner.
legacyMirrorPaddingBefore SUITE-3748, mirror padding was not computed correctly on URB side. This flag allows to continue use the wrong definition of mirror padding to avoid regressions. Note: this is a temporary parameter and will be deprecated/removed soon.

◆ computePadded()

bool computePadded ( const MemImage & input,
MemImage & output,
PaddingMode paddingMode,
const vec3i & paddingLLF,
const vec3i & paddingURB,
bool legacyMirrorPadding = true )

Create a padded version of the input image where the additional border pixels have a specified value.

Parameters
inputInput image, will not be modified
outputUser provided output image, its descriptor must be compatible with the processing applied to the input image. In case it's not the function returns false.
paddingModePadding mode specifying what pixel values to assign to the additional border pixels
paddingLLFNumber of padding pixels in X, Y, and Z direction at the lower left front corner.
paddingURBNumber of padding pixels in X, Y, and Z direction at the upper right back corner.
legacyMirrorPaddingBefore SUITE-3748, mirror padding was not computed correctly on URB side. This flag allows to continue use the wrong definition of mirror padding to avoid regressions. Note: this is a temporary parameter and will be deprecated/removed soon.

◆ createDownsampled() [1/2]

template<typename T>
std::unique_ptr< TypedImage< T > > createDownsampled ( const TypedImage< T > & input,
int dx,
int dy,
int dz = 1,
bool zeroMask = false,
ReductionMode reductionMode = ReductionMode::Average )

Create a downsampled version of the input image, where the new image size is specified by an integer factor.

Parameters
inputInput image, will not be modified
dxDownsampling factor in X direction
dyDownsampling factor in Y direction
dzDownsampling factor in Z direction
zeroMaskIf enabled zeros are propagated to avoid masking artifacts
reductionModeFilter mode defining how contributing input pixels are combined into the downsampled pixel value

◆ createDownsampled() [2/2]

std::unique_ptr< MemImage > createDownsampled ( const MemImage & input,
int dx,
int dy,
int dz = 1,
bool zeroMask = false,
ReductionMode reductionMode = ReductionMode::Average )

Create a downsampled version of the input image, where the new image size is specified by an integer factor.

Parameters
inputInput image, will not be modified
dxDownsampling factor in X direction
dyDownsampling factor in Y direction
dzDownsampling factor in Z direction
zeroMaskIf enabled, zeros are always propagated (independent of reduction mode) to avoid masking artifacts
reductionModeFilter mode defining how contributing input pixels are combined into the downsampled pixel value

◆ computeDownsampled()

bool computeDownsampled ( const MemImage & input,
MemImage & output,
int dx,
int dy,
int dz = 1,
bool zeroMask = false,
ReductionMode reductionMode = ReductionMode::Average )

Create a downsampled version of the input image, where the new image size is specified by an integer factor.

Parameters
inputInput image, will not be modified
outputUser provided output image, its descriptor must be compatible with the processing applied to the input image. In case it's not the function returns false.
dxDownsampling factor in X direction
dyDownsampling factor in Y direction
dzDownsampling factor in Z direction
zeroMaskIf enabled, zeros are always propagated (independent of reduction mode) to avoid masking artifacts
reductionModeFilter mode defining how contributing input pixels are combined into the downsampled pixel value

◆ createResampledToSpacing() [1/2]

template<typename T>
std::unique_ptr< TypedImage< T > > createResampledToSpacing ( const TypedImage< T > & input,
SpacingMode spacingAdjustment,
const vec3 & spacing,
bool zeroMask = false,
ReductionMode reductionMode = ReductionMode::Average,
InterpolationMode interpolationMode = InterpolationMode::Linear,
bool allowDimensionChange = false )

Create a resampled version of the input image with a dedicated target spacing.

Parameters
inputInput image, will not be modified
spacingAdjustmentIf set to ADJUST, resampling is performed to roughly the desired spacing so that the image extent is kept constant. Otherwise, the exact spacing defined will be used, leading to a potentially different extent.
spacingTarget spacing of the resampled image
zeroMaskIf enabled, zeros are always propagated (independent of reduction mode) to avoid masking artifacts
reductionModeFilter mode defining how contributing input pixels are combined into the downsampled pixel value
interpolationModeInterpolation mode for pixel lookup in input image
allowDimensionChangeIf true, 3D images may become 2D images, etc.

◆ createResampledToSpacing() [2/2]

std::unique_ptr< MemImage > createResampledToSpacing ( const MemImage & input,
SpacingMode spacingAdjustment,
const vec3 & spacing,
bool zeroMask = false,
ReductionMode reductionMode = ReductionMode::Average,
InterpolationMode interpolationMode = InterpolationMode::Linear,
bool allowDimensionChange = false )

Create a resampled version of the input image with a dedicated target spacing.

Parameters
inputInput image, will not be modified
spacingAdjustmentIf set to ADJUST, resampling is performed to roughly the desired spacing so that the image extent is kept constant. Otherwise, the exact spacing defined will be used, leading to a potentially different extent.
spacingTarget spacing of the resampled image
zeroMaskIf enabled, zeros are always propagated (independent of reduction mode) to avoid masking artifacts
reductionModeFilter mode defining how contributing input pixels are combined into the downsampled pixel value
interpolationModeInterpolation mode for pixel lookup in input image
allowDimensionChangeIf true, 3D images may become 2D images, etc.

◆ computeResampledToSpacing()

bool computeResampledToSpacing ( const MemImage & input,
MemImage & output,
SpacingMode spacingAdjustment,
const vec3 & spacing,
bool zeroMask = false,
ReductionMode reductionMode = ReductionMode::Average,
InterpolationMode interpolationMode = InterpolationMode::Linear,
bool allowDimensionChange = false )

Create a resampled version of the input image with a dedicated target spacing.

Parameters
inputInput image, will not be modified
outputUser provided output image, its descriptor must be compatible with the processing applied to the input image. In case it's not the function returns false.
spacingAdjustmentIf set to ADJUST, resampling is performed to roughly the desired spacing so that the image extent is kept constant. Otherwise, the exact spacing defined will be used, leading to a potentially different extent.
spacingTarget spacing of the resampled image
zeroMaskIf enabled, zeros are always propagated (independent of reduction mode) to avoid masking artifacts
reductionModeFilter mode defining how contributing input pixels are combined into the downsampled pixel value
interpolationModeInterpolation mode for pixel lookup in input image
allowDimensionChangeIf true, 3D images may become 2D images, etc.

◆ createResampledToDimensions() [1/2]

template<typename T>
std::unique_ptr< TypedImage< T > > createResampledToDimensions ( const TypedImage< T > & input,
const vec3i & dimensions,
bool zeroMask = false,
ReductionMode reductionMode = ReductionMode::Average,
InterpolationMode interpolationMode = InterpolationMode::Linear )

Create a resampled version of the input image with a dedicated target resolution.

Parameters
inputInput image, will not be modified
dimensionsTarget pixel dimensions of resampled image
zeroMaskIf enabled, zeros are always propagated (independent of reduction mode) to avoid masking artifacts
reductionModeFilter mode defining how contributing input pixels are combined into the downsampled pixel value
interpolationModeInterpolation mode for pixel lookup in input image

◆ createResampledToDimensions() [2/2]

std::unique_ptr< MemImage > createResampledToDimensions ( const MemImage & input,
const vec3i & dimensions,
bool zeroMask = false,
ReductionMode reductionMode = ReductionMode::Average,
InterpolationMode interpolationMode = InterpolationMode::Linear )

Create a resampled version of the input image with a dedicated target resolution.

Parameters
inputInput image, will not be modified
dimensionsTarget pixel dimensions of resampled image
zeroMaskIf enabled, zeros are always propagated (independent of reduction mode) to avoid masking artifacts
reductionModeFilter mode defining how contributing input pixels are combined into the downsampled pixel value
interpolationModeInterpolation mode for pixel lookup in input image

◆ computeResampledToDimensions()

bool computeResampledToDimensions ( const MemImage & input,
MemImage & output,
const vec3i & dimensions,
bool zeroMask = false,
ReductionMode reductionMode = ReductionMode::Average,
InterpolationMode interpolationMode = InterpolationMode::Linear )

Create a resampled version of the input image with a dedicated target resolution.

Parameters
inputInput image, will not be modified
outputUser provided output image, its descriptor must be compatible with the processing applied to the input image. In case it's not the function returns false.
dimensionsTarget pixel dimensions of resampled image
zeroMaskIf enabled, zeros are always propagated (independent of reduction mode) to avoid masking artifacts
reductionModeFilter mode defining how contributing input pixels are combined into the downsampled pixel value
interpolationModeInterpolation mode for pixel lookup in input image

◆ createThresholded() [1/2]

std::unique_ptr< TypedImage< unsigned char > > createThresholded ( const MemImage & input,
double value,
Flags< ThresholdingOptions > options )

Create a binary mask image based on the input image's pixel values.

Parameters
inputInput image, will not be modified
valueCutoff value for thresholding, either in storage or in original value domain depending on options.
optionsSet of thresholding options, must meet the following conditions
  • Contains either AcceptAboveOrEqual or AcceptBelow
  • Contains either UseStorageValues or UseOriginalValues
  • Does not contain AcceptInside or AcceptOutside
  • Can contain any combination of the other options

◆ computeThresholded() [1/2]

bool computeThresholded ( const MemImage & input,
TypedImage< unsigned char > & output,
double value,
Flags< ThresholdingOptions > options )

Create a binary mask image based on the input image's pixel values.

Parameters
inputInput image, will not be modified
outputUser provided output image, its descriptor must be compatible with that of the input image. In case it's not the function returns false.
valueCutoff value for thresholding, either in storage or in original value domain depending on options.
optionsSet of thresholding options, must meet the following conditions
  • Contains either AcceptAboveOrEqual or AcceptBelow
  • Contains either UseStorageValues or UseOriginalValues
  • Does not contain AcceptInside or AcceptOutside
  • Can contain any combination of the other options

◆ createThresholded() [2/2]

std::unique_ptr< TypedImage< unsigned char > > createThresholded ( const MemImage & input,
vec2 interval,
Flags< ThresholdingOptions > options )

Create a binary mask image based on the input image's pixel values.

Parameters
inputInput image, will not be modified
intervalClosed interval describing the value range for thresholding, either in storage or in original value domain depending on options.
optionsSet of thresholding options, must meet the following conditions
  • Contains either AcceptInside or AcceptOutside
  • Contains either UseStorageValues or UseOriginalValues
  • Does not contain AcceptAboveOrEqual or AcceptBelow
  • Can contain any combination of the other options

◆ computeThresholded() [2/2]

bool computeThresholded ( const MemImage & input,
TypedImage< unsigned char > & output,
vec2 interval,
Flags< ThresholdingOptions > options )

Create a binary mask image based on the input image's pixel values.

Parameters
inputInput image, will not be modified
outputUser provided output image, its descriptor must be compatible with that of the input image. In case it's not the function returns false.
intervalClosed interval describing the value range for thresholding, either in storage or in original value domain depending on options.
optionsSet of thresholding options, must meet the following conditions
  • Contains either AcceptInside or AcceptOutside
  • Contains either UseStorageValues or UseOriginalValues
  • Does not containAcceptAboveOrEqual or AcceptBelow
  • Can contain any combination of the other options

◆ createRGBFromBayerPattern()

std::unique_ptr< TypedImage< unsigned char > > createRGBFromBayerPattern ( MemImage & image,
BayerPattern bayerPattern )

convert Bayer Pattern Image to a color image

Parameters
imageBayer pattern Image to be converted to RGB, should be a grayscale unsigned 8 bit image
BayerPatternthe Bayer pattern of the input image
Returns
return a pointer to the result image (8 bit RGB image), nullptr in case of failure

◆ computeFlipped()

void computeFlipped ( MemImage & image,
Axis flipAxis )

Flip the given image in-place.

Parameters
imageImage to flip
flipAxisFlip axis

◆ computeInverted()

void computeInverted ( MemImage & image,
bool useImageRange )

Invert the pixel intensities of the given image in-place.

Parameters
imageImage to invert
useImageRangeIf true, the output values will be such that the new image minimum will be equal to the old image maximum (and vice versa). Otherwise the full range of the image type will be used to invert the values.

◆ computeClamped()

void computeClamped ( MemImage & image,
const vec2 & range,
ValueDomain valueDomain )

Clamp the image intensity of all pixels to the given range (in-place).

Parameters
imageInput image, will be changed
rangeValue range to which to clamp the image pixels.
valueDomainPixel value domain in which range is specified, cf. Pixel Value Domains.

◆ createConverted() [1/2]

template<typename InputT, typename OutputT>
std::unique_ptr< TypedImage< OutputT > > createConverted ( const TypedImage< InputT > & input,
std::optional< std::pair< InputT, InputT > > inputRange = std::nullopt,
std::optional< std::pair< OutputT, OutputT > > outputRange = std::nullopt )

Performs a type conversion from a TypedImage<InputT> to a newly created TypedImage<OutputT>.

The pixel values are adjusted linearly so that inputRange.first is mapped to outputRange.first and inputRange.second is mapped to outputRange.second. Shift and scale of the resulting ImageDescriptor are adjusted accordingly so that the original/real-world values remain the same.

Note
If both InputT and OutputT are integral types and the outputRange is larger than the inputRange this function will truncate any floating-point scaling factor between the two to an integer one in order to avoid a re-quantization of the input values. In this case inputRange.second is mapped to the largest value less or equal than outputRange.second so that outputRange/inputRange is an integer division.
Parameters
inputInput image to convert to a different type.
inputRangeStorage pixel value range of input that should be mapped to outputRange If unset, will use {MIN_T, MAX_T} for integral types and {0.0, 1.0} for floating point types.
outputRangeStorage pixel value range of the return value to which pixels from inputRange are mapped to. If unset, will use {MIN_T, MAX_T} for integral types and {0.0, 1.0} for floating point types.

◆ createConverted() [2/2]

template<typename OutputT>
std::unique_ptr< TypedImage< OutputT > > createConverted ( const MemImage & input,
std::optional< std::pair< double, double > > inputRange = std::nullopt,
std::optional< std::pair< OutputT, OutputT > > outputRange = std::nullopt )

Performs a type conversion from any MemImage to a newly created TypedImage<OutputT>.

The pixel values are adjusted linearly so that inputRange.first is mapped to outputRange.first and inputRange.second is mapped to outputRange.second. Shift and scale of the resulting ImageDescriptor are adjusted accordingly so that the original/real-world values remain the same.

Note
If both InputT and OutputT are integral types and the outputRange is larger than the inputRange this function will truncate any floating-point scaling factor between the two to an integer one in order to avoid a re-quantization of the input values. In this case inputRange.second is mapped to the largest value less or equal than outputRange.second so that outputRange/inputRange it is an integer division.
Parameters
inputInput image to convert to a different type.
inputRangeStorage pixel value range of input that should be mapped to outputRange If unset, will use {MIN_T, MAX_T} for integral types and {0.0, 1.0} for floating point types.
outputRangeStorage pixel value range of the return value to which pixels from inputRange are mapped to. If unset, will use {MIN_T, MAX_T} for integral types and {0.0, 1.0} for floating point types.

◆ createFloat() [1/2]

std::unique_ptr< TypedImage< float > > createFloat ( const MemImage & input,
Normalization valueMapping )

Create a floating point version of the input image.

Parameters
inputInput image, will not be modified
valueMappingDefines how input pixel intensities are mapped to float

◆ createFloat() [2/2]

bool createFloat ( const MemImage & input,
TypedImage< float > & output,
Normalization valueMapping )

Create a floating point version of the input image.

Parameters
inputInput image, will not be modified
outputUser provided output image, its descriptor must be compatible with that of the input image. In case it's not the function returns false.
valueMappingDefines how input pixel intensities are mapped to float

◆ createGrayscale() [1/2]

template<typename T>
std::unique_ptr< TypedImage< T > > createGrayscale ( const TypedImage< T > & input,
int numChannels = -1,
ColorWeighting method = ColorWeighting::Average )

Create a single-channel version of the input image by averaging pixel values over the first N (or all if -1) channels.

Parameters
inputInput image, will not be modified
numChannelsNumber of channels to be considered
methodThe method used for computing the grayscale values, fall back to Averaging if the number of channels is != 3

◆ computeGrayscale()

bool computeGrayscale ( const MemImage & input,
MemImage & output,
int numChannels = -1,
ColorWeighting method = ColorWeighting::Average )

Create a single-channel version of the input image by averaging pixel values over first N (or all if -1) channels.

Parameters
inputInput image, will not be modified
outputUser provided output image, its descriptor must be compatible with the processing applied to the input image. In case it's not the function returns false.
numChannelsNumber of channels to be considered
methodThe method used for computing the grayscale values, fall back to Averaging if the number of channels is != 3

◆ createGrayscale() [2/2]

std::unique_ptr< MemImage > createGrayscale ( const MemImage & input,
int numChannels = -1,
ColorWeighting method = ColorWeighting::Average )

Create a single-channel version of the input image by averaging pixel values over first N (or all if -1) channels.

Parameters
inputInput image, will not be modified
numChannelsNumber of channels to be considered
methodThe method used for computing the grayscale values, fall back to Averaging if the number of channels is != 3

◆ computeGradientMagnitude()

template<typename T>
void computeGradientMagnitude ( const TypedImage< T > * img,
TypedImage< float > * gradient,
bool normalizeResult = true,
TypedImage< float > * orientation = 0 )

Compute normalized gradient magnitude using 3x3 Sobel filter.

The border of the image is set to zero.

Parameters
imgInput image
[out]gradientGradient image. Has to be float type.
normalizeResultNormalize result to range [0;1]
[out]orientationOptional pointer to orientation image receiving gradient orientation
Search Tab / S to search, Esc to close