104 _dataTypeSize (si._dataTypeSize)
131 _dataTypeSize (si._dataTypeSize)
133 _box.translate(offset);
151 _dataTypeSize = si._dataTypeSize;
182 _box.translate(offset);
193 _box.v2 = newOrigin + offset;
317 return static_cast<void*
>(
static_cast<char*
>(
_data) +
static_cast<size_t>((x*
_stride.x + y*
_stride.y +
_stride.z*z) *
static_cast<MLint>(_dataTypeSize)));
425 return ((voxelPosition.
x>=0) && (voxelPosition.
y>=0) && (voxelPosition.
z>=0) &&
426 (voxelPosition.
c>=0) && (voxelPosition.
t>=0) && (voxelPosition.
u>=0) &&
427 voxelPosition.
x < extent.
x && voxelPosition.
y < extent.
y && voxelPosition.
z < extent.
z &&
428 voxelPosition.
c < extent.
c && voxelPosition.
t < extent.
t && voxelPosition.
u < extent.
u );
438 return ((x>=0) && (y>=0) && (z>=0) &&
439 (x < extent.
x) && (y < extent.
y) && (z < extent.
z));
448 return ((voxelPosition.
x>=
_box.v1.x) && (voxelPosition.
y>=
_box.v1.y) && (voxelPosition.
z>=
_box.v1.z) &&
449 (voxelPosition.
c>=
_box.v1.c) && (voxelPosition.
t>=
_box.v1.t) && (voxelPosition.
u>=
_box.v1.u) &&
450 (voxelPosition.
x<=
_box.v2.x) && (voxelPosition.
y<=
_box.v2.y) && (voxelPosition.
z<=
_box.v2.z) &&
451 (voxelPosition.
c<=
_box.v2.c) && (voxelPosition.
t<=
_box.v2.t) && (voxelPosition.
u<=
_box.v2.u) );
460 return ((x>=
_box.v1.x) && (y>=
_box.v1.y) && (z>=
_box.v1.z) &&
551 bool* dataTypesMatch,
552 bool* thisBoxIsPartOfRegion2,
553 bool* region2IsPartOfThisBox,
554 bool* overlapHasSameValues,
681 MLint &fullLineLenXB,
682 MLint &leftLineStartX,
684 MLint &leftLineLenXB,
685 MLint &rightLineStartX,
686 MLint &rightLineLenX,
687 MLint &rightLineLenXB);
718 size_t _dataTypeSize;
const MLTypeInfos * _getDataTypeInfos(MLDataType dt) const
Returns MLTypeInfos for used datatypes, indicates error if the type dt is not registered.
void fillInvalidRegionWithScalarValue(MLdouble value)
SubImage & operator=(const SubImage &si)
void * getSubImagePointer(const ImageVector &voxelPosition) const
void setBox(const SubImageBox &subImageBox)
MLEXPORT void compare(const SubImage &subImage2, bool *regionsMatch, bool *dataTypesMatch, bool *thisBoxIsPartOfRegion2, bool *region2IsPartOfThisBox, bool *overlapHasSameValues, ImageVector *firstMismatchPos) const
bool isValidSubImagePosition(const ImageVector &voxelPosition) const
void * getImagePointer(const ImageVector &voxelPosition) const
void fillInvalidRegionWithTypeData(const MLTypeData *value)
const SubImageBox & getBox() const
Returns the box describing the origin/extent of the subimage.
virtual ~SubImage()=default
Virtual destructor to suppress compiler warnings.
void setDataType(MLDataType dataType)
void translate(const ImageVector &offset)
Translates the box of the subimage by adding the vector offset.
MLEXPORT void allocateAsMemoryBlockHandle(MLMemoryErrorHandling handleFailure=ML_RETURN_NULL)
Allocates data using the ML memory manager. For failure handing, see SubImage::allocate().
MLDataType getDataType() const
Returns the type of image data.
MLEXPORT bool isOneValued() const
SubImageBox getBoxFromImageExtent() const
SubImage(const SubImage &si, const ImageVector &offset)
MLMemoryBlockHandle _memoryBlock
Memory block used by this subimage.
SubImageBox _box
The box of the subimage.
void _calcFillAreaParams(const SubImageBox &box, const SubImageBox &maxValidInputRegion, ImageVector &boxV1, ImageVector &boxV2, ImageVector &outputTSubImageV1, ImageVector &outputTSubImageV2, MLint &fullLineLenX, MLint &fullLineLenXB, MLint &leftLineStartX, MLint &leftLineLenX, MLint &leftLineLenXB, MLint &rightLineStartX, MLint &rightLineLenX, MLint &rightLineLenXB)
void setExtent(const ImageVector &newExtent)
Sets the extent of the subimage to newExtent. This also changes the strides.
SubImage(const SubImage &si)
MLEXPORT MLint calculateMinMax(MLdouble &minValue, MLdouble &maxValue, const SubImageBox *const validBox=nullptr) const
ImageVector getExtent() const
Returns the extent of the subimage, which is identical to getBox().getExtent().
ImageVector getStride() const
const ImageVector & getOrigin() const
Returns the origin of the subimage, which is identical to getBox().v1.
SubImageBox getValidRegion() const
void setExtent(MLint x, MLint y, MLint z=1, MLint c=1, MLint t=1, MLint u=1)
void _copySubImageGeneric(const SubImage &fromImage, const ScaleShiftData &scaleShiftData)
Generic, non-optimized version of copySubImage.
void toStream(std::ostream &ostr) const
MLEXPORT void allocate(MLMemoryErrorHandling handleFailure)
void setSourceImageExtent(const ImageVector &extent)
void * _data
Memory chunk managed by this subimage.
static MLEXPORT MLint coordToIndex(const ImageVector &voxelPosition, const ImageVector &size)
MLEXPORT void copySubImage(const SubImage &fromImage)
MLEXPORT void fillBordersWithInputValues(const SubImageBox &box, const SubImage &inputSubImage)
static MLEXPORT MLint coordToIndex(MLint x, MLint y, MLint z, MLint c, MLint t, MLint u, const ImageVector &size)
MLEXPORT void fillBordersWithScalarValue(const SubImageBox &box, MLdouble fillValue)
void setOrigin(const ImageVector &newOrigin)
void fillInvalidRegionWithBorderValues()
SubImage(const SubImageBox &box, MLDataType datatype, void *data=nullptr)
MLint getOffset(const ImageVector &voxelPosition) const
Returns the array index offset from the origin (0,0,0,0,0,0) to the voxelPosition.
void * getData() const
Returns the memory address of the memory managed by the subimage.
bool isValidImagePosition(MLint x, MLint y, MLint z) const
SubImage()
Constructor: Creates a subimage with no data.
bool isValidSubImagePosition(MLint x, MLint y, MLint z) const
MLEXPORT bool isValid() const
SubImageBox getBoxFromExtent() const
Returns the size of image as box with origin 0.
MLint getSizeInBytes() const
ImageVector getSourceImageExtent() const
void * getImagePointer(MLint x, MLint y, MLint z) const
bool isValidImagePosition(const ImageVector &voxelPosition) const
void setImageExtent(const ImageVector &newExtent)
MLEXPORT void setFromImageProperties(const ImageProperties &imageProperties)
MLEXPORT void fillBordersWithTypeData(const SubImageBox &box, const MLTypeData *fillValue)
const MLMemoryBlockHandle & getMemoryBlockHandle() const
MLEXPORT ImageProperties toImageProperties() const
MLint getNumVoxels() const
MLEXPORT void fillWithTypeData(const MLTypeData *value)
MLEXPORT void fill(MLdouble value)
Fills the subimage with a value that is cast to the data type of the subimage.
MLEXPORT void setDataFromMemoryBlockHandle(const MLMemoryBlockHandle &data)
ImageVector getImageExtent() const
static MLEXPORT ImageVector indexToCoord(MLint index, const ImageVector &extent)
const MLTypeInfos * getDataTypeInfos() const
Returns MLTypeInfos for image data type.
void * getSubImagePointer(MLint x, MLint y, MLint z) const
MLEXPORT void fillBordersWithBorderValues(const SubImageBox &box)
MLEXPORT void copySubImage(const SubImage &fromImage, const ScaleShiftData &scaleShiftData)
MLEXPORT void setData(void *data)
void setBox(const ImageVector &imageExtent)
ImageVector _sourceImageExtent
The extent of the source image, which is used for getValidRegion().
MLDataType _dataType
Data type of the image.
static TSubImageBox< MLint > intersect(const TSubImageBox< MLint > &box1, const TSubImageBox< MLint > &box2)
VectorType getExtent() const
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
ComponentType dot(const TVector< TVector6DBase< MLint > > &b) const
MLEXPORT size_t MLSizeOf(MLDataType dataType)
@ MLuint8Type
Enumerator for the unsigned 8-bit ML integer type.
MLEXPORT MLTypeInfos * MLGetTypeInfosForDataType(MLDataType dataType)
#define MLEXPORT
Code it as import symbol if compiled elsewhere.
MLMemoryErrorHandling
Enumerator to specify memory error handling.
@ ML_RETURN_NULL
On allocation failure, NULL is returned without error handling.
unsigned char MLTypeData
This is the pointer type used to point to the data of MLType data instances.
std::ostream & operator<<(std::ostream &out, const ml::Variant &variant)
TScaleShiftData< MLdouble > ScaleShiftData
Double version of TScaleShiftData for maximum reasonable precision.
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.