SMILX  1.01
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
milx::Image< TImage > Class Template Reference

Represents an image (i.e. an regular rectangular array with scalar values) and their common operations using the Insight Toolkit (ITK). More...

#include <milxImage.h>

Inheritance diagram for milx::Image< TImage >:
milx::ImageBase

Public Member Functions

 Image ()
 Standard constructor. More...
 
virtual ~Image ()
 Standard Destructor.
 
itk::SmartPointer< TImage > Result ()
 Returns the current image, i.e. the result of the latest operation. More...
 
itk::SmartPointer< TImage > PreviousResult ()
 Returns the previous image, i.e. the result of the penultimate operation. More...
 
itk::SmartPointer< TImage > GetOutput ()
 Returns the current image, i.e. the result of the latest operation ITK/VTK style.
 
template<class TJoinedImage >
itk::SmartPointer< TJoinedImage > JoinCollection (std::vector< typename itk::SmartPointer< TImage > > &images, const double origin, const double spacing)
 

Static Public Member Functions

static vtkSmartPointer< vtkImageData > ConvertITKImageToVTKImage (itk::SmartPointer< TImage > img)
 Converts a ITK image object to an VTK image object. You MUST DeepCopy the result as the ITK smartpointer is not aware of the VTK smartpointer.
 
static vtkSmartPointer< vtkImageData > ConvertITKVectorImageToVTKImage (itk::SmartPointer< TImage > img)
 Converts a ITK Vector image object to an VTK image object. You MUST DeepCopy the result as the ITK smartpointer is not aware of the VTK smartpointer.
 
template<typename TRefImage , class TPrecision >
static itk::SmartPointer< TImage > ApplyOrientationToITKImage (itk::SmartPointer< TImage > img, itk::SmartPointer< TRefImage > refImage, const bool labelledImage, const bool flipY=true, const bool ignoreDirection=false)
 
static vtkSmartPointer< vtkImageData > ApplyOrientationToVTKImage (vtkSmartPointer< vtkImageData > img, itk::SmartPointer< TImage > refImage, vtkSmartPointer< vtkMatrix4x4 > &transformMatrix, const bool labelledImage, const bool flipY=true)
 Applies orientation/direction and origin to a VTK image from a reference image. More...
 
static itk::SmartPointer< TImage > ConvertVTKImageToITKImage (vtkSmartPointer< vtkImageData > img)
 Converts a VTK image object to an ITK image object.
 
template<typename TOutImage >
static itk::SmartPointer< TOutImage > CastImage (itk::SmartPointer< TImage > img)
 Casts an image from one type to another.
 
static itk::SmartPointer< TImage > DuplicateImage (itk::SmartPointer< TImage > img)
 Duplicates the image into a new image.
 
static itk::SmartPointer< TImage > DuplicateImage (const TImage *img)
 Duplicates the image into a new image.
 
template<typename TVector >
static itk::SmartPointer< TImage > ImportVectorToImage (vnl_vector< TVector > &vec, typename TImage::SizeType size, itk::SmartPointer< TImage > image=NULL)
 Imports a VNL vector to an ITK image object. More...
 
template<typename TMatrix >
static itk::SmartPointer< TImage > ImportMatrixToImage (vnl_matrix< TMatrix > &matrix, itk::SmartPointer< TImage > image=NULL)
 Imports a VNL matrix to an ITK image object. More...
 
static itk::SmartPointer< TImage > BlankImage (typename TImage::PixelType value, typename TImage::SizeType imgSize)
 Creates an empty image filled with value given.
 
template<typename TSubImage >
static itk::SmartPointer< TSubImage > ExtractSubImage (itk::SmartPointer< TImage > img, typename TImage::RegionType imgRegion)
 Extract a sub image (such as a slice) from the current image given the region.
 
template<typename TImageSlice >
static itk::SmartPointer< TImageSlice > ExtractSlice (itk::SmartPointer< TImage > img, int *extent)
 Extract a sub image (such as a slice) from the current image given the extent (typically obtained from a VTK image actor etc.). More...
 
template<typename TImageComponent >
static itk::SmartPointer< TImageComponent > ExtractComponent (itk::SmartPointer< TImage > img, int component)
 Extract a component from the current vector image given the component index. More...
 
static itk::SmartPointer< TImage > ResizeImage (itk::SmartPointer< TImage > img, typename TImage::SizeType imgSize)
 Resizes current image using current spacing. More...
 
static itk::SmartPointer< TImage > ResizeImage (itk::SmartPointer< TImage > img, typename TImage::SizeType imgSize, typename TImage::SpacingType outputSpacing)
 
static itk::SmartPointer< TImage > ResizeImage (itk::SmartPointer< TImage > img, typename TImage::SizeType imgSize, typename TImage::SpacingType outputSpacing, typename TImage::PointType outputOrigin, typename TImage::DirectionType outputDirection)
 Resizes current image using given spacing, origin and direction.
 
static itk::SmartPointer< TImage > SubsampleImage (itk::SmartPointer< TImage > img, typename TImage::SizeType factors)
 Subsamples or shrinks the current image using the factors provided. More...
 
template<typename TOutImage , typename TTransform , typename TPrecision >
static itk::SmartPointer< TOutImage > TransformImage (itk::SmartPointer< TImage > img, itk::SmartPointer< TOutImage > refImg, itk::SmartPointer< TTransform > transf, const bool inverse, const int interp=1)
 Transform the image into a new reference image space given the transform. More...
 
template<typename TOutImage , typename TTransform , typename TPrecision >
static itk::SmartPointer< TOutImage > TransformImage (itk::SmartPointer< TImage > img, itk::SmartPointer< TTransform > transf, const bool inverse, const int interp=1)
 
template<typename TOutImage >
static itk::SmartPointer< TOutImage > ResampleImage (itk::SmartPointer< TImage > img, itk::SmartPointer< TOutImage > refImg, const bool linearInterp=false)
 Resample the image into a new reference image space given.
 
template<typename TOutImage >
static itk::SmartPointer< TOutImage > ResampleLabel (itk::SmartPointer< TImage > img, itk::SmartPointer< TOutImage > refImg)
 Resample the a labelled image into a new reference image space given ensuring no interpolator artefacts.
 
static itk::SmartPointer< TImage > AddImages (itk::SmartPointer< TImage > img1, itk::SmartPointer< TImage > img2)
 Adds image 1 to image 2, returning the result.
 
static itk::SmartPointer< TImage > SubtractImages (itk::SmartPointer< TImage > img1, itk::SmartPointer< TImage > img2)
 Subtracts image 2 from image 1, returning the result.
 
static itk::SmartPointer< TImage > DifferenceImages (itk::SmartPointer< TImage > img1, itk::SmartPointer< TImage > img2)
 Same as SubtractImages().
 
static itk::SmartPointer< TImage > MultiplyImages (itk::SmartPointer< TImage > img1, itk::SmartPointer< TImage > img2)
 Multiplies (element-wise) image 2 from image 1, returning the result.
 
template<class TOutImage >
static itk::SmartPointer< TOutImage > ScaleImage (itk::SmartPointer< TImage > img, float scaling)
 Scales the image intensities by scaling factor and returns the result.
 
static itk::SmartPointer< TImage > ScaleVectorImage (itk::SmartPointer< TImage > img, float scaling, int numberOfComponents)
 Scales each component of the vector image intensities by scaling factor and returns the result.
 
static void Information (itk::SmartPointer< TImage > img)
 Prints the information of the image to standard output.
 
static double ImageMaximum (itk::SmartPointer< TImage > img)
 Returns the maximum pixel value of an image.
 
static double ImageMinimum (itk::SmartPointer< TImage > img)
 Returns the minimum pixel value of an image.
 
static std::string ImageOrientation (itk::SmartPointer< TImage > img)
 Returns the orientation flag of an image.
 
static itk::SmartPointer< TImage > CheckerBoard (itk::SmartPointer< TImage > img, itk::SmartPointer< TImage > imgToCheckerBoard, const int numberOfSquares=0)
 Generates a checker board pattern where each box alternates between two images. Ideal for comparison among images.
 
static itk::SmartPointer< TImage > RescaleIntensity (itk::SmartPointer< TImage > img, float minValue, float maxValue)
 
static itk::SmartPointer< TImage > InvertIntensity (itk::SmartPointer< TImage > img, float maxValue)
 Generates an image with the intensities reversed based on the max pixel value.
 
static itk::SmartPointer< TImage > HistogramEqualisation (itk::SmartPointer< TImage > img, float alpha=0.3, float beta=0.3, float radius=5)
 Generates an image with the intensities after histogram equalisation. Defaults to classic histogram equalisation. More...
 
static itk::SmartPointer< TImage > GradientMagnitude (itk::SmartPointer< TImage > img)
 Generates an image with the gradient magnitude of the given image.
 
static itk::SmartPointer< TImage > SobelEdges (itk::SmartPointer< TImage > img)
 Generates an image with Sobel edges, i.e. uses the Sobel edge detection on the input image.
 
static itk::SmartPointer< TImage > Laplacian (itk::SmartPointer< TImage > img)
 Generates an Laplacian image from the input image.
 
static itk::SmartPointer< TImage > CannyEdges (itk::SmartPointer< TImage > img, float variance, float lowerThreshold, float upperThreshold)
 Generates an Canny edge image from the input image.
 
static itk::SmartPointer< itk::Image< float, TImage::ImageDimension > > Normalization (itk::SmartPointer< TImage > img)
 Generates an image which is statistically normalised so having pixel values between -1 and 1.
 
static itk::SmartPointer< TImage > MatchInformation (itk::SmartPointer< TImage > img, itk::SmartPointer< TImage > imgToMatch, bool originOnly=false)
 Changes the image info to match that of provided image. By default, only the spacing, region and origin are changed. More...
 
static itk::SmartPointer< TImage > CopyInformation (itk::SmartPointer< TImage > img, itk::SmartPointer< TImage > imgToMatch, bool originOnly=false)
 Changes the image info to match that of provided image. By default, only the spacing, region and origin are changed. More...
 
static itk::SmartPointer< TImage > MatchHistogram (itk::SmartPointer< TImage > img, itk::SmartPointer< TImage > imgToMatch, const int bins=128)
 Changes the image gray levels to match histogram of image provided.
 
template<typename TOutImage >
static itk::SmartPointer< TOutImage > DistanceMap (itk::SmartPointer< TImage > img, const bool binaryImage=false, const bool signedDistances=false, const bool computeInsideObject=false, const bool squaredDistance=false)
 Generates a distance map image, where the distances are from the object boundary to the outside or vice versa. More...
 
static itk::SmartPointer< TImage > FlipImage (itk::SmartPointer< TImage > img, bool xAxis=false, bool yAxis=true, bool zAxis=false, bool aboutOrigin=true)
 Generates an image with axes flipped. Currently flips the y-axis as default, but can do other axes also in combination.
 
static itk::SmartPointer< TImage > PadImageByConstant (itk::SmartPointer< TImage > img, size_t xAxis, size_t yAxis, size_t zAxis, typename TImage::PixelType value)
 Generates an image padded by extending each axes by size given in both directions. The created areas have the value given by value.
 
template<typename TOutImage >
static itk::SmartPointer< TOutImage > AnisotropicDiffusion (itk::SmartPointer< TImage > img, const int iterations, const float timestep)
 Generates the gradient anisotropic diffusion (smoothing) of an image using the number of iterations.
 
static itk::SmartPointer< TImage > Bilateral (itk::SmartPointer< TImage > img, const float sigmaRange, const float sigmaSpatial)
 Generates the (non-linear) Bilateral smoothing of an image using the sigmas provided.
 
static itk::SmartPointer< TImage > GaussianSmooth (itk::SmartPointer< TImage > img, const float variance)
 Generates the Gaussian smoothing (by convolution) of an image using the variance provided.
 
static itk::SmartPointer< TImage > Median (itk::SmartPointer< TImage > img, const int radius)
 Generates the (non-linear) median filtering (smoothing) of an image of given neighbourhood radius.
 
template<typename TMaskImage >
static itk::SmartPointer< TImage > MaskImage (itk::SmartPointer< TImage > img, itk::SmartPointer< TMaskImage > maskImg)
 Mask an image by given binary image.
 
static itk::SmartPointer< TImage > RelabelImage (itk::SmartPointer< TImage > labelledImg)
 Returns a labelled image with labelled values relabelled consecutively based on connectivity.
 
static itk::SmartPointer< TImage > ThresholdAboveImage (itk::SmartPointer< TImage > img, float outsideValue, float aboveValue)
 Generates an image with the intensities above a certain level thresholded (capped) to the outsideValue.
 
static itk::SmartPointer< TImage > ThresholdBelowImage (itk::SmartPointer< TImage > img, float outsideValue, float aboveValue)
 Generates an image with the intensities below a certain level thresholded (capped) to the outsideValue.
 
static itk::SmartPointer< TImage > ThresholdImage (itk::SmartPointer< TImage > img, float outsideValue, float belowValue, float aboveValue)
 Generates an image with the intensities below and above a certain level thresholded (capped) to the outsideValue.
 
template<typename TOutImage >
static itk::SmartPointer< TOutImage > BinaryThresholdImage (itk::SmartPointer< TImage > img, float outsideValue, float insideValue, float belowValue, float aboveValue)
 Generates a binary image thresholded at the intensities below and above a certain level to the outsideValue.
 
static double OtsuThreshold (itk::SmartPointer< TImage > img, const int bins)
 Returns the Otsu threshold of an image of given the number of histogram bins.
 
template<typename TOutImage >
static itk::SmartPointer< TOutImage > OtsuThresholdImage (itk::SmartPointer< TImage > img, const int bins)
 Generates the Otsu threshold of an image of given the number of histogram bins. More...
 
template<typename TOutImage >
static itk::SmartPointer< TOutImage > OtsuMultipleThresholdImage (itk::SmartPointer< TImage > img, const int bins, const int noOfLabels=1)
 Generates the multiple Otsu threshold of an image of given the number of histogram bins. More...
 
template<typename TScalarImage >
static itk::SmartPointer< TScalarImage > VectorMagnitude (itk::SmartPointer< TImage > img)
 Generates an image comprised of the magnitude of the vectors in the image.
 
static void InformationCollection (std::vector< typename itk::SmartPointer< TImage > > &images)
 Batch process images by output the image information for each image.
 
static void MatchHistogramCollection (std::vector< typename itk::SmartPointer< TImage > > &images, itk::SmartPointer< TImage > refImage, const int bins=128)
 Batch process images by matching the histograms of the images to the reference image provided.
 
static void CheckerboardCollection (std::vector< typename itk::SmartPointer< TImage > > &images, itk::SmartPointer< TImage > refImage, const int squares=10)
 Batch process images by checkerboarding all of the images to the reference image provided.
 
static void RescaleIntensityCollection (std::vector< typename itk::SmartPointer< TImage > > &images, float belowValue, float aboveValue)
 
static void InvertIntensityCollection (std::vector< typename itk::SmartPointer< TImage > > &images)
 Batch process images by inverting the intensities for each image.
 
static void FlipCollection (std::vector< typename itk::SmartPointer< TImage > > &images, bool xAxis=false, bool yAxis=true, bool zAxis=false, bool aboutOrigin=true)
 Batch process images by flipping each image along axis provided.
 
template<typename TOutImage >
static std::vector< typename itk::SmartPointer< TOutImage > > AnisotropicDiffusionCollection (const std::vector< typename itk::SmartPointer< TImage > > &images, const int iterations, float timestep=-1.0)
 Batch process images by smoothing each image using Gradient Anisotropic Diffusion. More...
 
static void BilateralCollection (std::vector< typename itk::SmartPointer< TImage > > &images, float sigmaRange, float sigmaSpatial)
 Batch process images by bilateral smoothing each image.
 
template<typename TOutImage >
static std::vector< typename itk::SmartPointer< TOutImage > > CastCollection (const std::vector< typename itk::SmartPointer< TImage > > &images)
 Batch process images by casting each image to type provided in templates.
 
static void MedianCollection (std::vector< typename itk::SmartPointer< TImage > > &images, const int radius)
 Batch process images by smoothing each image using the Median of the neighbourhood.
 
static void GradientMagnitudeCollection (std::vector< typename itk::SmartPointer< TImage > > &images)
 Batch process images by hightlighting the edges of each image using Gradient magnitude information of the pixels in the image.
 
static void LaplacianCollection (std::vector< typename itk::SmartPointer< TImage > > &images)
 Batch process images by hightlighting the edges of each image using the Laplacian of the image.
 
template<typename TOutImage >
static std::vector< typename itk::SmartPointer< TOutImage > > DistanceMapCollection (const std::vector< typename itk::SmartPointer< TImage > > &images, const bool binaryImage=false, const bool signedDistances=false, const bool computeInsideObject=false, const bool squaredDistance=false)
 Batch process images by computing the distance map of each image. Output should always be a float image.
 
static void ThresholdAboveCollection (std::vector< typename itk::SmartPointer< TImage > > &images, float outsideValue, float aboveValue)
 Batch process images by thresholding each image from above.
 
static void ThresholdBelowCollection (std::vector< typename itk::SmartPointer< TImage > > &images, float outsideValue, float belowValue)
 Batch process images by thresholding each image from below.
 
static void ThresholdCollection (std::vector< typename itk::SmartPointer< TImage > > &images, float outsideValue, float belowValue, float aboveValue)
 Batch process images by thresholding each image within band provided.
 
template<typename TOutImage >
static std::vector< typename itk::SmartPointer< TOutImage > > BinaryThresholdCollection (const std::vector< typename itk::SmartPointer< TImage > > &images, float outsideValue, float insideValue, float belowValue, float aboveValue)
 Batch process images by binary thresholding each image within band and inside value provided.
 
template<typename TOutImage >
static std::vector< typename itk::SmartPointer< TOutImage > > OtsuMultipleThresholdCollection (const std::vector< typename itk::SmartPointer< TImage > > &images, const int bins, const int noOfLabels)
 Batch process images by Otsu (histogram-based) thresholding each image having number of partitions/labels provided.
 
template<class TMaskImage >
static void MaskCollection (std::vector< typename itk::SmartPointer< TImage > > &images, itk::SmartPointer< TMaskImage > maskImage)
 Batch process images by masking using the mask image provided.
 
static void RelabelCollection (std::vector< typename itk::SmartPointer< TImage > > &images)
 Batch process images by relabelling unconnected regions consecutatively.
 
template<class TRefImage >
static void ResampleCollection (std::vector< typename itk::SmartPointer< TImage > > &images, itk::SmartPointer< TRefImage > refImage)
 Batch process images by resampling images using the reference image provided.
 
template<class TRefImage >
static void ResampleLabelCollection (std::vector< typename itk::SmartPointer< TImage > > &images, itk::SmartPointer< TRefImage > refImage)
 Batch process labelled images by resampling images using the reference image provided. This uses the nearest neighbour interploator.
 
static itk::SmartPointer< TImage > AddCollection (std::vector< typename itk::SmartPointer< TImage > > &images)
 Batch process images by the adding the images together (pixel-wise).
 
static itk::SmartPointer< TImage > SubtractCollection (std::vector< typename itk::SmartPointer< TImage > > &images)
 Batch process images by the subtracting the images from the first image (pixel-wise).
 
static itk::SmartPointer< TImage > DifferenceCollection (std::vector< typename itk::SmartPointer< TImage > > &images)
 Same as SubtractCollection.
 
template<class TOutImage >
static itk::SmartPointer< TOutImage > AverageCollection (std::vector< typename itk::SmartPointer< TImage > > &images)
 Batch process images by the averaging the images (pixel-wise).
 
static itk::SmartPointer< TImage > AverageVectorCollection (std::vector< typename itk::SmartPointer< TImage > > &images, int numberOfComponents)
 Batch process images by the averaging the vector images (pixel-wise).
 

Protected Attributes

itk::SmartPointer< TImage > CurrentImage
 Holds the current image in the pipeline.
 
itk::SmartPointer< TImage > PreviousImage
 Holds the previous image in the pipeline.
 

Detailed Description

template<class TImage>
class milx::Image< TImage >

Represents an image (i.e. an regular rectangular array with scalar values) and their common operations using the Insight Toolkit (ITK).

Due to the templated nature of itk::Image objects, most of the members in this class are static and the current state is not tracked. This class is used extensively throughout the milxQtImage class. Use the milx::File object to load and save images. See the usage examples given below:

Converting

typedef unsigned char InputPixelType;
typedef itk::Image<InputPixelType, 3> LabelImageType;
LabelImageType::SpacingType labelSpacing = m_LabelledImages[index]->GetSpacing();
milx::Model model1(surface1);
vtkSmartPointer<vtkImageData> voxelisedModel1 = model1.Voxelise(255, labelSpacing.GetDataPointer(), bigBounds);
LabelImageType::Pointer image1 = milx::Image<LabelImageType>::ConvertVTKImageToITKImage(voxelisedModel1);

Distance maps

typedef float FloatPixelType;
typedef itk::Image<FloatPixelType, 3> FloatImageType;
const bool binary = false, signedDistance = true, insideDistance = false, squaredDistance = false;
FloatImageType::Pointer distanceImage1 = milx::Image<LabelImageType>::DistanceMap<FloatImageType>(image1, binary, signedDistance, insideDistance, squaredDistance);

Padding an image

LabelImageType::RegionType region = image->GetLargestPossibleRegion();
LabelImageType::SizeType imageSize = region.GetSize();
itk::SmartPointer<LabelImageType> paddedImage = milx::Image<LabelImageType>::PadImageByConstant(image, imageSize[0]/2, imageSize[1]/2, imageSize[2]/2, 0);

Definition at line 174 of file milxImage.h.

Constructor & Destructor Documentation

◆ Image()

template<class TImage >
milx::Image< TImage >::Image ( )

Standard constructor.

Constructor that copies the input model.

Definition at line 858 of file milxImage.h.

Member Function Documentation

◆ PreviousResult()

template<class TImage>
milx::Image< TImage >::PreviousResult ( )
inline

Returns the previous image, i.e. the result of the penultimate operation.

Could be NULL, the user must check.

Definition at line 214 of file milxImage.h.

◆ Result()

template<class TImage>
milx::Image< TImage >::Result ( )
inline

Returns the current image, i.e. the result of the latest operation.

Could be NULL, the user must check.

Definition at line 204 of file milxImage.h.


The documentation for this class was generated from the following file: