13#ifndef ML_TSUB_IMAGE_H
14#define ML_TSUB_IMAGE_H
30#pragma warning(disable: 4244)
39template <
typename DATATYPE>
class TSubImageCursor;
41template <
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)
108template <
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; }
451 for (
MLint u=box.
v1.u; u <= box.
v2.u; ++u){
452 for (
MLint t=box.
v1.t; t <= box.
v2.t; ++t){
453 for (
MLint c=box.
v1.c; c <= box.
v2.c; ++c){
454 for (
MLint z=box.
v1.z; z <= box.
v2.z; ++z){
455 for (
MLint y=box.
v1.y; y <= box.
v2.y; ++y){
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) {
536 const ImageVector pos(intersection.
v1.x,p.y,p.z,p.c,p.t,p.u);
537 const ImageVector posReordered(p.c, intersection.
v1.x,p.y,p.z,p.t,p.u);
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) {
557 const ImageVector pos(intersection.
v1.x,p.y,p.z,p.c,p.t,p.u);
558 const ImageVector posReordered(p.c, intersection.
v1.x,p.y,p.z,p.t,p.u);
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);
590 template <
typename FROM_DATATYPE>
598 if (scaleShiftData.
getReorderMode() == ScaleShiftData::ReorderColorPlanesToInterleaved) {
599 copySubImageReorderColorPlanesToInterleaved(typedFromImg, scaleShiftData);
609 copySubImage(typedFromImg);
619 if (getBox()==typedFromImg.
getBox()){
622 const FROM_DATATYPE *fromPt = typedFromImg.
getData();
623 DATATYPE *toPt = getData();
629 const MLint size = getNumVoxels();
633 memcpy( toPt, fromPt, bytesize );
637 if (!isDTScalarType){
641 for (DATATYPE* toPtEnd=toPt+size; toPt<toPtEnd; ++toPt){
642 *toPt=
static_cast<DATATYPE
>(
static_cast<DATATYPE
>(*toPt)*scaleDbl + shiftDbl);
646 for (DATATYPE* toPtEnd=toPt+size; toPt<toPtEnd; ++toPt){
647 *toPt=
static_cast<DATATYPE
>(
static_cast<MLdouble>(*toPt)*scaleDbl + shiftDbl);
655 const SubImageBox intersection = SubImageBox::intersect(typedFromImg.
getBox(),getBox());
662 const FROM_DATATYPE *fromPt =
nullptr;
663 DATATYPE *toPt =
nullptr,
668 const MLint dist = intersection.
v2.x - intersection.
v1.x;
669 const MLint size_x = dist+1;
673 for (p.u=intersection.
v1.u; p.u<=intersection.
v2.u; ++p.u){
674 for (p.t=intersection.
v1.t; p.t<=intersection.
v2.t; ++p.t){
675 for (p.c=intersection.
v1.c; p.c<=intersection.
v2.c; ++p.c){
676 for (p.z=intersection.
v1.z; p.z<=intersection.
v2.z; ++p.z){
679 const ImageVector pos(intersection.
v1.x, intersection.
v1.y, p.z, p.c, p.t, p.u);
681 toPt = getImagePointer(pos);
685 for (p.y=intersection.
v1.y; p.y<=intersection.
v2.y; ++p.y,fromPt+=fromStr.y,toPt+=toStr.y){
688 memcpy(toPt, fromPt, bytesize_x);
691 if (!isDTScalarType){
693 for (toPtEnd = toPt_+size_x;
696 *toPt_=
static_cast<DATATYPE
>(
static_cast<DATATYPE
>(*toPt_)*scaleDbl + shiftDbl);
700 for (toPtEnd = toPt_+size_x;
703 *toPt_=
static_cast<DATATYPE
>(
static_cast<MLdouble>(*toPt_)*scaleDbl + shiftDbl);
719 const SubImageBox intersection = SubImageBox::intersect(typedFromImg.
getBox(),getBox());
726 const FROM_DATATYPE *fromPt =
nullptr;
727 DATATYPE *toPt =
nullptr;
730 for (p.u=intersection.
v1.u; p.u<=intersection.
v2.u; ++p.u){
731 for (p.t=intersection.
v1.t; p.t<=intersection.
v2.t; ++p.t){
732 for (p.c=intersection.
v1.c; p.c<=intersection.
v2.c; ++p.c){
733 for (p.z=intersection.
v1.z; p.z<=intersection.
v2.z; ++p.z){
734 for (p.y=intersection.
v1.y; p.y<=intersection.
v2.y; ++p.y){
737 const ImageVector pos(intersection.
v1.x,p.y,p.z,p.c,p.t,p.u);
739 toPt = getImagePointer(pos);
740 const MLint startX = intersection.
v1.x;
741 const MLint endX = intersection.
v2.x;
743 if (!isFDTScalarType){
746 for (p.x = startX; p.x <= endX; ++p.x, ++fromPt, ++toPt){
747 *toPt=
static_cast<DATATYPE
>(
static_cast<FROM_DATATYPE
>(*fromPt)*scaleDbl + shiftDbl);
751 for (p.x = startX; p.x <= endX; ++p.x, ++fromPt, ++toPt){
752 *toPt=
static_cast<DATATYPE
>(
static_cast<MLdouble>(*fromPt)*scaleDbl + shiftDbl);
778 inline void fill(DATATYPE value)
782 const DATATYPE* dataEnd =
static_cast<DATATYPE*
>(_data) + getNumVoxels();
784 for (DATATYPE* i =
static_cast<DATATYPE*
>(_data); i<dataEnd; ++i){ *i=value; }
797 SubImage::fillBordersWithTypeData(box,
reinterpret_cast<const MLTypeData*
>(&fillValue));
805 fillBordersWithValue(getValidRegion(), value);
814 fillBordersWithBorderValues(getValidRegion());
823template <
typename DATATYPE>
829 _data =
const_cast<DATATYPE*
>(subImage.
getData());
830 _subImageOffset = subImage.
getBox().
v1;
854 inline void setPosition(
const DATATYPE *pointer) { _cursor =
const_cast<DATATYPE*
>(pointer); }
860 inline void moveX() { _cursor += _stride.x; }
862 inline void moveY() { _cursor += _stride.y; }
864 inline void moveZ() { _cursor += _stride.z; }
866 inline void moveC() { _cursor += _stride.c; }
868 inline void moveT() { _cursor += _stride.t; }
870 inline void moveU() { _cursor += _stride.u; }
895 inline DATATYPE
getValue()
const {
return *(_cursor); }
920template <
typename DATATYPE>
934 inline const DATATYPE*
getPointer()
const {
return T::_cursor; }
946template <
typename DATATYPE>
977 inline void setValue(DATATYPE value)
const { *(T::_cursor) = value; }
989template <
typename DATATYPE>
1019 _cursor = tSubImg._cursor;
1040 inline void setCursorPosition(
const DATATYPE* pointer) { _cursor =
const_cast<DATATYPE*
>(pointer); }
1135template <
typename T>
1142 "Mismatch of data type between argument and template typename.");
1147template <
typename T>
1154 "Mismatch of data type between argument and template typename.");
1159template <
typename T>
1166 "Mismatch of data type between argument and template typename.");
1171template <
typename T>
1178 "Mismatch of data type between argument and template typename.");
1196 template <
typename DATATYPE>
1197 inline ostream &
operator<<(ostream &ostr,
const ML_NAMESPACE::TSubImage<DATATYPE> &v)
1200 const ML_NAMESPACE::SubImageBox& box = v.getBox();
1201 ML_NAMESPACE::ImageVector p;
1202 for (p.u=box.v1.u; p.u<=box.v2.u; ++p.u){
1203 for (p.t=box.v1.t; p.t<=box.v2.t; ++p.t){
1204 for (p.c=box.v1.c; p.c<=box.v2.c; ++p.c){
1205 for (p.z=box.v1.z; p.z<=box.v2.z; ++p.z){
1206 for (p.y=box.v1.y; p.y<=box.v2.y; ++p.y){
1210 for (; p.x<=box.v2.x; p.x++){
1211 ostr << v.getImageValue(p) <<
" ";
Predeclaration for const cursor.
ConstTSubImageCursor(const TSubImage< DATATYPE > &subImage)
const DATATYPE * getPointerWithOffset(const ImageVector &offset) const
Returns cursor position of voxel given from current cursor shifted by offset.
const DATATYPE * getPointerWithOffset(MLint dx, MLint dy, MLint dz) const
Returns cursor position of voxel given from current cursor shifted by (dx, dy, dz).
const DATATYPE * getPointer() const
This class manages/represents a rectangular 6d image region which is organized linearly in memory.
const SubImageBox & getBox() const
Returns the box describing the origin/extent of the subimage.
MLDataType getDataType() const
Return type of image data.
ImageVector getStride() const
Returns a stride vector to address the memory efficiently.
void * getData() const
Returns the memory address of the memory managed by 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 scale constant from transformation y=scale*x+offset.
ReorderMode getReorderMode() const
Get the reorder mode.
DT getShift() const
Returns addition constant shift from 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 cursor backward in c direction.
void moveT()
Moves cursor forward in t direction.
void reverseMoveX()
Moves cursor backward in x direction.
void moveZ()
Moves cursor forward in z direction.
void setPosition(const DATATYPE *pointer)
Sets cursor to the given pointer where the pointer is the memory address of the voxel.
void reverseMoveY()
Moves cursor backward in y direction.
DATATYPE getValue() const
Returns voxel value at cursor position.
void reverseMoveT()
Moves cursor backward in t direction.
ImageVector _stride
Stride for the sub image.
void moveU()
Moves cursor forward in u direction.
void setSubImagePosition(MLint x, MLint y, MLint z)
Sets 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 voxel value at (cursor position + (dx, dy, dz))
void moveX()
Moves cursor forward in x direction.
DATATYPE getValueWithOffset(const ImageVector &offset) const
Returns voxel value at (cursor position + offset).
ImageVector _subImageOffset
SubImage offset in original image.
DATATYPE * _data
SubImage data.
void reverseMoveZ()
Moves cursor backward in z direction.
void setImagePosition(const ImageVector &position)
Sets cursor to the given 6d position relative to the origin of the complete image region.
void moveByOffset(const ImageVector &offset)
Moves cursor to cursor position + offset.
DATATYPE * _cursor
Cursor address for image data access.
void reverseMoveU()
Moves cursor backward in u direction.
TSubImageCursorBase(const TSubImage< DATATYPE > &subImage)
void moveY()
Moves cursor forward in y direction.
void setSubImagePosition(const ImageVector &position)
Sets cursor to the given position relative to the origin of the subimage region.
void moveByOffset(MLint x, MLint y, MLint z)
Moves cursor to cursor position + (x, y, z).
void setImagePosition(MLint x, MLint y, MLint z)
Sets cursor to the given 3d position (x, y, z) relative to the origin of the complete image region.
void moveC()
Moves cursor forward in c direction.
Predeclaration for cursor.
DATATYPE * getPointerWithOffset(const ImageVector &offset) const
Returns cursor position of voxel given from current cursor shifted by offset.
DATATYPE * getPointer() const
void setValueWithOffset(MLint dx, MLint dy, MLint dz, DATATYPE value) const
Sets voxel value at (cursor position + (dx, dy, dz)) to value.
TSubImageCursor(TSubImage< DATATYPE > &subImage)
void setValueWithOffset(const ImageVector &offset, DATATYPE value) const
Sets voxel value at (cursor position + offset) to value.
void setValue(DATATYPE value) const
Sets voxel value at cursor position to value.
DATATYPE * getPointerWithOffset(MLint dx, MLint dy, MLint dz) const
Returns cursor position of voxel given from current cursor shifted by (dx, dy, dz).
A class that offers a TSubImage with a TSubImageCursor.
void setCursorValue(DATATYPE value)
Sets the voxel value at cursor position to value.
void reverseMoveCursorC()
Moves cursor backward in c direction.
void moveCursorT()
Moves cursor forward in t direction.
void moveCursorByOffset(const ImageVector &offset)
Moves cursor to cursor position + offset.
void setCursorImagePosition(MLint x, MLint y, MLint z)
Sets cursor to the given 3d position (x, y, z) relative to the origin of the complete image region.
DATATYPE getCursorValue() const
Returns the voxel value at the cursor position.
void reverseMoveCursorU()
Moves cursor backward in u direction.
void reverseMoveCursorY()
Moves cursor backward in y direction.
DATATYPE getCursorValueWithOffset(MLint dx, MLint dy, MLint dz) const
Returns voxel value at (cursor position + (dx, dy, dz))
void reverseMoveCursorX()
Moves cursor backward in x direction.
void moveCursorByOffset(MLint x, MLint y, MLint z)
Moves cursor to cursor position + (x, y, z).
TSubImageWithCursor(const TSubImage< DATATYPE > &subImage)
Constructor with TSubImage.
void moveCursorZ()
Moves cursor forward in z direction.
void reverseMoveCursorZ()
Moves cursor backward in z direction.
void moveCursorC()
Moves cursor forward in c direction.
DATATYPE * getCursorPointerWithOffset(const ImageVector &offset) const
Returns cursor pointer of voxel given from current cursor shifted by offset.
void reverseMoveCursorT()
Moves 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 cursor to the given 6d position relative to the origin of the complete image region.
DATATYPE * getCursorPointerWithOffset(MLint dx, MLint dy, MLint dz) const
Returns cursor pointer of voxel given from current cursor shifted by (dx, dy, dz).
void setCursorPosition(const DATATYPE *pointer)
Sets cursor to the given pointer where pointer is the memory address of the voxel.
void moveCursorY()
Moves cursor forward in y direction.
void moveCursorX()
Moves cursor forward in x direction.
TSubImageWithCursor(const TSubImageWithCursor &subImage)
Constructor with TSubImageWithCursor.
TSubImageWithCursor(const SubImage &subImage)
Constructor with SubImage.
void moveCursorU()
Moves 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 cursor to the given 3d position (x, y, z) relative to the origin of the subimage region.
void setCursorSubImagePosition(const ImageVector &position)
Sets cursor to the given position relative to the origin of the subimage region.
DATATYPE * getCursorPointer() const
TSubImageWithCursor()
Default constructor.
TSubImageWithCursor & operator=(const TSubImageWithCursor< DATATYPE > &tSubImg)
Assignment operator to get an identical copy.
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 which is organized lin...
TSubImage(const SubImage &subImage)
Constructor to build a typed subimage from an untyped subImage.
const DATATYPE * getImagePointer(const ImageVector &position) const
Returns a pointer to voxel data of image voxel at 6d position position relative to the begin of the c...
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.
DATATYPE * getImagePointer(const ImageVector &position)
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 DATATY...
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 begin of th...
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...
ConstTSubImageCursor< DATATYPE > ConstCursor
A read-only cursor.
~TSubImage() override=default
Virtual destructor to shut up compiler warnings.
void fill(DATATYPE value)
Sets all voxel values in subimage to value.
ImageVector convertPointerToImagePosition(DATATYPE *pointer) const
Returns 6d voxel coordinates corresponding to the memory address pointer.
DATATYPE & operator[](const ImageVector &position)
Reference access to voxel value at the given position.
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 6d voxel coordinates corresponding to the memory address pointer.
const DATATYPE * getSubImagePointer(const ImageVector &position) const
Returns a pointer to voxel data of image voxel at the 6d position relative to the begin of the subima...
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.
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 begin of th...
void fillInvalidRegionWithValue(DATATYPE value)
Fills the invalid region (everything outside of getValidRegion()) with the given value.
DATATYPE * getSubImagePointer(const ImageVector &position)
const DATATYPE & operator[](const ImageVector &position) const
Constant reference access to voxel value at the given position.
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 which 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 minimum and maximum values of the region which is part of subimage box ...
void convertPointerToSubImagePosition(DATATYPE *pointer, MLint *x, MLint *y, MLint *z) const
Returns 3d voxel coordinates corresponding to the memory address pointer.
TSubImage & operator=(const TSubImage< DATATYPE > &typedSubImage)
Assignment operator to get an identical copy.
void setImageValue(MLint x, MLint y, DATATYPE value)
Sets the 2d voxel at the given position (x, y) to the the given value.
const DATATYPE * getData() const
Returns memory address of image region (Overloads method from SubImage)
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 positionis relative...
void convertPointerToImagePosition(DATATYPE *pointer, MLint *x, MLint *y, MLint *z) const
Returns 3d voxel coordinates corresponding to the memory address pointer.
DATATYPE * getSubImagePointer(MLint x, MLint y, MLint z)
void fillInvalidRegionWithBorderValues()
Fills the invalid region (everything outside of getValidRegion()) with the values on the borders of t...
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 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; t...
#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)
#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 ...
TSubImage< T > & tsubimage_cast(SubImage &subImg)
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator "<<" for stream output of Field objects.
TypeTraits for scalar ML Datatypes.