21 #ifndef MIRTK_ImageAttributes_H 22 #define MIRTK_ImageAttributes_H 24 #include "mirtk/Indent.h" 25 #include "mirtk/Matrix.h" 26 #include "mirtk/Point.h" 27 #include "mirtk/Array.h" 105 double XSize()
const;
108 double YSize()
const;
111 double ZSize()
const;
114 double TSize()
const;
126 ImageAttributes(
int,
int,
int,
double = 1.0,
double = 1.0,
double = 1.0);
129 ImageAttributes(
int,
int,
int,
int,
double = 1.0,
double = 1.0,
double = 1.0,
double = 1.0);
138 operator bool()
const;
165 void IndexToLattice(
int,
int *,
int *,
int * = NULL,
int * = NULL)
const;
180 void IndexToWorld(
int,
double &,
double &,
double &)
const;
198 void LatticeToWorld(
double *,
double *,
double *,
double *)
const;
258 bool IsInside(
int,
int,
int,
int)
const;
270 bool IsOutside(
int,
int,
int,
int)
const;
294 double Space()
const;
335 if (i == 0)
return _x;
336 if (i == 1)
return _y;
337 if (i == 2)
return _z;
338 if (i == 3)
return _t;
345 if (i == 0)
return _dx;
346 if (i == 1)
return _dy;
347 if (i == 2)
return _dz;
348 if (i == 3)
return _dt;
401 inline ImageAttributes::operator bool()
const 404 return _x > 0 &&
_y > 0 &&
_z > 0 &&
_t > 0 &&
_dx > .0 &&
_dy > .0 &&
_dz >= .0;
416 return !(*
this == attr);
422 return i +
_x * (j +
_y * (k +
_z * l));
429 if (l) *l = index / n;
432 if (k) *k = index / n;
577 return (0 <= idx && idx <
_x *
_y *
_z *
_t);
583 return (0 <= i && i <
_x) && (0 <= j && j <
_y);
595 return IsInside(i, j, k) && (0 <= l && l <
_t);
625 return (i == 0 || i ==
_x - 1) || (j == 0 || j ==
_y - 1);
694 #endif // MIRTK_ImageAttributes_H double YSize() const
Get voxel size/spacing of lattice points in y dimension.
double _dt
Voxel t-dimensions (in ms)
double _xaxis[3]
Direction of x-axis.
ImageAttributes & operator=(const ImageAttributes &)
Copy operator.
void Print(ostream &, Indent=0) const
Print attributes.
const Matrix * _i2w
Pointer to pre-computed image to world matrix (cf. BaseImage::_matI2W)
void WorldToLattice(double &, double &, double &) const
Convert world to lattice coordinate.
Matrix GetWorldToImageMatrix() const
Alias for GetWorldToLatticeMatrix.
double Spacing(int) const
Get spacing of lattice points in i-th dimension.
double Volume() const
Image volume in world space.
Matrix _smat
Affine transformation matrix.
void PutAffineMatrix(const Matrix &m, bool apply=false)
double _torigin
Image t-origin (in ms)
double _x
x coordinate of Point
int _y
Image y-dimension (in voxels)
int Z() const
Get number of lattice points in z dimension.
ImageAttributes()
Constructor.
bool IsOutside(int) const
Whether voxel is index is outside finite image domain.
bool operator==(const ImageAttributes &attr) const
Equality operator.
Matrix GetImageToWorldOrientation() const
Alias for GetLatticeToWorldOrientation.
double _xorigin
Image x-origin (in mm)
int NumberOfPoints() const
ImageAttributes OverallFieldOfView(const Array< ImageAttributes > &)
double Space() const
Amount of space occupied by the image in n-D world space (excluding time dimension) ...
double XSize() const
Get voxel size/spacing of lattice points in x dimension.
double XSpacing() const
Get spacing of lattice points in x dimension.
Matrix GetImageToWorldMatrix() const
Alias for GetLatticeToWorldMatrix.
void IndexToWorld(int, double &, double &) const
Get world coordinates (in mm) of lattice point.
Matrix GetWorldToLatticeMatrix() const
Return transformation matrix for world to lattice coordinates.
int _z
Image z-dimension (in voxels)
double _dz
Voxel z-dimensions (in mm)
int _t
Image t-dimension (in voxels)
int T() const
Get number of lattice points in t dimension.
int Y() const
Get number of lattice points in y dimension.
double _zorigin
Image z-origin (in mm)
int LatticeToIndex(int, int, int=0, int=0) const
Get Index from Lattice.
double ZSpacing() const
Get spacing of lattice points in z dimension.
Matrix GetWorldToLatticeOrientation() const
Return orientation part of lattice to world coordinate transformation.
Matrix GetWorldToImageOrientation() const
Alias for GetWorldToLatticeOrientation.
bool ContainsInSpace(const ImageAttributes &attr) const
Whether given lattice is fully contained by this image lattice.
double LatticeToTime(double) const
Convert lattice to time coordinate.
int NumberOfSpatialPoints() const
Number of spatial lattice points.
double _zaxis[3]
Direction of z-axis.
bool EqualInSpace(const ImageAttributes &attr) const
Whether spatial attributes are equal.
double _yorigin
Image y-origin (in mm)
double TSize() const
Get voxel size/spacing of lattice points in t dimension.
double _dy
Voxel y-dimensions (in mm)
double TimeToLattice(double) const
Convert time to lattice coordinate.
bool operator!=(const ImageAttributes &attr) const
Inequality operator.
bool EqualInTime(const ImageAttributes &attr) const
Whether temporal attributes are equal.
double Area() const
Image slice area in world space.
int X() const
Get number of lattice points in x dimension.
int NumberOfLatticePoints() const
Number of lattice points in image domain.
double ZSize() const
Get voxel size/spacing of lattice points in z dimension.
double YSpacing() const
Get spacing of lattice points in y dimension.
double _z
z coordinate of Point
void LatticeToWorld(Point &) const
Convert lattice to world coordinate.
void IndexToLattice(int, int *, int *, int *=NULL, int *=NULL) const
Get Index from Lattice.
double TSpacing() const
Get spacing of lattice points in t dimension.
int _x
Image x-dimension (in voxels)
bool IsInside(int) const
Whether voxel index is within finite image domain.
int N(int) const
Get number of lattice points in i-th dimension.
double _y
y coordinate of Point
Matrix GetLatticeToWorldOrientation() const
Return orientation part of lattice to world coordinate transformation.
bool IsBoundary(int) const
Whether voxel index is at boundary of finite image domain.
double _dx
Voxel x-dimensions (in mm)
Matrix GetLatticeToWorldMatrix() const
Return transformation matrix for lattice to world coordinates.
void Transform(Array< T > &values, UnaryOperation op)
Apply unary operation for each array element in-place.
const Matrix * _w2i
Pointer to pre-computed world to image matrix (cf. BaseImage::_matW2I)
ImageAttributes OrthogonalFieldOfView(const ImageAttributes &)
double _yaxis[3]
Direction of y-axis.