13 #ifndef ML_TSUB_IMAGE_H
14 #define ML_TSUB_IMAGE_H
30 #pragma warning(disable: 4244)
39 template <
typename DATATYPE>
class TSubImageCursor;
41 template <
typename DATATYPE>
class ConstTSubImageCursor;
44 #define _ML_TSUBIMG_SUBDOT6(pos, offset, stride) \
45 (((pos).x - (offset).x) * (stride).x + \
46 ((pos).y - (offset).y) * (stride).y + \
47 ((pos).z - (offset).z) * (stride).z + \
48 ((pos).c - (offset).c) * (stride).c + \
49 ((pos).t - (offset).t) * (stride).t + \
50 ((pos).u - (offset).u) * (stride).u)
53 #define _ML_TSUBIMG_SUBDOT3(x, y, z, offset, stride) \
54 (((x) - (offset).x) * (stride).x + \
55 ((y) - (offset).y) * (stride).y + \
56 ((z) - (offset).z) * (stride).z)
59 #define _ML_TSUBIMG_SUBDOT2(x, y, offset, stride) \
60 (((x) - (offset).x) * (stride).x + \
61 ((y) - (offset).y) * (stride).y)
108 template <
typename DATATYPE>
143 "Mismatch of data type between argument and template typename.");
158 "Data type has no registered TypeTraits.");
172 setBox(subImage.
getBox());
188 "Mismatch of data type between argument and template typename.");
206 SubImage::operator=(typedSubImage);
217 inline const DATATYPE*
getData()
const {
return static_cast<DATATYPE*
>(_data); }
218 inline DATATYPE*
getData() {
return static_cast<DATATYPE*
>(_data); }
275 {
return getStride().
getVectorPosition(pointer -
static_cast<DATATYPE*
>(_data)); }
284 const MLint offset = pointer -
static_cast<DATATYPE*
>(_data);
291 *x = (offset/stride.x) % imgExt.
x;
297 *y = (offset/stride.y) % imgExt.
y;
303 *z = (offset/stride.z) % imgExt.
z;
312 {
return convertPointerToSubImagePosition(pointer) + _box.v1; }
322 convertPointerToSubImagePosition(pointer, x, y, z);
323 if (x){ *x += _box.v1.x; }
324 if (y){ *y += _box.v1.y; }
325 if (z){ *z += _box.v1.z; }
351 inline void setSubImageValue(
const ImageVector& position, DATATYPE value) {
static_cast<DATATYPE*
>(_data)[ ImageVector::dot(position,_stride) ]=value; }
356 inline DATATYPE
getSubImageValue(
const ImageVector& position)
const {
return static_cast<DATATYPE*
>(_data)[ ImageVector::dot(position,_stride) ]; }
425 const SubImageBox box = validBox ? SubImageBox::intersect(thisBox, *validBox) : thisBox;
429 if (numVoxels==0){ minValue=0; maxValue=0;
return 0; }
432 minValue = maxValue = getImageValue(box.
v1);
439 const DATATYPE* dataEnd =
static_cast<DATATYPE*
>(_data) + numVoxels;
442 for (DATATYPE* i=
static_cast<DATATYPE*
>(_data)+1; i<dataEnd; ++i)
444 if (*i < minValue){ minValue = *i; }
445 if (*i > maxValue){ maxValue = *i; }
457 p.
set(box.
v1.
x, y, z, c, t, u);
458 const DATATYPE *dPtr = getImagePointer(p);
460 for (
MLint x=box.
v1.
x; x <= pEnd; ++x, ++dPtr){
461 if (*dPtr < minValue){ minValue = *dPtr; }
462 if (*dPtr > maxValue){ maxValue = *dPtr; }
482 #define _ML_CHECK_SUBIMAGE_DATA_POINTERS(FROM_PTR, TO_PTR) \
485 if (!FROM_PTR || !TO_PTR){ \
486 ML_PRINT_ERROR("TSubImage::copySubImageTyped( )", \
487 ML_BAD_POINTER_OR_0, \
488 "Valid data pointers in source and target subimage required for" \
489 "subimage copying, thus call is ignored."); \
497 template <
typename FROM_DATATYPE>
507 const SubImageBox intersection = SubImageBox::intersect(typedFromImage.
getBox(),getBox());
514 const FROM_DATATYPE* fromPt =
nullptr;
515 DATATYPE* toPt =
nullptr;
519 const ImageVector offsetReordered(_box.v1.c, _box.v1.x, _box.v1.y, _box.v1.z, _box.v1.t, _box.v1.u);
529 if (identicalScaling) {
530 for (p.
u=intersection.
v1.
u; p.
u<=intersection.
v2.
u; ++p.
u) {
531 for (p.
t=intersection.
v1.
t; p.
t<=intersection.
v2.
t; ++p.
t) {
532 for (p.
c=intersection.
v1.
c; p.
c<=intersection.
v2.
c; ++p.
c) {
533 for (p.
z=intersection.
v1.
z; p.
z<=intersection.
v2.
z; ++p.
z) {
534 for (p.
y=intersection.
v1.
y; p.
y<=intersection.
v2.
y; ++p.
y) {
539 toPt =
static_cast<DATATYPE*
>(_data) +
_ML_TSUBIMG_SUBDOT6(posReordered, offsetReordered, toStrides);
541 for (p.
x = intersection.
v1.
x; p.
x <= intersection.
v2.
x; ++p.
x, ++fromPt) {
542 *toPt =
static_cast<DATATYPE
>(*fromPt);
551 for (p.
u=intersection.
v1.
u; p.
u<=intersection.
v2.
u; ++p.
u) {
552 for (p.
t=intersection.
v1.
t; p.
t<=intersection.
v2.
t; ++p.
t) {
553 for (p.
c=intersection.
v1.
c; p.
c<=intersection.
v2.
c; ++p.
c) {
554 for (p.
z=intersection.
v1.
z; p.
z<=intersection.
v2.
z; ++p.
z) {
555 for (p.
y=intersection.
v1.
y; p.
y<=intersection.
v2.
y; ++p.
y) {
560 toPt =
static_cast<DATATYPE*
>(_data) +
_ML_TSUBIMG_SUBDOT6(posReordered, offsetReordered, toStrides);
562 for (p.
x = intersection.
v1.
x; p.
x <= intersection.
v2.
x; ++p.
x, ++fromPt) {
563 *toPt =
static_cast<DATATYPE
>(
static_cast<MLdouble>(*fromPt)*scaleDbl + shiftDbl);
589 template <
typename FROM_DATATYPE>
597 if (scaleShiftData.
getReorderMode() == ScaleShiftData::ReorderColorPlanesToInterleaved) {
598 copySubImageReorderColorPlanesToInterleaved(typedFromImg, scaleShiftData);
608 copySubImage(typedFromImg);
618 if (getBox()==typedFromImg.
getBox()){
621 const FROM_DATATYPE *fromPt = typedFromImg.
getData();
622 DATATYPE *toPt = getData();
628 const MLint size = getNumVoxels();
632 memcpy( toPt, fromPt, bytesize );
636 if (!isDTScalarType){
640 for (DATATYPE* toPtEnd=toPt+size; toPt<toPtEnd; ++toPt){
641 *toPt=
static_cast<DATATYPE
>(
static_cast<DATATYPE
>(*toPt)*scaleDbl + shiftDbl);
645 for (DATATYPE* toPtEnd=toPt+size; toPt<toPtEnd; ++toPt){
646 *toPt=
static_cast<DATATYPE
>(
static_cast<MLdouble>(*toPt)*scaleDbl + shiftDbl);
654 const SubImageBox intersection = SubImageBox::intersect(typedFromImg.
getBox(),getBox());
661 const FROM_DATATYPE *fromPt =
nullptr;
662 DATATYPE *toPt =
nullptr,
667 const MLint dist = intersection.
v2.
x - intersection.
v1.
x;
668 const MLint size_x = dist+1;
672 for (p.
u=intersection.
v1.
u; p.
u<=intersection.
v2.
u; ++p.
u){
673 for (p.
t=intersection.
v1.
t; p.
t<=intersection.
v2.
t; ++p.
t){
674 for (p.
c=intersection.
v1.
c; p.
c<=intersection.
v2.
c; ++p.
c){
675 for (p.
z=intersection.
v1.
z; p.
z<=intersection.
v2.
z; ++p.
z){
680 toPt = getImagePointer(pos);
684 for (p.
y=intersection.
v1.
y; p.
y<=intersection.
v2.
y; ++p.
y,fromPt+=fromStr.
y,toPt+=toStr.
y){
687 memcpy(toPt, fromPt, bytesize_x);
690 if (!isDTScalarType){
692 for (toPtEnd = toPt_+size_x;
695 *toPt_=
static_cast<DATATYPE
>(
static_cast<DATATYPE
>(*toPt_)*scaleDbl + shiftDbl);
699 for (toPtEnd = toPt_+size_x;
702 *toPt_=
static_cast<DATATYPE
>(
static_cast<MLdouble>(*toPt_)*scaleDbl + shiftDbl);
718 const SubImageBox intersection = SubImageBox::intersect(typedFromImg.
getBox(),getBox());
725 const FROM_DATATYPE *fromPt =
nullptr;
726 DATATYPE *toPt =
nullptr;
729 for (p.
u=intersection.
v1.
u; p.
u<=intersection.
v2.
u; ++p.
u){
730 for (p.
t=intersection.
v1.
t; p.
t<=intersection.
v2.
t; ++p.
t){
731 for (p.
c=intersection.
v1.
c; p.
c<=intersection.
v2.
c; ++p.
c){
732 for (p.
z=intersection.
v1.
z; p.
z<=intersection.
v2.
z; ++p.
z){
733 for (p.
y=intersection.
v1.
y; p.
y<=intersection.
v2.
y; ++p.
y){
738 toPt = getImagePointer(pos);
739 const MLint startX = intersection.
v1.
x;
740 const MLint endX = intersection.
v2.
x;
742 if (!isFDTScalarType){
745 for (p.
x = startX; p.
x <= endX; ++p.
x, ++fromPt, ++toPt){
746 *toPt=
static_cast<DATATYPE
>(
static_cast<FROM_DATATYPE
>(*fromPt)*scaleDbl + shiftDbl);
750 for (p.
x = startX; p.
x <= endX; ++p.
x, ++fromPt, ++toPt){
751 *toPt=
static_cast<DATATYPE
>(
static_cast<MLdouble>(*fromPt)*scaleDbl + shiftDbl);
777 inline void fill(DATATYPE value)
781 const DATATYPE* dataEnd =
static_cast<DATATYPE*
>(_data) + getNumVoxels();
783 for (DATATYPE* i =
static_cast<DATATYPE*
>(_data); i<dataEnd; ++i){ *i=value; }
796 SubImage::fillBordersWithTypeData(box,
reinterpret_cast<const MLTypeData*
>(&fillValue));
804 fillBordersWithValue(getValidRegion(), value);
813 fillBordersWithBorderValues(getValidRegion());
822 template <
typename DATATYPE>
828 _data =
const_cast<DATATYPE*
>(subImage.
getData());
829 _subImageOffset = subImage.
getBox().
v1;
853 inline void setPosition(
const DATATYPE *pointer) { _cursor =
const_cast<DATATYPE*
>(pointer); }
859 inline void moveX() { _cursor += _stride.x; }
861 inline void moveY() { _cursor += _stride.y; }
863 inline void moveZ() { _cursor += _stride.z; }
865 inline void moveC() { _cursor += _stride.c; }
867 inline void moveT() { _cursor += _stride.t; }
869 inline void moveU() { _cursor += _stride.u; }
894 inline DATATYPE
getValue()
const {
return *(_cursor); }
919 template <
typename DATATYPE>
933 inline const DATATYPE*
getPointer()
const {
return T::_cursor; }
945 template <
typename DATATYPE>
976 inline void setValue(DATATYPE value)
const { *(T::_cursor) = value; }
988 template <
typename DATATYPE>
1018 _cursor = tSubImg._cursor;
1039 inline void setCursorPosition(
const DATATYPE* pointer) { _cursor =
const_cast<DATATYPE*
>(pointer); }
1134 template <
typename T>
1141 "Mismatch of data type between argument and template typename.");
1146 template <
typename T>
1153 "Mismatch of data type between argument and template typename.");
1158 template <
typename T>
1165 "Mismatch of data type between argument and template typename.");
1170 template <
typename T>
1177 "Mismatch of data type between argument and template typename.");
1195 template <
typename DATATYPE>
1196 inline ostream &
operator<<(ostream &ostr,
const ML_NAMESPACE::TSubImage<DATATYPE> &v)
1201 for (p.u=box.v1.u; p.u<=box.v2.u; ++p.u){
1202 for (p.t=box.v1.t; p.t<=box.v2.t; ++p.t){
1203 for (p.c=box.v1.c; p.c<=box.v2.c; ++p.c){
1204 for (p.z=box.v1.z; p.z<=box.v2.z; ++p.z){
1205 for (p.y=box.v1.y; p.y<=box.v2.y; ++p.y){
1209 for (; p.x<=box.v2.x; p.x++){
1210 ostr << v.getImageValue(p) <<
" ";
1224 #pragma warning(pop)
Predeclaration for const cursor.
ConstTSubImageCursor(const TSubImage< DATATYPE > &subImage)
const DATATYPE * getPointer() const
const DATATYPE * getPointerWithOffset(const ImageVector &offset) const
Returns the cursor position of the voxel computed from the current cursor shifted by offset.
const DATATYPE * getPointerWithOffset(MLint dx, MLint dy, MLint dz) const
Returns the cursor position of the voxel computed from the current cursor shifted by (dx,...
This class manages/represents a rectangular 6D image region that is organized linearly in memory.
void * getData() const
Returns the memory address of the memory managed by the subimage.
MLDataType getDataType() const
Returns the type of image data.
ImageVector getStride() const
Returns a stride vector to address the memory efficiently.
const SubImageBox & getBox() const
Returns the box describing the origin/extent of the subimage.
ImageVector getSourceImageExtent() const
Returns the image extent of the source image that was used to create this SubImage.
void set(const ComponentType v=0)
Sets all components to v or - if v is not specified - to 0.
DT getScale() const
Returns the scale constant of the transformation y=scale*x+offset.
ReorderMode getReorderMode() const
Returns the reorder mode.
DT getShift() const
Returns the addition constant of the transformation y=scale*x+shift.
VectorType v1
Corner v1 of the subimage region (included in region).
VectorType v2
Corner v2 of the subimage region (also included in region!).
intT getNumVoxels() const
Returns number of voxels in the subimage region, i.e., the product of all extents if this is not empt...
bool isEmpty() const
Returns true if subimage region is empty, i.e., if any of the components of v1 is greater than the co...
Base class for all TSubImage Cursors.
void reverseMoveC()
Moves the cursor backward in c direction.
void moveT()
Moves the cursor forward in t direction.
void reverseMoveX()
Moves the cursor backward in x direction.
void moveZ()
Moves the cursor forward in z direction.
void setPosition(const DATATYPE *pointer)
Sets the cursor to the given pointer where the pointer is the memory address of the voxel.
void reverseMoveY()
Moves the cursor backward in y direction.
DATATYPE getValue() const
Returns the voxel value at cursor position.
void reverseMoveT()
Moves the cursor backward in t direction.
ImageVector _stride
Stride for the subimage.
void moveU()
Moves the cursor forward in u direction.
void setSubImagePosition(MLint x, MLint y, MLint z)
Sets the cursor to the given 3D position (x, y, z) relative to the origin of the subimage region.
DATATYPE getValueWithOffset(MLint dx, MLint dy, MLint dz) const
Return the voxel value at (cursor position + (dx, dy, dz))
void moveX()
Moves the cursor forward in x direction.
DATATYPE getValueWithOffset(const ImageVector &offset) const
Returns the voxel value at (cursor position + offset).
ImageVector _subImageOffset
SubImage offset in original image.
DATATYPE * _data
SubImage data.
void reverseMoveZ()
Moves the cursor backward in z direction.
void setImagePosition(const ImageVector &position)
Sets the cursor to the given 6D position relative to the origin of the complete image region.
void moveByOffset(const ImageVector &offset)
Moves the cursor to cursor position + offset.
DATATYPE * _cursor
Cursor address for image data access.
void reverseMoveU()
Moves the cursor backward in u direction.
TSubImageCursorBase(const TSubImage< DATATYPE > &subImage)
void moveY()
Moves the cursor forward in y direction.
void setSubImagePosition(const ImageVector &position)
Sets the cursor to the given position relative to the origin of the subimage region.
void moveByOffset(MLint x, MLint y, MLint z)
Moves the cursor to cursor position + (x, y, z).
void setImagePosition(MLint x, MLint y, MLint z)
Sets the cursor to the given 3D position (x, y, z) relative to the origin of the complete image regio...
void moveC()
Moves the cursor forward in c direction.
Predeclaration for cursor.
void setValueWithOffset(MLint dx, MLint dy, MLint dz, DATATYPE value) const
Sets the voxel value at (cursor position + (dx, dy, dz)) to value.
TSubImageCursor(TSubImage< DATATYPE > &subImage)
void setValueWithOffset(const ImageVector &offset, DATATYPE value) const
Sets the voxel value at (cursor position + offset) to value.
void setValue(DATATYPE value) const
Sets the voxel value at the cursor position to value.
DATATYPE * getPointerWithOffset(MLint dx, MLint dy, MLint dz) const
Returns the cursor position of the voxel computed from the current cursor shifted by (dx,...
DATATYPE * getPointerWithOffset(const ImageVector &offset) const
Returns the cursor position of the voxel computed from the current cursor shifted by offset.
DATATYPE * getPointer() const
A class that offers a TSubImage with a TSubImageCursor.
void setCursorValue(DATATYPE value)
Sets the voxel value at the cursor position to value.
void reverseMoveCursorC()
Moves the cursor backward in c direction.
void moveCursorT()
Moves the cursor forward in t direction.
DATATYPE * getCursorPointer() const
void moveCursorByOffset(const ImageVector &offset)
Moves the cursor to cursor position + offset.
void setCursorImagePosition(MLint x, MLint y, MLint z)
Sets the cursor to the given 3D position (x, y, z) relative to the origin of the complete image regio...
DATATYPE getCursorValue() const
Returns the voxel value at the cursor position.
void reverseMoveCursorU()
Moves the cursor backward in u direction.
void reverseMoveCursorY()
Moves the cursor backward in y direction.
DATATYPE * getCursorPointerWithOffset(MLint dx, MLint dy, MLint dz) const
Returns the cursor pointer of the voxel computed from the current cursor shifted by (dx,...
DATATYPE getCursorValueWithOffset(MLint dx, MLint dy, MLint dz) const
Returns the voxel value at (cursor position + (dx, dy, dz))
void reverseMoveCursorX()
Moves the cursor backward in x direction.
void moveCursorByOffset(MLint x, MLint y, MLint z)
Moves the cursor to cursor position + (x, y, z).
TSubImageWithCursor(const TSubImage< DATATYPE > &subImage)
Constructor with TSubImage.
void moveCursorZ()
Moves the cursor forward in z direction.
void reverseMoveCursorZ()
Moves the cursor backward in z direction.
void moveCursorC()
Moves the cursor forward in c direction.
void reverseMoveCursorT()
Moves the cursor backward in t direction.
void setCursorValueWithOffset(const ImageVector &offset, DATATYPE value)
Sets the voxel value at (cursor position + offset) to value.
void setCursorImagePosition(const ImageVector &position)
Sets the cursor to the given 6D position relative to the origin of the complete image region.
void setCursorPosition(const DATATYPE *pointer)
Sets the cursor to the given pointer where pointer is the memory address of the voxel.
DATATYPE * getCursorPointerWithOffset(const ImageVector &offset) const
Returns the cursor pointer of the voxel computed from the current cursor shifted by offset.
TSubImageWithCursor & operator=(const TSubImageWithCursor< DATATYPE > &tSubImg)
Assignment operator to get an identical copy.
void moveCursorY()
Moves the cursor forward in y direction.
void moveCursorX()
Moves the cursor forward in x direction.
TSubImageWithCursor(const TSubImageWithCursor &subImage)
Constructor with TSubImageWithCursor.
TSubImageWithCursor(const SubImage &subImage)
Constructor with SubImage.
void moveCursorU()
Moves the cursor forward in u direction.
DATATYPE getCursorValueWithOffset(const ImageVector &offset) const
Returns the voxel value at (cursor position + offset)
void setCursorSubImagePosition(MLint x, MLint y, MLint z)
Sets the cursor to the given 3D position (x, y, z) relative to the origin of the subimage region.
void setCursorSubImagePosition(const ImageVector &position)
Sets the cursor to the given position relative to the origin of the subimage region.
TSubImageWithCursor()
Default constructor.
void setCursorValueWithOffset(MLint dx, MLint dy, MLint dz, DATATYPE value)
Sets voxel value at (cursor position + (dx, dy,dz)) to value.
This template class manages/represents a rectangular 6D image region in memory that is organized line...
TSubImage(const SubImage &subImage)
Constructor to build a typed subimage from an untyped subImage.
DATATYPE getSubImageValue(MLint x, MLint y, MLint z) const
Returns the voxel value at the given position (x, y, z) where the position is relative to the origin ...
void copySubImageTyped(const TSubImage< FROM_DATATYPE > &typedFromImg, const ScaleShiftData &scaleShiftData)
Copies image data from the subimage fromImg into the overlapping region of this subimage.
TSubImage(const TSubImage< DATATYPE > &typedSubImage)
Copy constructor to get an identical copy.
void copySubImageReorderColorPlanesToInterleaved(const TSubImage< FROM_DATATYPE > &typedFromImage, const ScaleShiftData &scaleShiftData)
Implements special case for void copySubImageTyped(const TSubImage<FROM_DATATYPE> &typedFromImg,...
void setSubImageValue(MLint x, MLint y, DATATYPE value)
Sets the voxel value at the given position(x, y) to the given value where the position is relative to...
DATATYPE getImageValue(MLint x, MLint y) const
Returns the 2D voxel value from the given position (x, y).
TSubImage(const SubImageBox &box, MLDataType dataType, void *data)
Constructor for an image region with location/extent box with data type dataType (must fit to DATATYP...
const DATATYPE * getImagePointer(const ImageVector &position) const
Returns a pointer to voxel data of image voxel at 6D position position relative to the origin of the ...
void setImageValue(const ImageVector &position, DATATYPE value)
Sets the 6D voxel at the given position to the given value.
DATATYPE getSubImageValue(MLint x, MLint y) const
Returns the voxel value at position (x, y) where the position is relative to the origin of the subima...
const DATATYPE * getImagePointer(MLint x, MLint y, MLint z) const
Returns a pointer to voxel data of image voxel at 3D position p=(x, y, z) relative to the origin of t...
ConstTSubImageCursor< DATATYPE > ConstCursor
A read-only cursor.
~TSubImage() override=default
Virtual destructor to suppress compiler warnings.
void fill(DATATYPE value)
Sets all voxel values in subimage to value.
TSubImage & operator=(const TSubImage< DATATYPE > &typedSubImage)
Assignment operator to get an identical copy.
ImageVector convertPointerToImagePosition(DATATYPE *pointer) const
Returns the 6D voxel coordinates corresponding to the memory address pointer.
DATATYPE getImageValue(MLint x, MLint y, MLint z) const
Returns the 3D voxel value from given position (x, y, z).
TSubImageCursor< DATATYPE > Cursor
A read/write cursor.
ImageVector convertPointerToSubImagePosition(DATATYPE *pointer) const
Returns the 6D voxel coordinates corresponding to the memory address pointer.
TSubImage()
Default constructor to build a typed subimage (with an empty box) from scratch.
DATATYPE getImageValue(const ImageVector &position) const
Returns the 6D voxel value from the given position.
DATATYPE * getSubImagePointer(const ImageVector &position)
void fillInvalidRegionWithValue(DATATYPE value)
Fills the invalid region (everything outside of getValidRegion()) with the given value.
DATATYPE * getImagePointer(MLint x, MLint y, MLint z)
DATATYPE ComponentType
A typedef to 'export' the type of voxels components.
void setImageValue(MLint x, MLint y, MLint z, DATATYPE value)
Sets the 3D voxel at the given position (x, y, z) to the given value.
void fillBordersWithValue(const SubImageBox &box, DATATYPE fillValue)
Fills all regions with fillValue that are not covered by box.
DATATYPE getSubImageValue(const ImageVector &position) const
Returns voxel value at the given position where position is relative to the origin of the subimage re...
void setSubImageValue(const ImageVector &position, DATATYPE value)
Sets the voxel value at the given position to the given value where position is relative to the origi...
MLint calculateMinMax(DATATYPE &minValue, DATATYPE &maxValue, const SubImageBox *const validBox=nullptr) const
Scans subimage and determines the minimum and maximum values of the region that is part of subimage b...
void convertPointerToSubImagePosition(DATATYPE *pointer, MLint *x, MLint *y, MLint *z) const
Returns the 3D voxel coordinates corresponding to the memory address pointer.
DATATYPE & operator[](const ImageVector &position)
Reference access to voxel value at the given position.
DATATYPE * getSubImagePointer(MLint x, MLint y, MLint z)
const DATATYPE * getData() const
Returns the memory address of the image region. Overloads methods from SubImage.
const DATATYPE * getSubImagePointer(const ImageVector &position) const
Returns a pointer to voxel data of image voxel at the 6D position relative to the origin of the subim...
void setImageValue(MLint x, MLint y, DATATYPE value)
Sets the 2D voxel at the given position (x, y) to the the given value.
void setSubImageValue(MLint x, MLint y, MLint z, DATATYPE value)
Sets the voxel value at the given position (x, y, z) to the given value where the position is relativ...
const DATATYPE * getSubImagePointer(MLint x, MLint y, MLint z) const
Returns a pointer to voxel data of image voxel at 3D position p=(x, y, z) relative to the origin of t...
const DATATYPE & operator[](const ImageVector &position) const
Constant reference access to voxel value at the given position.
void convertPointerToImagePosition(DATATYPE *pointer, MLint *x, MLint *y, MLint *z) const
Returns the 3D voxel coordinates corresponding to the memory address pointer.
DATATYPE * getImagePointer(const ImageVector &position)
void fillInvalidRegionWithBorderValues()
Fills the invalid region (i.e., everything outside of getValidRegion() ) with the values on the borde...
ComponentType c
Color component of the vector.
ComponentType t
Time component of the vector.
ComponentType u
Unit/Modality/User component of the vector.
ComponentType z
Z component of the vector.
ComponentType x
X component of the vector.
ComponentType y
Y component of the vector.
TVector< TVectorBase > getStrides(const ComponentType offset=1) const
Interprets the vector as image extension and returns a stride vector.
TVector< TVectorBase > getVectorPosition(ComponentType offsetPos) const
Interprets the vector as a stride vector of an image and returns the offset position offsetPos from t...
MLEXPORT size_t MLSizeOf(MLDataType dataType)
Returns the size of the data type dataType in bytes.
#define ML_INVALID_DATA_TYPE
Defines an invalid MLDataType.
bool MLValuesAreEqual(MLint8 a, MLint8 b, MLint8)
Returns true if values are equal (numerically safely compared); otherwise, it returns false.
MLint32 MLDataType
MLDataType.
#define ML_BAD_DATA_TYPE
A wrong or unexpected data type has been passed to an algorithm, which often is a programming error.
#define ML_PRINT_FATAL_ERROR(FUNC_NAME, REASON, HANDLING)
Like ML_PRINT_FATAL_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be du...
#define ML_CHECK_THROW(x)
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator '<<' for stream output of Field objects.
#define _ML_TSUBIMG_SUBDOT6(pos, offset, stride)
Private helper macro for calculation of memory offset, calculates (pos-offset) * stride.
#define _ML_TSUBIMG_SUBDOT2(x, y, offset, stride)
Private helper macro for calculation of memory offset, calculates ((xy)-offset) * stride.
#define _ML_TSUBIMG_SUBDOT3(x, y, z, offset, stride)
Private helper macro for calculation of memory offset, calculates ((xyz)-offset) * stride.
#define _ML_CHECK_SUBIMAGE_DATA_POINTERS(FROM_PTR, TO_PTR)
Internal helper macro to check validity of data pointers of subimages.
MLint32 MLIsScalarTypePtr(const T *)
unsigned char MLTypeData
This is the pointer type used to point to the data of MLType data instances.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
TSubImageBox< MLint > SubImageBox
Defines the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type...
TImageVector< MLint > ImageVector
Defines the standard ImageVector type that is used by the ML for indexing and coordinates.
const TSubImage< T > * tsubimage_cast(const SubImage *subImg)
TypeTraits for scalar ML datatypes.