Skip to content

shapeworks::Image

Module: Image Classes

More...

#include <Image.h>

Public Types

Name
enum InterpolationType
using float PixelType
using itk::Image< PixelType, 3 > ImageType
using itk::StatisticsImageFilter< ImageType >::Pointer StatsPtr
using itk::ImageRegionIterator< ImageType > ImageIterator
using itk::LinearInterpolateImageFunction< ImageType, Image::PixelType > InterpolatorType

Public Functions

Name
Image(const Dims dims)
Image(const std::string & pathname)
Image(ImageType::Pointer imagePtr)
Image(const vtkSmartPointer< vtkImageData > vtkImage)
Image(Image && img)
Image(const Image & img)
Image & operator=(const Image & img)
Image & operator=(Image && img)
lvalue assignment operator
operator ImageType::Pointer()
rvalue assignment operator
ImageType::Pointer getITKImage() const
vtkSmartPointer< vtkImageData > getVTKImage() const
creates a VTK filter for the given image
Image & operator-()
negation operator
Image operator+(const Image & other) const
plus operator to add two images
Image & operator+=(const Image & other)
Image operator-(const Image & other) const
minus operator to add two images
Image & operator-=(const Image & other)
Image operator*(const Image & other) const
multiply operator to multiply two images
Image operator*(const PixelType x) const
multiply operator to scale contents of an image
Image & operator*=(const PixelType x)
Image operator/(const PixelType x) const
divide operator to scale contents of an image
Image & operator/=(const PixelType x)
Image operator+(const PixelType x) const
plus operator to shift contents of an image
Image & operator+=(const PixelType x)
Image operator-(const PixelType x) const
minus operator to shift contents of an image
Image & operator-=(const PixelType x)
Image & antialias(unsigned iterations =50, double maxRMSErr =0.01f, int layers =3)
antialiases image
Image & recenter()
Image & resample(const TransformPtr transform, const Point3 origin, const Dims dims, const Vector3 spacing, const ImageType::DirectionType direction, InterpolationType interp =NearestNeighbor)
Image & resample(const Vector & physicalSpacing, InterpolationType interp =Linear)
resamples image using new physical spacing, updating logical dims to keep all image data for this spacing
Image & resample(double isoSpacing =1.0, InterpolationType interp =Linear)
resamples image using isotropic physical spacing
Image & resize(Dims logicalDims, InterpolationType interp =Linear)
Image & pad(int padding, PixelType value =0.0)
pads an image by same number of voxels in all directions with constant value
Image & pad(int padx, int pady, int padz, PixelType value =0.0)
pads an image by desired number of voxels in each direction with constant value
Image & pad(IndexRegion & region, PixelType value =0.0)
pads an image to include the given region with constant value
Image & translate(const Vector3 & v)
helper to simply translate image
Image & scale(const Vector3 & v)
helper to simply scale image around center (not origin)
Image & rotate(const double angle, const Vector3 & axis)
helper to simply rotate around axis through center (not origin) by given angle (in radians)
Image & rotate(const double angle, Axis axis)
helper to simply rotate around axis through center (not origin) by given angle (in radians)
TransformPtr createCenterOfMassTransform()
creates a transform that translates center of mass to center of image
TransformPtr createRigidRegistrationTransform(const Image & target_dt, float isoValue =0.0, unsigned iterations =20)
Image & applyTransform(const TransformPtr transform, InterpolationType interp =Linear)
applies the given transformation to the image by using resampling filter
Image & applyTransform(const TransformPtr transform, const Point3 origin, const Dims dims, const Vector3 spacing, const ImageType::DirectionType direction, InterpolationType interp =NearestNeighbor)
Image & extractLabel(const PixelType label =1.0)
Image & closeHoles(const PixelType foreground =0.0)
closes holes in a given volume, default foreground value assumes a binary volume
Image & binarize(PixelType minVal =0.0, PixelType maxVal =std::numeric_limits< PixelType >::max(), PixelType innerVal =1.0, PixelType outerVal =0.0)
threholds image into binary label based on upper and lower intensity bounds given by user
Image & computeDT(PixelType isoValue =0.0)
computes distance transform volume from a (preferably antialiased) binary image using the specified isovalue
Image & applyCurvatureFilter(unsigned iterations =10)
denoises an image using curvature driven flow using curvature flow image filter
Image & applyGradientFilter()
computes gradient magnitude at each pixel using gradient magnitude filter
Image & applySigmoidFilter(double alpha =10.0, double beta =10.0)
computes sigmoid function pixel-wise using sigmoid image filter
Image & applyTPLevelSetFilter(const Image & featureImage, double scaling =20.0)
segements structures in images using topology preserving geodesic active contour level set filter
Image & topologyPreservingSmooth(float scaling =20.0, float sigmoidAlpha =10.5, float sigmoidBeta =10.0)
Image & applyIntensityFilter(double minVal, double maxVal)
applies intensity windowing image filter
Image & gaussianBlur(double sigma =0.0)
applies gaussian blur with given sigma
Image & crop(PhysicalRegion region, const int padding =0)
crops the image down to the given region, with optional padding added
Image & clip(const Plane plane, const PixelType val =0.0)
clips an image using a cutting plane
Image & reflect(const Axis & axis)
Image & setOrigin(Point3 origin =Point3({0, 0, 0}))
sets the image origin in physical space to the given value
Image & setSpacing(Vector3 spacing)
sets the image spacing to the given value
Image & setCoordsys(ImageType::DirectionType coordsys)
sets the coordinate system in which this image lives in physical space
Image & isolate()
isolate the largest object in a binary segmentation
Dims dims() const
logical dimensions of the image
Point3 size() const
physical dimensions of the image (dims * spacing)
Vector spacing() const
physical spacing of the image
Point3 origin() const
physical coordinates of image origin
Point3 center() const
physical coordinates of center of this image
ImageType::DirectionType coordsys() const
return coordinate system in which this image lives in physical space
Point3 centerOfMass(PixelType minVal =0.0, PixelType maxVal =1.0) const
returns average physical coordinate of pixels in range (minval, maxval]
PixelType min()
minimum of image
PixelType max()
maximum of image
PixelType mean()
mean of image
PixelType std()
standard deviation of image
IndexRegion logicalBoundingBox() const
bounding box of complete image in logical (index) space
PhysicalRegion physicalBoundingBox() const
bounding box of complete image in physical space
PhysicalRegion physicalBoundingBox(PixelType isovalue) const
bounding box of largest region of data >= the given isoValue in physical space
PhysicalRegion logicalToPhysical(IndexRegion region) const
converts a bounding box in logical (index) space to this image's index coordinates
IndexRegion physicalToLogical(PhysicalRegion region) const
converts a bounding box in physical space to this image's logical (index) coordinates
Point3 logicalToPhysical(const Coord & c) const
converts from pixel coordinates to physical space
Coord physicalToLogical(const Point3 & p) const
converts from a physical coordinate to a logical coordinate
ImageIterator iterator()
creates an image iterator and returns it
bool compare(const Image & other, bool verifyall =true, double tolerance =0.0, double precision =1e-12) const
compares this with another image using the region of interest filter
bool operator==(const Image & other) const
compares this with another image using the region of interest filter
Image & write(const std::string & filename, bool compressed =true)
writes image, format specified by filename extension
Mesh toMesh(PixelType isovalue) const
converts image to mesh
Image::PixelType evaluate(Point p)
Evaluates the image at a given position.

Friends

Name
struct SharedCommandData

Detailed Description

class shapeworks::Image;

This class represents a 3D image volume and operations that can be performed on images.

Public Types Documentation

enum InterpolationType

Enumerator Value Description
Linear
NearestNeighbor

using PixelType

using shapeworks::Image::PixelType =  float;

using ImageType

using shapeworks::Image::ImageType =  itk::Image<PixelType, 3>;

using StatsPtr

using shapeworks::Image::StatsPtr =  itk::StatisticsImageFilter<ImageType>::Pointer;

using ImageIterator

using shapeworks::Image::ImageIterator =  itk::ImageRegionIterator<ImageType>;

using InterpolatorType

using shapeworks::Image::InterpolatorType =  itk::LinearInterpolateImageFunction<ImageType, Image::PixelType>;

Public Functions Documentation

function Image

Image(
    const Dims dims
)

function Image

inline Image(
    const std::string & pathname
)

function Image

inline Image(
    ImageType::Pointer imagePtr
)

function Image

Image(
    const vtkSmartPointer< vtkImageData > vtkImage
)

function Image

inline Image(
    Image && img
)

function Image

inline Image(
    const Image & img
)

function operator=

Image & operator=(
    const Image & img
)

function operator=

Image & operator=(
    Image && img
)

lvalue assignment operator

function operator ImageType::Pointer

inline operator ImageType::Pointer()

rvalue assignment operator

return this as an ITK image

function getITKImage

inline ImageType::Pointer getITKImage() const

function getVTKImage

vtkSmartPointer< vtkImageData > getVTKImage() const

creates a VTK filter for the given image

function operator-

Image & operator-()

negation operator

function operator+

Image operator+(
    const Image & other
) const

plus operator to add two images

function operator+=

Image & operator+=(
    const Image & other
)

function operator-

Image operator-(
    const Image & other
) const

minus operator to add two images

function operator-=

Image & operator-=(
    const Image & other
)

function operator*

Image operator*(
    const Image & other
) const

multiply operator to multiply two images

function operator*

Image operator*(
    const PixelType x
) const

multiply operator to scale contents of an image

function operator*=

Image & operator*=(
    const PixelType x
)

function operator/

Image operator/(
    const PixelType x
) const

divide operator to scale contents of an image

function operator/=

Image & operator/=(
    const PixelType x
)

function operator+

Image operator+(
    const PixelType x
) const

plus operator to shift contents of an image

function operator+=

Image & operator+=(
    const PixelType x
)

function operator-

Image operator-(
    const PixelType x
) const

minus operator to shift contents of an image

function operator-=

Image & operator-=(
    const PixelType x
)

function antialias

Image & antialias(
    unsigned iterations =50,
    double maxRMSErr =0.01f,
    int layers =3
)

antialiases image

function recenter

Image & recenter()

helper identical to setOrigin(image.center()) changing origin (in the image header) to physcial center of the image

function resample

Image & resample(
    const TransformPtr transform,
    const Point3 origin,
    const Dims dims,
    const Vector3 spacing,
    const ImageType::DirectionType direction,
    InterpolationType interp =NearestNeighbor
)

resamples by applying transform then sampling from given origin along direction axes at spacing physical units per pixel for dims pixels using specified interpolator

function resample

Image & resample(
    const Vector & physicalSpacing,
    InterpolationType interp =Linear
)

resamples image using new physical spacing, updating logical dims to keep all image data for this spacing

function resample

Image & resample(
    double isoSpacing =1.0,
    InterpolationType interp =Linear
)

resamples image using isotropic physical spacing

function resize

Image & resize(
    Dims logicalDims,
    InterpolationType interp =Linear
)

changes logical image size, computing new physical spacing based on this size (i.e., physical image size remains the same)

function pad

Image & pad(
    int padding,
    PixelType value =0.0
)

pads an image by same number of voxels in all directions with constant value

function pad

Image & pad(
    int padx,
    int pady,
    int padz,
    PixelType value =0.0
)

pads an image by desired number of voxels in each direction with constant value

function pad

Image & pad(
    IndexRegion & region,
    PixelType value =0.0
)

pads an image to include the given region with constant value

function translate

Image & translate(
    const Vector3 & v
)

helper to simply translate image

function scale

Image & scale(
    const Vector3 & v
)

helper to simply scale image around center (not origin)

function rotate

Image & rotate(
    const double angle,
    const Vector3 & axis
)

helper to simply rotate around axis through center (not origin) by given angle (in radians)

function rotate

Image & rotate(
    const double angle,
    Axis axis
)

helper to simply rotate around axis through center (not origin) by given angle (in radians)

function createCenterOfMassTransform

TransformPtr createCenterOfMassTransform()

creates a transform that translates center of mass to center of image

function createRigidRegistrationTransform

TransformPtr createRigidRegistrationTransform(
    const Image & target_dt,
    float isoValue =0.0,
    unsigned iterations =20
)

creates transform to target image using iterative closest point (ICP) registration; images MUST be distance transforms; isovalue is used to create meshes from these distance transform images, which are then passed to ICP for the given number of iterations

function applyTransform

Image & applyTransform(
    const TransformPtr transform,
    InterpolationType interp =Linear
)

applies the given transformation to the image by using resampling filter

function applyTransform

Image & applyTransform(
    const TransformPtr transform,
    const Point3 origin,
    const Dims dims,
    const Vector3 spacing,
    const ImageType::DirectionType direction,
    InterpolationType interp =NearestNeighbor
)

applies the given transformation to the image by using resampling filter with new origin, dims, spacing and direction values

function extractLabel

Image & extractLabel(
    const PixelType label =1.0
)

extracts/isolates a specific voxel label from a given multi-label volume and outputs the corresponding binary image

function closeHoles

Image & closeHoles(
    const PixelType foreground =0.0
)

closes holes in a given volume, default foreground value assumes a binary volume

function binarize

Image & binarize(
    PixelType minVal =0.0,
    PixelType maxVal =std::numeric_limits< PixelType >::max(),
    PixelType innerVal =1.0,
    PixelType outerVal =0.0
)

threholds image into binary label based on upper and lower intensity bounds given by user

function computeDT

Image & computeDT(
    PixelType isoValue =0.0
)

computes distance transform volume from a (preferably antialiased) binary image using the specified isovalue

function applyCurvatureFilter

Image & applyCurvatureFilter(
    unsigned iterations =10
)

denoises an image using curvature driven flow using curvature flow image filter

function applyGradientFilter

Image & applyGradientFilter()

computes gradient magnitude at each pixel using gradient magnitude filter

function applySigmoidFilter

Image & applySigmoidFilter(
    double alpha =10.0,
    double beta =10.0
)

computes sigmoid function pixel-wise using sigmoid image filter

function applyTPLevelSetFilter

Image & applyTPLevelSetFilter(
    const Image & featureImage,
    double scaling =20.0
)

segements structures in images using topology preserving geodesic active contour level set filter

function topologyPreservingSmooth

Image & topologyPreservingSmooth(
    float scaling =20.0,
    float sigmoidAlpha =10.5,
    float sigmoidBeta =10.0
)

creates a feature image (by applying gradient then sigmoid filters), then passes it to the TPLevelSet filter [curvature flow filter is often applied to the image before this filter]

function applyIntensityFilter

Image & applyIntensityFilter(
    double minVal,
    double maxVal
)

applies intensity windowing image filter

function gaussianBlur

Image & gaussianBlur(
    double sigma =0.0
)

applies gaussian blur with given sigma

function crop

Image & crop(
    PhysicalRegion region,
    const int padding =0
)

crops the image down to the given region, with optional padding added

function clip

Image & clip(
    const Plane plane,
    const PixelType val =0.0
)

clips an image using a cutting plane

function reflect

Image & reflect(
    const Axis & axis
)

reflect image around the plane specified by the logical center and the given normal (ex: <1,0,0> reflects across YZ-plane).

function setOrigin

Image & setOrigin(
    Point3 origin =Point3({0, 0, 0})
)

sets the image origin in physical space to the given value

function setSpacing

Image & setSpacing(
    Vector3 spacing
)

sets the image spacing to the given value

function setCoordsys

Image & setCoordsys(
    ImageType::DirectionType coordsys
)

sets the coordinate system in which this image lives in physical space

function isolate

Image & isolate()

isolate the largest object in a binary segmentation

function dims

inline Dims dims() const

logical dimensions of the image

function size

inline Point3 size() const

physical dimensions of the image (dims * spacing)

function spacing

inline Vector spacing() const

physical spacing of the image

function origin

inline Point3 origin() const

physical coordinates of image origin

function center

inline Point3 center() const

physical coordinates of center of this image

function coordsys

inline ImageType::DirectionType coordsys() const

return coordinate system in which this image lives in physical space

function centerOfMass

Point3 centerOfMass(
    PixelType minVal =0.0,
    PixelType maxVal =1.0
) const

returns average physical coordinate of pixels in range (minval, maxval]

function min

PixelType min()

minimum of image

function max

PixelType max()

maximum of image

function mean

PixelType mean()

mean of image

function std

PixelType std()

standard deviation of image

function logicalBoundingBox

IndexRegion logicalBoundingBox() const

bounding box of complete image in logical (index) space

function physicalBoundingBox

PhysicalRegion physicalBoundingBox() const

bounding box of complete image in physical space

function physicalBoundingBox

PhysicalRegion physicalBoundingBox(
    PixelType isovalue
) const

bounding box of largest region of data >= the given isoValue in physical space

function logicalToPhysical

PhysicalRegion logicalToPhysical(
    IndexRegion region
) const

converts a bounding box in logical (index) space to this image's index coordinates

function physicalToLogical

IndexRegion physicalToLogical(
    PhysicalRegion region
) const

converts a bounding box in physical space to this image's logical (index) coordinates

function logicalToPhysical

Point3 logicalToPhysical(
    const Coord & c
) const

converts from pixel coordinates to physical space

function physicalToLogical

Coord physicalToLogical(
    const Point3 & p
) const

converts from a physical coordinate to a logical coordinate

function iterator

ImageIterator iterator()

creates an image iterator and returns it

function compare

bool compare(
    const Image & other,
    bool verifyall =true,
    double tolerance =0.0,
    double precision =1e-12
) const

compares this with another image using the region of interest filter

function operator==

inline bool operator==(
    const Image & other
) const

compares this with another image using the region of interest filter

function write

Image & write(
    const std::string & filename,
    bool compressed =true
)

writes image, format specified by filename extension

function toMesh

Mesh toMesh(
    PixelType isovalue
) const

converts image to mesh

function evaluate

Image::PixelType evaluate(
    Point p
)

Evaluates the image at a given position.

Friends

friend SharedCommandData

friend struct SharedCommandData();

Updated on 2022-07-23 at 17:50:04 -0600