17 #if !defined(__mlKernelTools_H)
18 #define __mlKernelTools_H
72 template<
class T,
typename DATATYPE>
102 { (pOb->*pLF)(inSubImg, outSubImg, numVox);}
121 template <
typename DATATYPE>
126 return (v >= minVal) && (v <= maxVal);
128 return (v < maxVal) || (v > minVal);
133 template <
typename DATATYPE>
139 template <
typename DATATYPE>
150 template <
typename IN_DATATYPE,
typename OUT_DATATYPE>
152 OUT_DATATYPE *outCursor,
157 inCursor += srcVoxelOffset;
158 for (
size_t i=0; i<numVox; ++i){
160 *outCursor =
static_cast<OUT_DATATYPE
>(*inCursor);
180 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
182 OUT_DATATYPE *outCursor,
184 const K_DATATYPE *valTab,
195 for (
size_t i=0; i < numVox; i++){
198 IntermediateType retVal = ml_cast_from_scalar<IntermediateType>(0);
199 for (
size_t c=0; c < indexTabSize; c++){
200 retVal +=
static_cast<IntermediateType
>(inCursor[indexTab[c]]) *
201 ml_scalar_factor_cast<IntermediateType>(valTab[c]);
205 *outCursor = ml_cast_from_intermediate_type_without_clamping<OUT_DATATYPE>(retVal);
229 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
231 OUT_DATATYPE *outCursor,
233 const K_DATATYPE *valTab,
241 const bool normal = minVal <= maxVal;
246 for (
size_t i=0; i < numVox; i++){
247 IN_DATATYPE srcVox = *(inCursor+srcVoxelOffset);
252 *outCursor =
static_cast<OUT_DATATYPE
>(srcVox);
260 IntermediateType retVal = ml_cast_from_scalar<IntermediateType>(0);
261 for (
size_t c=0; c < indexTabSize; c++){
262 retVal +=
static_cast<IntermediateType
>(inCursor[indexTab[c]]) *
263 ml_scalar_factor_cast<IntermediateType>(valTab[c]);
267 *outCursor = ml_cast_from_intermediate_type_without_clamping<OUT_DATATYPE>(retVal);
299 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
301 OUT_DATATYPE *outCursor,
303 const K_DATATYPE *valTab,
311 const bool normal = minVal <= maxVal;
316 for (
size_t i=0; i < numVox; i++){
323 IntermediateType retVal = ml_cast_from_scalar<IntermediateType>(0);
324 for (
size_t c=0; c < indexTabSize; c++){
325 IN_DATATYPE val = inCursor[indexTab[c]];
331 retVal +=
static_cast<IntermediateType
>(val) *
332 ml_scalar_factor_cast<IntermediateType>(valTab[c]);
333 posValSum += valTab[c];
336 negValSum += valTab[c];
344 *outCursor =
static_cast<OUT_DATATYPE
>(inCursor[srcVoxelOffset]);
346 *outCursor = ml_cast_from_intermediate_type_without_clamping<OUT_DATATYPE>(retVal *
347 ml_scalar_factor_cast<IntermediateType>((posValSum + negValSum) / posValSum));
381 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
383 OUT_DATATYPE *outCursor,
385 const K_DATATYPE *valTab,
395 const bool normalImgInt = imgIntMinVal <= imgIntMaxVal;
396 const bool normalKernInt = kernIntMinVal <= kernIntMaxVal;
401 for (
size_t i=0; i < numVox; i++){
404 const IN_DATATYPE *voxPtr = inCursor;
405 IN_DATATYPE srcVox = *(voxPtr+srcVoxelOffset);
410 *outCursor =
static_cast<OUT_DATATYPE
>(srcVox);
420 IntermediateType retVal = ml_cast_from_scalar<IntermediateType>(0);
421 for (
size_t c=0; c < indexTabSize; c++){
422 IN_DATATYPE val = inCursor[indexTab[c]];
428 retVal +=
static_cast<IntermediateType
>(val) *
429 ml_scalar_factor_cast<IntermediateType>(valTab[c]);
430 posValSum += valTab[c];
433 negValSum += valTab[c];
441 *outCursor =
static_cast<OUT_DATATYPE
>(inCursor[srcVoxelOffset]);
443 *outCursor = ml_cast_from_intermediate_type_without_clamping<OUT_DATATYPE>(retVal *
444 ml_scalar_factor_cast<IntermediateType>((posValSum + negValSum) / posValSum));
467 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
469 OUT_DATATYPE *outCursor,
471 const K_DATATYPE *valTab,
482 if (useImgInt && !useKernInt) {
493 }
else if (!useImgInt && useKernInt) {
504 }
else if (useImgInt && useKernInt) {
705 NUM_BORDER_HANDLINGS};
710 static const char*
const BorderHandlingNames[];
749 MLint numIterations=1);
770 MLint numIterations);
793 bool isSeparable=
false,
794 MLint numIterations=1);
820 bool isSeparable=
false,
821 MLint numIterations=1);
850 template <
typename IN_DATATYPE,
typename OUT_DATATYPE>
852 OUT_DATATYPE *outCursor,
860 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
862 OUT_DATATYPE *outCursor,
864 const K_DATATYPE *valTab,
872 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
874 OUT_DATATYPE *outCursor,
876 const K_DATATYPE *valTab,
887 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
889 OUT_DATATYPE *outCursor,
891 const K_DATATYPE *valTab,
902 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
904 OUT_DATATYPE *outCursor,
906 const K_DATATYPE *valTab,
916 imgIntMinVal, imgIntMaxVal, kernIntMinVal, kernIntMaxVal);
920 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
922 OUT_DATATYPE *outCursor,
924 const K_DATATYPE *valTab,
936 imgIntMinVal, imgIntMaxVal, kernIntMinVal, kernIntMaxVal, useImgInt, useKernInt);
940 template <
typename DATATYPE>
952 template <
typename DATATYPE>
990 template <
typename DATATYPE>
1021 template <
typename DATATYPE>
1032 KernelTools::fillBorders(inImgExt, negKernelExt, posKernelExt, borderHandling, fillValue, outSubImg, inSubImg);
1035 SubImageBox area(KernelTools::calcAreaToBeCalculated(inImgExt, negKernelExt, posKernelExt, borderHandling));
1045 ImageVector pOf = KernelTools::calcOutInCoordShift(borderHandling, negKernelExt);
1051 MLint rowLength = ov2.
x - ov1.
x + 1;
1052 for (p.
u=ov1.
u; p.
u<=ov2.
u; p.
u++){
1053 for (p.
t=ov1.
t; p.
t<=ov2.
t; p.
t++){
1054 for (p.
c=ov1.
c; p.
c<=ov2.
c; p.
c++){
1055 for (p.
z=ov1.
z; p.
z<=ov2.
z; p.
z++){
1056 rowStart .
set(0, 0, p.
z, p.
c, p.
t, p.
u);
1057 for (p.
y=ov1.
y; p.
y<=ov2.
y; p.
y++){
1062 rowStart .
x = ov1.
x;
1071 lineFilter(&inSubImg, &outSubImg,
static_cast<size_t>(rowLength));
The LineApplicator class provides pure virtual functions used by the old applyFiltering functions fro...
virtual ImageVector getNegativeExtent() const
Returns the negative extent of a kernel used for filtering.
virtual ImageVector getPositiveExtent() const
Returns the positive extent of a kernel used for filtering.
Class which represents an image, which manages properties of an image and image data which is located...
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.
void set(const ComponentType v=0)
Sets all components to v or - if v is not specified - to 0.
VectorType v1
Corner v1 of the subimage region (included in region).
static TSubImageBox< intT > intersect(const TSubImageBox< intT > &box1, const TSubImageBox< intT > &box2)
Returns the overlapping region of subimage regions box1 and box2.
VectorType v2
Corner v2 of the subimage region (also included in region!).
A class that offers a TSubImage with a TSubImageCursor.
void setCursorImagePosition(const ImageVector &position)
Sets cursor to the given 6d position relative to the origin of the complete image region.
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.
bool MLValueIs0WOM(MLint8 a)
Returns true if value is 0, otherwise false.
#define MLKERNELEXPORT
Includes files used in many parts of the dll, defined dll-specific macros and controls any system dep...
MLint MLsoffset
Signed ML offset type which is a 32 bit signed integer on 32 bit platforms and a 64 bit integer on 64...
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
static void MLKernelToolsCorrelateLineWithImageAndKernelInterval(const IN_DATATYPE *inCursor, OUT_DATATYPE *outCursor, size_t numVox, const K_DATATYPE *valTab, const MLsoffset *indexTab, size_t indexTabSize, MLsoffset srcVoxelOffset, MLdouble imgIntMinVal, MLdouble imgIntMaxVal, MLdouble kernIntMinVal, MLdouble kernIntMaxVal)
Correlate all voxels of the a row pointed to by inCursor with the current kernel and write the result...
static bool isScalarValueInRange(const DATATYPE &v, bool normal, double minVal, double maxVal)
static void MLKernelToolsCorrelateLineEvtWithIntervals(const IN_DATATYPE *inCursor, OUT_DATATYPE *outCursor, size_t numVox, const K_DATATYPE *valTab, const MLsoffset *indexTab, size_t indexTabSize, MLsoffset srcVoxelOffset, MLdouble imgIntMinVal, MLdouble imgIntMaxVal, MLdouble kernIntMinVal, MLdouble kernIntMaxVal, bool useImgInt, bool useKernInt)
Correlate all voxels of the a row pointed to by inCursor with the current kernel and write the result...
static void MLKernelToolsCopyLine(const IN_DATATYPE *inCursor, OUT_DATATYPE *outCursor, size_t numVox, MLsoffset srcVoxelOffset)
Copy the line from input subimage which corresponds to the line to be modified in the output image.
static void MLKernelToolsApplyFiltering(const ImageVector &inImgExt, const fctLineFilter< DATATYPE > &lineFilter, const ImageVector &negKernelExt, const ImageVector &posKernelExt, KernelTools::BorderHandling borderHandling, MLdouble fillValue, TSubImageWithCursor< DATATYPE > &outSubImg, TSubImageWithCursor< DATATYPE > &inSubImg)
Compute the page outSubImg by filtering inSubImg with the passed function taking care of correct inte...
static void MLKernelToolsCorrelateLineWithKernelInterval(const IN_DATATYPE *inCursor, OUT_DATATYPE *outCursor, size_t numVox, const K_DATATYPE *valTab, const MLsoffset *indexTab, size_t indexTabSize, MLsoffset srcVoxelOffset, MLdouble minVal, MLdouble maxVal)
Correlate all voxels of the a row pointed to by inCursor with the current kernel and write the result...
static void MLKernelToolsCorrelateLineWithImageInterval(const IN_DATATYPE *inCursor, OUT_DATATYPE *outCursor, size_t numVox, const K_DATATYPE *valTab, const MLsoffset *indexTab, size_t indexTabSize, MLsoffset srcVoxelOffset, MLdouble minVal, MLdouble maxVal)
Correlate all voxels of the a row pointed to by inCursor with the current kernel and write the result...
static bool _isScalarValueInRange(const DATATYPE &, bool, double, double, OverloadSelector::OnFalse)
static void MLKernelToolsCorrelateLine(const IN_DATATYPE *inCursor, OUT_DATATYPE *outCursor, size_t numVox, const K_DATATYPE *valTab, const MLsoffset *indexTab, size_t indexTabSize)
Correlate all voxels of the a row pointed to by inCursor with the current kernel and write the result...
helper types to switch between implementations of functions by overloading
The basic implementation of a filter to filter an image row with kernel operations.
virtual ~fctLineFilter()
Virtual destructor to avoid warnings. Currently it does nothing.
Wrapper for the use of object bound row filters.
T * pOb
Pointer to store the pointer to the class type object passed to the explicit useObjectLineFilter as p...
~useObjectLineFilter() override
Virtual destructor to avoid warnings. Currently it does nothing.
useObjectLineFilter(T *po, void(T::*pf)(TSubImageWithCursor< DATATYPE > *, TSubImageWithCursor< DATATYPE > *, size_t))
Constructor.