Grid topology of data arranged in a 3D lattice. More...
#include <cmtkDataGrid.h>
Public Types | |
typedef DataGrid | Self |
This class. | |
typedef SmartPointer< Self > | SmartPtr |
Smart pointer to DataGrid. | |
typedef SmartConstPointer< Self > | SmartConstPtr |
Smart pointer-to-const to DataGrid. | |
typedef Region< 3, int > | RegionType |
Region type. | |
typedef RegionType::IndexType | IndexType |
Index type. | |
typedef FixedVector < 3, Types::Coordinate > | SpaceVectorType |
Space vector type. | |
Public Member Functions | |
cmtkGetSetMacro (TypedArray::SmartPtr, Data) | |
Data array (element type is variable) | |
DataGrid () | |
Default constructor. | |
DataGrid (const Self::IndexType &dims, TypedArray::SmartPtr &data=TypedArray::SmartPtr::Null) | |
Constructor. | |
virtual | ~DataGrid () |
Virtual destructor. | |
bool | GridMatches (const Self &other) const |
Test whether this grid matches another one, i.e., has the same dimensions. | |
virtual DataGrid * | GetDownsampledAndAveraged (const int(&downsample)[3]) const |
Downsampling and pixel-averaging constructor function. | |
const DataGrid::SmartPtr | GetReoriented (const char *newOrientation=AnatomicalOrientation::ORIENTATION_STANDARD) const |
Reorientation constructor function. | |
void | SetDims (const Self::IndexType &dims) |
Set dimensions array. | |
const Self::IndexType | GetDims () const |
Get dimensions array. | |
virtual TypedArray::SmartPtr | CreateDataArray (const ScalarDataType dataType, const bool setToZero=false) |
Create data array. | |
size_t | GetNumberOfPixels () const |
Get number of data items in the volume. | |
bool | IndexIsInRange (const int x, const int y, const int z) const |
Check whether given pixel index is inside grid. | |
size_t | GetOffsetFromIndex (const int x, const int y, const int z) const |
Get offset of a pixel. | |
void | GetIndexFromOffset (const size_t offset, int &x, int &y, int &z) const |
Get index of a pixel identified by its offset. | |
bool | GetDataAt (Types::DataItem &data, const size_t offset) const |
Return data at specified offset. | |
void | SetDataAt (const Types::DataItem data, const size_t offset) |
Set data at specified offset. | |
bool | GetDataAt (Types::DataItem &data, const int x, const int y, const int z) const |
Return data at specified grid point. | |
void | SetDataAt (const Types::DataItem data, const int x, const int y, const int z) |
Set data at specified grid point. | |
Types::DataItem | GetDataAt (const int x, const int y, const int z, const Types::DataItem defaultValue=0.0) const |
Return data at specified grid point, or a given default value if no data exists there. | |
Types::DataItem | GetDataAt (const size_t offset, const Types::DataItem defaultValue=0.0) const |
Return data at specified grid offset, or a given default value if no data exists there. | |
TypedArray::SmartPtr | GetDataMirrorPlane (const int axis=AXIS_X) const |
Return data after mirroring. | |
void | ApplyMirrorPlane (const int axis=AXIS_X) |
Replace data with mirrored version. | |
Self::RegionType & | CropRegion () |
Get cropped region reference. | |
virtual void | SetCropRegion (const Self::RegionType ®ion) |
Set cropped region. | |
const Self::RegionType & | CropRegion () const |
Get cropped region reference. | |
int | GetCropRegionNumVoxels () const |
Return number of voxels in the cropped remaining image. | |
const RegionType | GetWholeImageRegion () const |
Get whole image region. | |
const Self::IndexType | GetCropRegionIncrements () const |
Get index increments for crop region. | |
void | AutoCrop (const Types::DataItem threshold, const bool recrop=false, const int margin=0) |
Automatically crop to minimal region above given threshold. | |
void | FillCropBackground (const Types::DataItem value) |
Fill volume outside current crop region with constant value. | |
TypedArray::SmartPtr | GetCroppedData () const |
Return data for cropped volume. | |
int | GetNextI () const |
Accessor functions for protected member variables. | |
int | GetNextJ () const |
int | GetNextK () const |
int | GetNextIJ () const |
int | GetNextIK () const |
int | GetNextJK () const |
int | GetNextIJK () const |
virtual FixedVector < 3, Types::Coordinate > | GetCenterOfMassGrid () const |
Get center of mass of pixel data. | |
virtual FixedVector < 3, Types::Coordinate > | GetCenterOfMassGrid (FixedVector< 3, Types::Coordinate > &firstOrderMoment) const |
Get center of mass and first-order moments of pixel data. | |
template<class TAccumulator > | |
ScalarImage * | ComputeProjection (const int axis) const |
Return maximum-intensity projection MIP along one axis. | |
virtual ScalarImage * | GetOrthoSlice (const int axis, const unsigned int plane) const |
Return orthogonal slice as a 2D image. | |
Self::SmartPtr | ExtractSlice (const int axis, const int plane) const |
Extract orthogonal slice as a data grid object. | |
virtual void | SetOrthoSlice (const int axis, const unsigned int idx, const ScalarImage *slice) |
Set orthogonal slice from a 2D image. | |
TypedArray::SmartPtr | GetDataMirrored (const int axis=AXIS_X) const |
Return data after mirror operator. | |
void | Print () const |
Print object. | |
Public Attributes | |
Self::IndexType | m_Dims |
Number of grid samples in the three spatial dimensions. | |
Protected Member Functions | |
bool | TrilinearInterpolation (Types::DataItem &data, const int x, const int y, const int z, const Self::SpaceVectorType &location, const Types::Coordinate *cellFrom, const Types::Coordinate *cellTo) const |
Utility function for trilinear interpolation. | |
template<class TData > | |
TData | TrilinearInterpolation (const TData *dataPtr, const int x, const int y, const int z, const Self::SpaceVectorType &gridPosition, const Types::Coordinate *cellFrom, const Types::Coordinate *cellTo) const |
Utility function for trilinear interpolation from a primitive data array. | |
template<class TData , class TOutputIterator > | |
void | TrilinearInterpolation (TOutputIterator result, const std::vector< TData * > &dataPtr, const int x, const int y, const int z, const Types::Coordinate fracX, const Types::Coordinate fracY, const Types::Coordinate fracZ) const |
Utility function for trilinear interpolation from multiple primitive data arrays of identical grid structure. | |
virtual Self * | ExtractSliceVirtual (const int axis, const int plane) const |
Extract orthogonal slice as a data grid object. | |
Protected Attributes | |
int | nextI |
Offset to next voxel column. | |
int | nextJ |
Offset to next voxel row. | |
int | nextK |
Offset to next voxel plane. | |
int | nextIJ |
Offset to next column and row. | |
int | nextIK |
Offset to next column and plane. | |
int | nextJK |
Offset to next row and plane. | |
int | nextIJK |
Offset to next column, row, and plane. | |
Static Private Member Functions | |
static void | MirrorPlaneInPlace (TypedArray &data, const Self::IndexType &dims, const int axis=AXIS_X) |
Mirror about plane without allocating additional memory. | |
Private Attributes | |
Self::RegionType | m_CropRegion |
Crop region. |
Grid topology of data arranged in a 3D lattice.
This class extends the plain data handling functions of TypedArray with a 3D topology. Real world coordinates, however, are not considered and need to be handled by derived classes. Thus, this class provides the coordinate independent services such as median filtering and, to a certain extent, interpolation.
Definition at line 66 of file cmtkDataGrid.h.
Index type.
Definition at line 84 of file cmtkDataGrid.h.
typedef Region<3,int> cmtk::DataGrid::RegionType |
Region type.
Definition at line 81 of file cmtkDataGrid.h.
typedef DataGrid cmtk::DataGrid::Self |
This class.
Reimplemented in cmtk::ImageTemplate< TPixelType >, cmtk::UniformVolume, and cmtk::Volume.
Definition at line 72 of file cmtkDataGrid.h.
Smart pointer-to-const to DataGrid.
Reimplemented in cmtk::ImageTemplate< TPixelType >, and cmtk::UniformVolume.
Definition at line 78 of file cmtkDataGrid.h.
typedef SmartPointer<Self> cmtk::DataGrid::SmartPtr |
Smart pointer to DataGrid.
Reimplemented in cmtk::ImageTemplate< TPixelType >, cmtk::UniformVolume, and cmtk::Volume.
Definition at line 75 of file cmtkDataGrid.h.
Space vector type.
Definition at line 87 of file cmtkDataGrid.h.
cmtk::DataGrid::DataGrid | ( | ) | [inline] |
Default constructor.
Definition at line 97 of file cmtkDataGrid.h.
cmtk::DataGrid::DataGrid | ( | const Self::IndexType & | dims, |
TypedArray::SmartPtr & | data = TypedArray::SmartPtr::Null |
||
) | [inline] |
Constructor.
Definition at line 102 of file cmtkDataGrid.h.
virtual cmtk::DataGrid::~DataGrid | ( | ) | [inline, virtual] |
Virtual destructor.
Definition at line 110 of file cmtkDataGrid.h.
void cmtk::DataGrid::AutoCrop | ( | const Types::DataItem | threshold, |
const bool | recrop = false , |
||
const int | margin = 0 |
||
) |
Automatically crop to minimal region above given threshold.
threshold | The cropping threshold. |
recrop | If this flag is true, then the cropping will be performed inside an already existing cropping region. If this flag is false (default), then any pre-set crop region is ignored. |
margin | Width of additional margin added around the threshold-cropped region. |
Definition at line 79 of file cmtkDataGrid_Crop.cxx.
References cmtk::TypedArray::Get().
cmtk::DataGrid::cmtkGetSetMacro | ( | TypedArray::SmartPtr | , |
Data | |||
) |
Data array (element type is variable)
Self::RegionType& cmtk::DataGrid::CropRegion | ( | ) | [inline] |
Get cropped region reference.
Definition at line 246 of file cmtkDataGrid.h.
Referenced by cmtk::VoxelMatchingMetric_Type< T, DT >::ImageData::Init().
const Self::RegionType& cmtk::DataGrid::CropRegion | ( | ) | const [inline] |
Get cropped region reference.
Definition at line 259 of file cmtkDataGrid.h.
Self::SmartPtr cmtk::DataGrid::ExtractSlice | ( | const int | axis, |
const int | plane | ||
) | const [inline] |
Extract orthogonal slice as a data grid object.
Reimplemented in cmtk::UniformVolume.
Definition at line 314 of file cmtkDataGrid.h.
void cmtk::DataGrid::FillCropBackground | ( | const Types::DataItem | value ) |
Fill volume outside current crop region with constant value.
Definition at line 133 of file cmtkDataGrid_Crop.cxx.
TypedArray::SmartPtr cmtk::DataGrid::GetCroppedData | ( | ) | const |
Return data for cropped volume.
Definition at line 161 of file cmtkDataGrid_Crop.cxx.
References cmtk::TypedArray::BlockCopy(), and cmtk::TypedArray::GetType().
const DataGrid::IndexType cmtk::DataGrid::GetCropRegionIncrements | ( | ) | const |
Get index increments for crop region.
Definition at line 60 of file cmtkDataGrid_Crop.cxx.
Referenced by cmtk::VoxelMatchingMetric_Type< T, DT >::ImageData::Init().
int cmtk::DataGrid::GetCropRegionNumVoxels | ( | ) | const |
Return number of voxels in the cropped remaining image.
Definition at line 72 of file cmtkDataGrid_Crop.cxx.
Referenced by cmtk::JointHistogramBase::CalcNumBins().
Types::DataItem cmtk::DataGrid::GetDataAt | ( | const size_t | offset, |
const Types::DataItem | defaultValue = 0.0 |
||
) | const [inline] |
Return data at specified grid offset, or a given default value if no data exists there.
Definition at line 221 of file cmtkDataGrid.h.
Types::DataItem cmtk::DataGrid::GetDataAt | ( | const int | x, |
const int | y, | ||
const int | z, | ||
const Types::DataItem | defaultValue = 0.0 |
||
) | const [inline] |
Return data at specified grid point, or a given default value if no data exists there.
Definition at line 211 of file cmtkDataGrid.h.
bool cmtk::DataGrid::GetDataAt | ( | Types::DataItem & | data, |
const size_t | offset | ||
) | const [inline] |
Return data at specified offset.
Definition at line 187 of file cmtkDataGrid.h.
Referenced by cmtk::InverseInterpolationVolumeReconstruction< TInterpolator >::ComputeErrorGradientImage(), cmtk::SplineWarpXform::GetRigidityConstraint(), cmtk::SplineWarpXform::GetRigidityConstraintDerivative(), cmtk::UniformVolume::ResampleThreadPoolExecuteGrey(), cmtk::UniformVolume::ResampleThreadPoolExecuteLabels(), cmtk::EntropyMinimizationIntensityCorrectionFunctionalBase::SetForegroundMask(), cmtk::EntropyMinimizationIntensityCorrectionFunctional< NOrderAdd, NOrderMul >::UpdateBiasFieldAddAllThreadFunc(), cmtk::EntropyMinimizationIntensityCorrectionFunctional< NOrderAdd, NOrderMul >::UpdateBiasFieldAddThreadFunc(), cmtk::EntropyMinimizationIntensityCorrectionFunctional< NOrderAdd, NOrderMul >::UpdateBiasFieldMulAllThreadFunc(), cmtk::EntropyMinimizationIntensityCorrectionFunctional< NOrderAdd, NOrderMul >::UpdateBiasFieldMulThreadFunc(), cmtk::EntropyMinimizationIntensityCorrectionFunctional< NOrderAdd, NOrderMul >::UpdateBiasFieldsAllThreadFunc(), cmtk::EntropyMinimizationIntensityCorrectionFunctional< NOrderAdd, NOrderMul >::UpdateBiasFieldsThreadFunc(), cmtk::QtTriplanarWindow::UpdateGridInfo(), cmtk::EntropyMinimizationIntensityCorrectionFunctionalBase::UpdateOutputImageThreadFunc(), cmtk::VolumeInjectionReconstruction::VolumeInjectionAnisotropic(), and cmtk::VolumeInjectionReconstruction::VolumeInjectionIsotropic().
bool cmtk::DataGrid::GetDataAt | ( | Types::DataItem & | data, |
const int | x, | ||
const int | y, | ||
const int | z | ||
) | const [inline] |
Return data at specified grid point.
Definition at line 199 of file cmtkDataGrid.h.
const Self::IndexType cmtk::DataGrid::GetDims | ( | ) | const [inline] |
Get dimensions array.
Definition at line 152 of file cmtkDataGrid.h.
Referenced by cmtk::VolumeInjectionReconstruction::AddLaplacianGradientImage(), cmtk::VolumeInjectionReconstruction::ComputeCorrectedImageLaplacianNorm(), cmtk::InverseInterpolationVolumeReconstruction< TInterpolator >::ComputeErrorGradientImage(), cmtk::FilterVolume::CoupeFilter(), cmtk::InverseInterpolationVolumeReconstruction< TInterpolator >::GetPassImageDependentPixelRegion(), cmtk::ReformatVolume::GetTransformedReference(), cmtk::ReformatVolume::GetTransformedReferenceJacobianAvg(), cmtk::InverseInterpolationVolumeReconstruction< TInterpolator >::Interpolation(), cmtk::operator<<(), cmtk::VoxelMatchingMetric_Type< T, DT >::ImageData::PrecomputeIncrements(), cmtk::ReformatVolume::ReformatMasked(), cmtk::ReformatVolume::ReformatUnmasked(), cmtk::FilterVolume::RohlfingFilter(), cmtk::UniformVolumeInterpolatorBase::SetVolume(), cmtk::FilterVolume::StudholmeFilter(), cmtk::QtTriplanarWindow::UpdateDialog(), cmtk::MultiChannelRegistrationFunctionalBase::VerifyImageSize(), cmtk::VolumeInjectionReconstruction::VolumeInjectionAnisotropic(), and cmtk::VolumeFromFile::WriteMetaImage().
void cmtk::DataGrid::GetIndexFromOffset | ( | const size_t | offset, |
int & | x, | ||
int & | y, | ||
int & | z | ||
) | const [inline] |
Get index of a pixel identified by its offset.
Definition at line 179 of file cmtkDataGrid.h.
Referenced by cmtk::VolumeInjectionReconstruction::AddLaplacianGradientImage(), cmtk::VolumeInjectionReconstruction::ComputeCorrectedImageLaplacianNorm(), and cmtk::VolumeInjectionReconstruction::VolumeInjectionIsotropic().
int cmtk::DataGrid::GetNextI | ( | ) | const [inline] |
Accessor functions for protected member variables.
Definition at line 290 of file cmtkDataGrid.h.
int cmtk::DataGrid::GetNextIJ | ( | ) | const [inline] |
Definition at line 293 of file cmtkDataGrid.h.
int cmtk::DataGrid::GetNextIJK | ( | ) | const [inline] |
Definition at line 296 of file cmtkDataGrid.h.
int cmtk::DataGrid::GetNextIK | ( | ) | const [inline] |
Definition at line 294 of file cmtkDataGrid.h.
int cmtk::DataGrid::GetNextJ | ( | ) | const [inline] |
Definition at line 291 of file cmtkDataGrid.h.
int cmtk::DataGrid::GetNextJK | ( | ) | const [inline] |
Definition at line 295 of file cmtkDataGrid.h.
int cmtk::DataGrid::GetNextK | ( | ) | const [inline] |
Definition at line 292 of file cmtkDataGrid.h.
size_t cmtk::DataGrid::GetNumberOfPixels | ( | ) | const [inline] |
Get number of data items in the volume.
Definition at line 164 of file cmtkDataGrid.h.
Referenced by cmtk::VolumeInjectionReconstruction::AddLaplacianGradientImage(), cmtk::UniformDistanceMap< TDistanceDataType >::BuildDistanceMap(), cmtk::VolumeInjectionReconstruction::ComputeCorrectedImageLaplacianNorm(), cmtk::InverseInterpolationVolumeReconstruction< TInterpolator >::ComputeErrorGradientImage(), cmtk::DeviceUniformVolume::DeviceUniformVolume(), cmtk::ReformatVolume::GetTransformedReference(), cmtk::ReformatVolume::GetTransformedReferenceJacobianAvg(), cmtk::ReformatVolume::ReformatMasked(), cmtk::ReformatVolume::ReformatUnmasked(), cmtk::EntropyMinimizationIntensityCorrectionFunctionalBase::SetForegroundMask(), cmtk::EntropyMinimizationIntensityCorrectionFunctionalBase::UpdateOutputImageThreadFunc(), cmtk::VolumeInjectionReconstruction::VolumeInjectionIsotropic(), and cmtk::VoxelMatchingCorrRatio< I >::VoxelMatchingCorrRatio().
size_t cmtk::DataGrid::GetOffsetFromIndex | ( | const int | x, |
const int | y, | ||
const int | z | ||
) | const [inline] |
Get offset of a pixel.
Definition at line 173 of file cmtkDataGrid.h.
Referenced by cmtk::SplineWarpGroupwiseRegistrationRMIFunctional::EvaluateLocalGradientThreadFunc(), cmtk::SplineWarpCongealingFunctional::EvaluateLocalGradientThreadFunc(), cmtk::FilterVolume::GaussianFilter(), and cmtk::FilterVolume::StudholmeFilter().
bool cmtk::DataGrid::GridMatches | ( | const Self & | other ) | const [inline] |
Test whether this grid matches another one, i.e., has the same dimensions.
Reimplemented in cmtk::UniformVolume.
Definition at line 113 of file cmtkDataGrid.h.
References m_Dims.
bool cmtk::DataGrid::IndexIsInRange | ( | const int | x, |
const int | y, | ||
const int | z | ||
) | const [inline] |
Check whether given pixel index is inside grid.
Definition at line 167 of file cmtkDataGrid.h.
Referenced by cmtk::QtTriplanarWindow::UpdateGridInfo().
void cmtk::DataGrid::SetCropRegion | ( | const Self::RegionType & | region ) | [virtual] |
Set cropped region.
This function can deal with negative crop region values, which refer to the upper grid boundary and are automatically converted.
Reimplemented in cmtk::UniformVolume.
Definition at line 40 of file cmtkDataGrid_Crop.cxx.
References cmtk::Region< NDIM, T >::From().
void cmtk::DataGrid::SetDataAt | ( | const Types::DataItem | data, |
const int | x, | ||
const int | y, | ||
const int | z | ||
) | [inline] |
Set data at specified grid point.
Definition at line 205 of file cmtkDataGrid.h.
void cmtk::DataGrid::SetDataAt | ( | const Types::DataItem | data, |
const size_t | offset | ||
) | [inline] |
Set data at specified offset.
Definition at line 193 of file cmtkDataGrid.h.
Self::RegionType cmtk::DataGrid::m_CropRegion [private] |
Crop region.
Definition at line 411 of file cmtkDataGrid.h.
Number of grid samples in the three spatial dimensions.
Definition at line 90 of file cmtkDataGrid.h.
Referenced by cmtk::AffineXformUniformVolume::AffineXformUniformVolume(), cmtk::UniformDistanceMap< TDistanceDataType >::BuildDistanceMap(), cmtk::DeformationField::DeformationField(), cmtk::DeviceUniformVolume::DeviceUniformVolume(), cmtk::FilterVolume::GaussianFilter(), GridMatches(), cmtk::VolumeInjectionReconstruction::GuessInterleaveAxis(), cmtk::TransformedVolumeAxes::MakeHash(), cmtk::SplineWarpXformUniformVolume::RegisterVolume(), cmtk::SplineWarpXform::RegisterVolume(), cmtk::UniformVolume::ResampleThreadPoolExecuteGrey(), cmtk::UniformVolume::ResampleThreadPoolExecuteLabels(), cmtk::UniformVolume::UniformVolume(), cmtk::VolumeGridToGridLookup::VolumeGridToGridLookup(), and cmtk::VolumeFromFile::WriteMetaImage().
int cmtk::DataGrid::nextI [protected] |
Offset to next voxel column.
Definition at line 384 of file cmtkDataGrid.h.
int cmtk::DataGrid::nextIJ [protected] |
Offset to next column and row.
Definition at line 393 of file cmtkDataGrid.h.
int cmtk::DataGrid::nextIJK [protected] |
Offset to next column, row, and plane.
Definition at line 402 of file cmtkDataGrid.h.
int cmtk::DataGrid::nextIK [protected] |
Offset to next column and plane.
Definition at line 396 of file cmtkDataGrid.h.
int cmtk::DataGrid::nextJ [protected] |
Offset to next voxel row.
Definition at line 387 of file cmtkDataGrid.h.
int cmtk::DataGrid::nextJK [protected] |
Offset to next row and plane.
Definition at line 399 of file cmtkDataGrid.h.
int cmtk::DataGrid::nextK [protected] |
Offset to next voxel plane.
Definition at line 390 of file cmtkDataGrid.h.