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) ]; }
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>
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);
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);
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){
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);
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){
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());
819 #if ML_DEPRECATED_SINCE(3,5,0)
852 inline ML_DEPRECATED ImageVector getSubImgCoords(DATATYPE *pos)
const {
return convertPointerToSubImagePosition(pos); }
855 inline ML_DEPRECATED void getSubImgCoords(DATATYPE *pos,
MLint *x,
MLint *y,
MLint *z)
const { convertPointerToSubImagePosition(pos, x, y, z); }
861 inline ML_DEPRECATED void getImgCoords(DATATYPE *pos,
MLint *x,
MLint *y,
MLint *z)
const { convertPointerToImagePosition(pos, x, y, z); }
900 inline ML_DEPRECATED MLint calcMinMax(DATATYPE &minVal, DATATYPE &maxVal,
const SubImageBox *
const validBox=
nullptr)
const {
return calculateMinMax(minVal, maxVal, validBox); }
903 template <
typename FROM_DATATYPE>
904 ML_DEPRECATED void copySubImg(
const TSubImage<FROM_DATATYPE> &typedFromImg) { copySubImage(typedFromImg); }
907 template <
typename FROM_DATATYPE>
908 ML_DEPRECATED void copySubImg(
const TSubImage<FROM_DATATYPE> &typedFromImg,
const ScaleShiftData& scaleShiftData) { copySubImage(typedFromImg, scaleShiftData); }
911 inline ML_DEPRECATED void fillSubImg(DATATYPE value) { fill(value);}
915 inline ML_DEPRECATED void fillBordersWithClampedInputValues(
const SubImageBox& box) { fillBordersWithBorderValues(box); }
919 inline ML_DEPRECATED void fillBordersWithFillValue(
const SubImageBox& box, DATATYPE value) { fillBordersWithValue(box, value); }
927 #if ML_DEPRECATED_SINCE(3,5,0)
932 #define TSubImg TSubImage
934 #if defined(WIN32) && !defined(ML_NO_DEPRECATED_WARNINGS)
935 #pragma deprecated("TSubImg")
945 template <
typename DATATYPE>
951 _data =
const_cast<DATATYPE*
>(subImage.
getData());
952 _subImageOffset = subImage.
getBox().
v1;
976 inline void setPosition(
const DATATYPE *pointer) { _cursor =
const_cast<DATATYPE*
>(pointer); }
982 inline void moveX() { _cursor += _stride.x; }
984 inline void moveY() { _cursor += _stride.y; }
986 inline void moveZ() { _cursor += _stride.z; }
988 inline void moveC() { _cursor += _stride.c; }
990 inline void moveT() { _cursor += _stride.t; }
992 inline void moveU() { _cursor += _stride.u; }
1017 inline DATATYPE
getValue()
const {
return *(_cursor); }
1038 #if ML_DEPRECATED_SINCE(3,5,0)
1059 inline ML_DEPRECATED void setCursorPos(
const DATATYPE *position) { setPosition(position); }
1086 inline ML_DEPRECATED void moveCursorBX() { reverseMoveX(); }
1089 inline ML_DEPRECATED void moveCursorBY() { reverseMoveY(); }
1092 inline ML_DEPRECATED void moveCursorBZ() { reverseMoveZ(); }
1095 inline ML_DEPRECATED void moveCursorBC() { reverseMoveC(); }
1098 inline ML_DEPRECATED void moveCursorBT() { reverseMoveT(); }
1101 inline ML_DEPRECATED void moveCursorBU() { reverseMoveU(); }
1104 inline DATATYPE getCursorVal()
const {
return getValue(); }
1107 inline DATATYPE getCursorVal(
const ImageVector& dp)
const {
return getValueWithOffset(dp); }
1110 inline DATATYPE getCursorVal(
MLint dx,
MLint dy,
MLint dz)
const {
return getValueWithOffset(dx, dy, dz); }
1122 template <
typename DATATYPE>
1144 #if ML_DEPRECATED_SINCE(3,5,0)
1153 inline ML_DEPRECATED const DATATYPE* getCursorPos()
const {
return getPointer(); }
1156 inline ML_DEPRECATED const DATATYPE* getCursorPos(
const ImageVector& dp)
const {
return getPointerWithOffset(dp); }
1167 #if ML_DEPRECATED_SINCE(3,5,0)
1172 #define ConstTSubImgCursor ConstTSubImageCursor
1174 #if defined(WIN32) && !defined(ML_NO_DEPRECATED_WARNINGS)
1175 #pragma deprecated("ConstTSubImgCursor")
1186 template <
typename DATATYPE>
1217 inline void setValue(DATATYPE value)
const { *(T::_cursor) = value; }
1224 #if ML_DEPRECATED_SINCE(3,5,0)
1233 inline ML_DEPRECATED DATATYPE* getCursorPos()
const {
return getPointer(); }
1242 inline ML_DEPRECATED void setCursorVal(DATATYPE val)
const { setValue(val); }
1256 #if ML_DEPRECATED_SINCE(3,5,0)
1261 #define TSubImgCursor TSubImageCursor
1263 #if defined(WIN32) && !defined(ML_NO_DEPRECATED_WARNINGS)
1264 #pragma deprecated("TSubImgCursor")
1275 template <
typename DATATYPE>
1305 _cursor = tSubImg._cursor;
1326 inline void setCursorPosition(
const DATATYPE* pointer) { _cursor =
const_cast<DATATYPE*
>(pointer); }
1409 #ifdef ML_DEPRECATED
1489 #if ML_DEPRECATED_SINCE(3,5,0)
1494 #define TSubImgWithCursor TSubImageWithCursor
1496 #if defined(WIN32) && !defined(ML_NO_DEPRECATED_WARNINGS)
1497 #pragma deprecated("TSubImgWithCursor")
1515 template <
typename T>
1522 "Mismatch of data type between argument and template typename.");
1527 template <
typename T>
1534 "Mismatch of data type between argument and template typename.");
1539 template <
typename T>
1546 "Mismatch of data type between argument and template typename.");
1551 template <
typename T>
1558 "Mismatch of data type between argument and template typename.");
1565 #ifdef ML_DEPRECATED
1569 template <
typename T>
1574 template <
typename T>
1579 template <
typename T>
1584 template <
typename T>
1601 template <
typename DATATYPE>
1602 inline ostream &
operator<<(ostream &ostr,
const ML_NAMESPACE::TSubImage<DATATYPE> &v)
1607 for (p.u=box.v1.u; p.u<=box.v2.u; ++p.u){
1608 for (p.t=box.v1.t; p.t<=box.v2.t; ++p.t){
1609 for (p.c=box.v1.c; p.c<=box.v2.c; ++p.c){
1610 for (p.z=box.v1.z; p.z<=box.v2.z; ++p.z){
1611 for (p.y=box.v1.y; p.y<=box.v2.y; ++p.y){
1615 for (; p.x<=box.v2.x; p.x++){
1616 ostr << v.getImageValue(p) <<
" ";
1630 #pragma warning(pop)
Predeclaration for const cursor.
ConstTSubImageCursor(const TSubImage< DATATYPE > &subImage)
const DATATYPE * getPointer() const
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).
This class manages/represents a rectangular 6d image region which is organized linearly in memory.
void * getData() const
Returns the memory address of the memory managed by the subimage.
MLDataType getDataType() const
Return 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 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.
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).
DATATYPE * getPointerWithOffset(const ImageVector &offset) const
Returns cursor position of voxel given from 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 cursor position to value.
DATATYPE * getCursorPos(const ImageVector &dp) const
void reverseMoveCursorC()
Moves cursor backward in c direction.
void moveCursorT()
Moves cursor forward in t direction.
DATATYPE getCursorVal() const
DATATYPE * getCursorPointer() const
void setCursorSubImgPos(MLint x, MLint y, MLint z)
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 * getCursorPos() const
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 * getCursorPointerWithOffset(MLint dx, MLint dy, MLint dz) const
Returns cursor pointer of voxel given from current cursor shifted by (dx, dy, dz).
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.
void setCursorVal(const ImageVector &dp, DATATYPE val)
void setCursorPos(const DATATYPE *position)
void moveCursor(const ImageVector &dp)
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.
void setCursorVal(DATATYPE val)
void setCursorPosition(const DATATYPE *pointer)
Sets cursor to the given pointer where pointer is the memory address of the voxel.
DATATYPE * getCursorPointerWithOffset(const ImageVector &offset) const
Returns cursor pointer of voxel given from current cursor shifted by offset.
TSubImageWithCursor & operator=(const TSubImageWithCursor< DATATYPE > &tSubImg)
Assignment operator to get an identical copy.
void moveCursorY()
Moves cursor forward in y direction.
DATATYPE * getCursorPos(MLint dx, MLint dy, MLint dz) const
void moveCursorX()
Moves cursor forward in x direction.
DATATYPE getCursorVal(const ImageVector &dp) const
TSubImageWithCursor(const TSubImageWithCursor &subImage)
Constructor with TSubImageWithCursor.
void moveCursor(MLint x, MLint y, MLint z)
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 setCursorSubImgPos(const ImageVector &p)
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.
void setCursorVal(MLint dx, MLint dy, MLint dz, DATATYPE val)
TSubImageWithCursor()
Default constructor.
void setCursorImgPos(MLint x, MLint y, MLint z)
DATATYPE getCursorVal(MLint dx, MLint dy, MLint dz) const
void setCursorImgPos(const ImageVector &p)
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.
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 DATATY...
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...
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 begin of th...
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.
TSubImage & operator=(const TSubImage< DATATYPE > &typedSubImage)
Assignment operator to get an identical copy.
ImageVector convertPointerToImagePosition(DATATYPE *pointer) const
Returns 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 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 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.
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 memory address of image region (Overloads method 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 begin of the subima...
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 positionis relative...
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...
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 3d voxel coordinates corresponding to the memory address pointer.
DATATYPE * getImagePointer(const ImageVector &position)
void fillInvalidRegionWithBorderValues()
Fills the invalid region (everything outside of getValidRegion()) with the values on the borders of t...
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 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)
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 ...
MLWEM_EXPORT void intersect(WEMTrianglePatch *inPatch1, WEMTrianglePatch *inPatch2, WEMTrianglePatch *outPatch, unsigned int outputMode, TriangulationModes triangulationMode, WEMVector< WEMCut > *cuts=nullptr)
Returns the intersection of the given patches.
TScaleShiftData< MLdouble > ScaleShiftData
Double version of TScaleShiftData for maximum reasonable precision.
TSubImageBox< MLint > SubImageBox
Define the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type.
const TSubImage< T > & tsubimg_cast(const SubImage &subImg)
TImageVector< MLint > ImageVector
Defines the standard ImageVector type which is used by the ML for indexing and coordinates.
const TSubImage< T > * tsubimage_cast(const SubImage *subImg)
TypeTraits for scalar ML Datatypes.