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,
156 if (inCursor ==
nullptr || outCursor ==
nullptr) {
161 inCursor += srcVoxelOffset;
162 for (
size_t i=0; i<numVox; ++i){
164 *outCursor =
static_cast<OUT_DATATYPE
>(*inCursor);
184 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
186 OUT_DATATYPE *outCursor,
188 const K_DATATYPE *valTab,
199 for (
size_t i=0; i < numVox; i++){
203 for (
size_t c=0; c < indexTabSize; c++){
204 retVal +=
static_cast<IntermediateType
>(inCursor[indexTab[c]]) *
233 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
235 OUT_DATATYPE *outCursor,
237 const K_DATATYPE *valTab,
245 const bool normal = minVal <= maxVal;
250 for (
size_t i=0; i < numVox; i++){
251 IN_DATATYPE srcVox = *(inCursor+srcVoxelOffset);
256 *outCursor =
static_cast<OUT_DATATYPE
>(srcVox);
265 for (
size_t c=0; c < indexTabSize; c++){
266 retVal +=
static_cast<IntermediateType
>(inCursor[indexTab[c]]) *
303 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
305 OUT_DATATYPE *outCursor,
307 const K_DATATYPE *valTab,
315 const bool normal = minVal <= maxVal;
320 for (
size_t i=0; i < numVox; i++){
328 for (
size_t c=0; c < indexTabSize; c++){
329 IN_DATATYPE val = inCursor[indexTab[c]];
335 retVal +=
static_cast<IntermediateType
>(val) *
337 posValSum += valTab[c];
340 negValSum += valTab[c];
348 *outCursor =
static_cast<OUT_DATATYPE
>(inCursor[srcVoxelOffset]);
385 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
387 OUT_DATATYPE *outCursor,
389 const K_DATATYPE *valTab,
399 const bool normalImgInt = imgIntMinVal <= imgIntMaxVal;
400 const bool normalKernInt = kernIntMinVal <= kernIntMaxVal;
405 for (
size_t i=0; i < numVox; i++){
408 const IN_DATATYPE *voxPtr = inCursor;
409 IN_DATATYPE srcVox = *(voxPtr+srcVoxelOffset);
414 *outCursor =
static_cast<OUT_DATATYPE
>(srcVox);
425 for (
size_t c=0; c < indexTabSize; c++){
426 IN_DATATYPE val = inCursor[indexTab[c]];
432 retVal +=
static_cast<IntermediateType
>(val) *
434 posValSum += valTab[c];
437 negValSum += valTab[c];
445 *outCursor =
static_cast<OUT_DATATYPE
>(inCursor[srcVoxelOffset]);
471 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
473 OUT_DATATYPE *outCursor,
475 const K_DATATYPE *valTab,
486 if (useImgInt && !useKernInt) {
497 }
else if (!useImgInt && useKernInt) {
508 }
else if (useImgInt && useKernInt) {
753 MLint numIterations=1);
774 MLint numIterations);
797 bool isSeparable=
false,
798 MLint numIterations=1);
824 bool isSeparable=
false,
825 MLint numIterations=1);
854 template <
typename IN_DATATYPE,
typename OUT_DATATYPE>
856 OUT_DATATYPE *outCursor,
864 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
866 OUT_DATATYPE *outCursor,
868 const K_DATATYPE *valTab,
876 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
878 OUT_DATATYPE *outCursor,
880 const K_DATATYPE *valTab,
891 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
893 OUT_DATATYPE *outCursor,
895 const K_DATATYPE *valTab,
906 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
908 OUT_DATATYPE *outCursor,
910 const K_DATATYPE *valTab,
920 imgIntMinVal, imgIntMaxVal, kernIntMinVal, kernIntMaxVal);
924 template <
typename IN_DATATYPE,
typename OUT_DATATYPE,
typename K_DATATYPE>
926 OUT_DATATYPE *outCursor,
928 const K_DATATYPE *valTab,
940 imgIntMinVal, imgIntMaxVal, kernIntMinVal, kernIntMaxVal, useImgInt, useKernInt);
944 template <
typename DATATYPE>
956 template <
typename DATATYPE>
994 template <
typename DATATYPE>
1025 template <
typename DATATYPE>
1055 MLint rowLength = ov2.
x - ov1.
x + 1;
1056 for (p.
u=ov1.
u; p.
u<=ov2.
u; p.
u++){
1057 for (p.
t=ov1.
t; p.
t<=ov2.
t; p.
t++){
1058 for (p.
c=ov1.
c; p.
c<=ov2.
c; p.
c++){
1059 for (p.
z=ov1.
z; p.
z<=ov2.
z; p.
z++){
1060 rowStart .
set(0, 0, p.
z, p.
c, p.
t, p.
u);
1061 for (p.
y=ov1.
y; p.
y<=ov2.
y; p.
y++){
1066 rowStart .
x = ov1.
x;
1075 lineFilter(&inSubImg, &outSubImg,
static_cast<size_t>(rowLength));
virtual ImageVector getNegativeExtent() const
Returns the negative extent of a kernel used for filtering.
virtual void applyToLine(TSubImageWithCursor< DATATYPE > *, TSubImageWithCursor< DATATYPE > *, size_t)
virtual ImageVector getPositiveExtent() const
Returns the positive extent of a kernel used for filtering.
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.
static TSubImageBox< intT > intersect(const TSubImageBox< intT > &box1, const TSubImageBox< intT > &box2)
void setCursorImagePosition(const ImageVector &position)
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)
MLint MLsoffset
Signed ML offset type that is a 32-bit signed integer on 32-bit platforms and a 64-bit integer on 64-...
ml::TypeTraits< typenameml::TypeTraits< T >::IntermediateType >::ComponentType ml_scalar_factor_cast(double v)
T ml_cast_from_intermediate_type_without_clamping(const typename ml::TypeTraits< T >::IntermediateType &v)
T ml_cast_from_scalar(double v)
Casts the (scalar) argument to the type of the template argument.
SwitchType< true > OnTrue
SwitchType< false > OnFalse
SwitchType< ml::TypeTraits< T >::isStandardType > isScalarType()
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)
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)
static void MLKernelToolsCopyLine(const IN_DATATYPE *inCursor, OUT_DATATYPE *outCursor, size_t numVox, MLsoffset srcVoxelOffset)
static void MLKernelToolsApplyFiltering(const ImageVector &inImgExt, LineApplicator< DATATYPE > &lineApp, KernelTools::BorderHandling borderHandling, MLdouble fillValue, TSubImageWithCursor< DATATYPE > &outSubImg, TSubImageWithCursor< DATATYPE > &inSubImg)
Global template functions for page filtering.
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)
TSubImageBox< MLint > SubImageBox
Defines the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type...
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)
TKernel< KernelDataType > Kernel
Standard kernel type to be used in this kernel library.
static bool _isScalarValueInRange(const DATATYPE &v, bool normal, double minVal, double maxVal, OverloadSelector::OnTrue)
Global static template functions for line filtering.
static void MLKernelToolsCorrelateLine(const IN_DATATYPE *inCursor, OUT_DATATYPE *outCursor, size_t numVox, const K_DATATYPE *valTab, const MLsoffset *indexTab, size_t indexTabSize)
TImageVector< MLint > ImageVector
Defines the standard ImageVector type that is used by the ML for indexing and coordinates.
virtual ~fctLineFilter()
Virtual destructor to avoid warnings. Currently it does nothing.
~useObjectLineFilter() override
Virtual destructor to avoid warnings. Currently it does nothing.
void(T::* pLF)(TSubImageWithCursor< DATATYPE > *, TSubImageWithCursor< DATATYPE > *, size_t)
useObjectLineFilter(T *po, void(T::*pf)(TSubImageWithCursor< DATATYPE > *, TSubImageWithCursor< DATATYPE > *, size_t))