20 #ifndef MIRTK_ConvolutionFunction_H 21 #define MIRTK_ConvolutionFunction_H 23 #include "mirtk/Voxel.h" 24 #include "mirtk/VoxelFunction.h" 25 #include "mirtk/BaseImage.h" 26 #include "mirtk/GenericImage.h" 32 namespace ConvolutionFunction {
62 if (n % 2) i = N - 1 - m;
88 template <
class TKernel =
double>
97 ConvolveInX(
const BaseImage *image,
const TKernel *kernel,
int size,
bool norm =
true,
int l = 0)
99 _Kernel(kernel), _Radius((size - 1) / 2), _Normalize(norm),
100 _Offset(l * image->NumberOfSpatialVoxels()), _X(image->X())
103 template <
class T1,
class T2>
104 void operator ()(
int i,
int,
int,
int,
const T1 *in, T2 *out)
const 106 typedef typename voxel_info<T2>::RealType AccType;
107 typedef typename voxel_info<AccType>::ScalarType RealType;
109 in += _Offset, out += _Offset;
113 int n = _Radius + _Radius;
115 if (i < 0) n += i, in -= i, i = 0;
118 RealType w, sum = .0;
119 while (i < _X && n >= 0) {
120 w =
static_cast<RealType
>(_Kernel[n]);
121 v = voxel_cast<AccType>(*in);
128 *out = voxel_cast<T2>(acc);
134 template <
class TKernel =
double>
144 ConvolveInY(
const BaseImage *image,
const TKernel *kernel,
int size,
bool norm =
true,
int l = 0)
146 _Kernel(kernel), _Radius((size - 1) / 2), _Normalize(norm),
147 _Offset(l * image->NumberOfSpatialVoxels()), _X(image->X()), _Y(image->Y())
150 template <
class T1,
class T2>
151 void operator ()(
int,
int j,
int,
int,
const T1 *in, T2 *out)
const 153 typedef typename voxel_info<T2>::RealType AccType;
154 typedef typename voxel_info<AccType>::ScalarType RealType;
156 in += _Offset, out += _Offset;
160 int n = _Radius + _Radius;
162 if (j < 0) n += j, in -= j * _X, j = 0;
165 RealType w, sum = 0.;
166 while (j < _Y && n >= 0) {
167 w =
static_cast<RealType
>(_Kernel[n]);
168 v = voxel_cast<AccType>(*in);
175 *out = voxel_cast<T2>(acc);
181 template <
class TKernel =
double>
191 ConvolveInZ(
const BaseImage *image,
const TKernel *kernel,
int size,
bool norm =
true,
int l = 0)
193 _Kernel(kernel), _Radius((size - 1) / 2), _Normalize(norm),
194 _Offset(l * image->NumberOfSpatialVoxels()), _XY(image->X() * image->Y()), _Z(image->Z())
197 template <
class T1,
class T2>
198 void operator ()(
int,
int,
int k,
int,
const T1 *in, T2 *out)
const 200 typedef typename voxel_info<T2>::RealType AccType;
201 typedef typename voxel_info<AccType>::ScalarType RealType;
203 in += _Offset, out += _Offset;
207 int n = _Radius + _Radius;
209 if (k < 0) n += k, in -= k * _XY, k = 0;
212 RealType w, sum = 0.;
213 while (k < _Z && n >= 0) {
214 w =
static_cast<RealType
>(_Kernel[n]);
215 v = voxel_cast<AccType>(*in);
222 *out = voxel_cast<T2>(acc);
228 template <
class TKernel =
double>
239 _Kernel(kernel), _Radius((size - 1) / 2), _Normalize(norm),
240 _XYZ(image->X() * image->Y() * image->Z()), _T(image->T())
243 template <
class T1,
class T2>
244 void operator ()(
int,
int,
int,
int l,
const T1 *in, T2 *out)
const 246 typedef typename voxel_info<T2>::RealType AccType;
247 typedef typename voxel_info<AccType>::ScalarType RealType;
250 in -= _Radius * _XYZ;
251 int n = _Radius + _Radius;
253 if (l < 0) n += l, in -= l * _XYZ, l = 0;
256 RealType w, sum = 0.;
257 while (l < _T && n >= 0) {
258 w =
static_cast<RealType
>(_Kernel[n]);
259 v = voxel_cast<AccType>(*in);
262 ++l, in += _XYZ, --n;
266 *out = voxel_cast<T2>(acc);
276 template <
class TKernel =
double>
288 _Image(image), _Kernel(kernel), _Radius((size - 1) / 2), _Normalize(norm),
289 _Offset(l * image->NumberOfSpatialVoxels()), _X(image->X())
292 template <
class T1,
class T2>
293 void operator ()(
int i,
int j,
int k,
int l,
const T1 *in, T2 *out)
const 295 typedef typename voxel_info<T2>::RealType AccType;
296 typedef typename voxel_info<AccType>::ScalarType RealType;
298 in += _Offset, out += _Offset;
302 int n = _Radius + _Radius;
304 if (i < 0) n += i, in -= i, i = 0;
307 RealType w, sum = 0.;
308 while (i < _X && n >= 0) {
310 w =
static_cast<RealType
>(_Kernel[n]);
311 v = voxel_cast<AccType>(*in);
319 *out = voxel_cast<T2>(acc);
325 template <
class TKernel =
double>
338 _Image(image), _Kernel(kernel), _Radius((size - 1) / 2), _Normalize(norm),
339 _Offset(l * image->NumberOfSpatialVoxels()), _X(image->X()), _Y(image->Y())
342 template <
class T1,
class T2>
343 void operator ()(
int i,
int j,
int k,
int l,
const T1 *in, T2 *out)
const 345 typedef typename voxel_info<T2>::RealType AccType;
346 typedef typename voxel_info<AccType>::ScalarType RealType;
348 in += _Offset, out += _Offset;
352 int n = _Radius + _Radius;
354 if (j < 0) n += j, in -= j * _X, j = 0;
357 RealType w, sum = 0.;
358 while (j < _Y && n >= 0) {
360 w =
static_cast<RealType
>(_Kernel[n]);
361 v = voxel_cast<AccType>(*in);
369 *out = voxel_cast<T2>(acc);
375 template <
class TKernel =
double>
388 _Image(image), _Kernel(kernel), _Radius((size - 1) / 2), _Normalize(norm),
389 _Offset(l * image->NumberOfSpatialVoxels()), _XY(image->X() * image->Y()), _Z(image->Z())
392 template <
class T1,
class T2>
393 void operator ()(
int i,
int j,
int k,
int l,
const T1 *in, T2 *out)
const 395 typedef typename voxel_info<T2>::RealType AccType;
396 typedef typename voxel_info<AccType>::ScalarType RealType;
398 in += _Offset, out += _Offset;
402 int n = _Radius + _Radius;
404 if (k < 0) n += k, in -= k * _XY, k = 0;
407 RealType w, sum = 0.;
408 while (k < _Z && n >= 0) {
410 w =
static_cast<RealType
>(_Kernel[n]);
411 v = voxel_cast<AccType>(*in);
419 *out = voxel_cast<T2>(acc);
425 template <
class TKernel =
double>
437 _Image(image), _Kernel(kernel), _Radius((size - 1) / 2), _Normalize(norm),
438 _XYZ(image->X() * image->Y() * image->Z()), _T(image->T())
441 template <
class T1,
class T2>
442 void operator ()(
int i,
int j,
int k,
int l,
const T1 *in, T2 *out)
const 444 typedef typename voxel_info<T2>::RealType AccType;
445 typedef typename voxel_info<AccType>::ScalarType RealType;
448 in -= _Radius * _XYZ;
449 int n = _Radius + _Radius;
451 if (l < 0) n += l, in -= l * _XYZ, l = 0;
454 RealType w, sum = 0.;
455 while (l < _T && n >= 0) {
457 w =
static_cast<RealType
>(_Kernel[n]);
458 v = voxel_cast<AccType>(*in);
462 ++l, in += _XYZ, --n;
466 *out = voxel_cast<T2>(acc);
476 template <
class TKernel =
double>
486 int size,
int l1 = 0,
int l2 = 0)
488 _Kernel(kernel), _Radius((size - 1) / 2),
489 _Offset1(l1 * image->NumberOfSpatialVoxels()),
490 _Offset2(l2 * image->NumberOfSpatialVoxels()),
494 template <
class T1,
class T2,
class T3>
495 void operator ()(
int i,
int,
int,
int,
const T1 *in,
const T2 *win, T3 *out)
const 498 in += _Offset1, win += _Offset2, out += _Offset1;
503 int n = _Radius + _Radius;
505 if (i < 0) n += i, in -= i, win -= i, i = 0;
507 double w, acc = .0, sum = .0;
508 while (i < _X && n >= 0) {
509 w =
static_cast<double>(*win) *
static_cast<double>(_Kernel[n]);
510 acc += w *
static_cast<double>(*in);
512 ++i, ++in, ++win, --n;
515 acc = (sum >
Epsilon() ? acc / sum : 0.);
516 *out =
static_cast<T3
>(acc);
522 template <
class TKernel =
double>
534 _Kernel(kernel), _Radius((size - 1) / 2),
535 _Offset1(l1 * image->NumberOfSpatialVoxels()),
536 _Offset2(l2 * image->NumberOfSpatialVoxels()),
537 _X(image->X()), _Y(image->Y())
540 template <
class T1,
class T2,
class T3>
541 void operator ()(
int,
int j,
int,
int,
const T1 *in,
const T2 *win, T3 *out)
const 544 in += _Offset1, win += _Offset2, out += _Offset1;
549 int n = _Radius + _Radius;
551 if (j < 0) n += j, in -= j * _X, win -= j * _X, j = 0;
553 double w, acc = .0, sum = .0;
554 while (j < _Y && n >= 0) {
555 w =
static_cast<double>(_Kernel[n]) * static_cast<double>(*win);
556 acc += w *
static_cast<double>(*in);
558 ++j, in += _X, win += _X, --n;
561 acc = (sum >
Epsilon() ? acc / sum : 0.);
562 *out =
static_cast<T3
>(acc);
568 template <
class TKernel =
double>
580 _Kernel(kernel), _Radius((size - 1) / 2),
581 _Offset1(l1 * image->NumberOfSpatialVoxels()),
582 _Offset2(l2 * image->NumberOfSpatialVoxels()),
583 _XY(image->X() * image->Y()), _Z(image->Z())
586 template <
class T1,
class T2,
class T3>
587 void operator ()(
int,
int,
int k,
int,
const T1 *in,
const T2 *win, T3 *out)
const 590 in += _Offset1, win += _Offset2, out += _Offset1;
594 win -= _Radius * _XY;
595 int n = _Radius + _Radius;
597 if (k < 0) n += k, in -= k * _XY, win -= k * _XY, k = 0;
599 double w, acc = .0, sum = .0;
600 while (k < _Z && n >= 0) {
601 w =
static_cast<double>(_Kernel[n]) * static_cast<double>(*win);
602 acc += w *
static_cast<double>(*in);
604 ++k, in += _XY, win += _XY, --n;
607 acc = (sum >
Epsilon() ? acc / sum : 0.);
608 *out =
static_cast<T3
>(acc);
614 template <
class TKernel =
double>
624 _Kernel(kernel), _Radius((size - 1) / 2),
625 _XYZ(image->X() * image->Y() * image->Z()), _T(image->T())
628 template <
class T1,
class T2,
class T3>
629 void operator ()(
int,
int,
int,
int l,
const T1 *in,
const T2 *win, T3 *out)
const 633 in -= _Radius * _XYZ;
634 win -= _Radius * _XYZ;
635 int n = _Radius + _Radius;
637 if (l < 0) n += l, in -= l * _XYZ, win -= l * _XYZ, l = 0;
639 double w, acc = .0, sum = .0;
640 while (l < _T && n >= 0) {
641 w =
static_cast<double>(_Kernel[n]) * static_cast<double>(*win);
642 acc += w *
static_cast<double>(*in);
644 ++l, in += _XYZ, win += _XYZ, --n;
647 acc = (sum >
Epsilon() ? acc / sum : 0.);
648 *out =
static_cast<T3
>(acc);
658 template <
class TKernel =
double>
667 _Kernel(kernel), _Size(size), _Radius((size - 1) / 2), _Normalize(norm)
686 acc =
static_cast<double>(_Kernel[_Radius]) * static_cast<double>(*in);
687 sum =
static_cast<double>(_Kernel[_Radius]);
698 for (
int k = _Radius + 1; k < _Size; ++k) {
705 acc +=
static_cast<double>(_Kernel[k]) * static_cast<double>(*in);
706 sum +=
static_cast<double>(_Kernel[k]);
716 for (
int k = _Radius - 1; k >= 0; --k) {
723 acc +=
static_cast<double>(_Kernel[k]) * static_cast<double>(*in);
724 sum +=
static_cast<double>(_Kernel[k]);
730 void Put(T *out,
double acc,
double sum)
const 733 (*out) =
static_cast<T
>(acc);
750 template <
class TKernel =
double>
756 _Offset(l * image->NumberOfSpatialVoxels()), _X(image->X())
762 _Offset(l * image->NumberOfSpatialVoxels()), _X(image->X())
764 this->_Background = bg;
770 _Offset(l * image->NumberOfSpatialVoxels()), _X(image->X())
773 template <
class T1,
class T2>
774 void operator ()(
int i,
int,
int,
int,
const T1 *in, T2 *out)
const 776 in += _Offset, out += _Offset;
778 if (this->ConvolveCenterVoxel(in, acc, sum)) {
779 this->ConvolveLeftNeighbors (i, _X, in, 1, acc, sum);
780 this->ConvolveRightNeighbors(i, _X, in, 1, acc, sum);
782 this->Put(out, acc, sum);
791 template <
class TKernel =
double>
797 _Offset(l * image->NumberOfSpatialVoxels()),
805 _Offset(l * image->NumberOfSpatialVoxels()),
809 this->_Background = bg;
815 _Offset(l * image->NumberOfSpatialVoxels()),
820 template <
class T1,
class T2>
821 void operator ()(
int,
int j,
int,
int,
const T1 *in, T2 *out)
const 823 in += _Offset, out += _Offset;
825 if (this->ConvolveCenterVoxel(in, acc, sum)) {
826 this->ConvolveLeftNeighbors (j, _Y, in, _X, acc, sum);
827 this->ConvolveRightNeighbors(j, _Y, in, _X, acc, sum);
829 this->Put(out, acc, sum);
839 template <
class TKernel =
double>
845 _Offset(l * image->NumberOfSpatialVoxels()),
846 _XY(image->X() * image->Y()),
853 _Offset(l * image->NumberOfSpatialVoxels()),
854 _XY(image->X() * image->Y()),
857 this->_Background = bg;
863 _Offset(l * image->NumberOfSpatialVoxels()),
864 _XY(image->X() * image->Y()),
868 template <
class T1,
class T2>
869 void operator ()(
int,
int,
int k,
int,
const T1 *in, T2 *out)
const 871 in += _Offset, out += _Offset;
873 if (this->ConvolveCenterVoxel(in, acc, sum)) {
874 this->ConvolveLeftNeighbors (k, _Z, in, _XY, acc, sum);
875 this->ConvolveRightNeighbors(k, _Z, in, _XY, acc, sum);
877 this->Put(out, acc, sum);
887 template <
class TKernel =
double>
893 _XYZ(image->X() * image->Y() * image->Z()),
900 _XYZ(image->X() * image->Y() * image->Z()),
903 this->_Background = bg;
909 _XYZ(image->X() * image->Y() * image->Z()),
913 template <
class T1,
class T2>
914 void operator ()(
int,
int,
int,
int t,
const T1 *in, T2 *out)
const 917 if (this->ConvolveCenterVoxel(in, acc, sum)) {
918 this->ConvolveLeftNeighbors (t, _T, in, _XYZ, acc, sum);
919 this->ConvolveRightNeighbors(t, _T, in, _XYZ, acc, sum);
921 this->Put(out, acc, sum);
934 template <
class TKernel =
double>
943 _Kernel(kernel), _Size(size), _Radius((size - 1) / 2), _Norm(norm)
958 acc = _Background / _Norm;
961 acc =
static_cast<double>(*in) *
static_cast<double>(_Kernel[_Radius]);
972 for (
int k = _Radius + 1; k < _Size; ++k) {
984 acc +=
static_cast<double>(*in) *
static_cast<double>(_Kernel[k]);
994 for (
int k = _Radius - 1; k >= 0; --k) {
1006 acc +=
static_cast<double>(*in) *
static_cast<double>(_Kernel[k]);
1012 void Put(T *out,
double acc)
const 1014 (*out) =
static_cast<T
>(_Norm * acc);
1021 const TKernel *_Kernel;
1031 template <
class TKernel =
double>
1043 template <
class T1,
class T2>
1044 void operator ()(
int i,
int,
int,
int,
const T1 *in, T2 *out)
const 1047 if (this->ConvolveCenterVoxel(in, acc)) {
1048 this->ConvolveLeftNeighbors (i, _X, in, 1, acc);
1049 this->ConvolveRightNeighbors(i, _X, in, 1, acc);
1051 this->Put(out, acc);
1059 template <
class TKernel =
double>
1076 template <
class T1,
class T2>
1077 void operator ()(
int,
int j,
int,
int,
const T1 *in, T2 *out)
const 1080 if (this->ConvolveCenterVoxel(in, acc)) {
1081 this->ConvolveLeftNeighbors (j, _Y, in, _X, acc);
1082 this->ConvolveRightNeighbors(j, _Y, in, _X, acc);
1084 this->Put(out, acc);
1093 template <
class TKernel =
double>
1099 _XY(image->X() * image->Y()),
1106 _XY(image->X() * image->Y()),
1110 template <
class T1,
class T2>
1111 void operator ()(
int,
int,
int k,
int,
const T1 *in, T2 *out)
const 1114 if (this->ConvolveCenterVoxel(in, acc)) {
1115 this->ConvolveLeftNeighbors (k, _Z, in, _XY, acc);
1116 this->ConvolveRightNeighbors(k, _Z, in, _XY, acc);
1118 this->Put(out, acc);
1127 template <
class TKernel =
double>
1133 _XYZ(image->X() * image->Y() * image->Z()),
1140 _XYZ(image->X() * image->Y() * image->Z()),
1144 template <
class T1,
class T2>
1145 void operator ()(
int,
int,
int,
int t,
const T1 *in, T2 *out)
const 1148 if (this->ConvolveCenterVoxel(in, acc)) {
1149 this->ConvolveLeftNeighbors (t, _T, in, _XYZ, acc);
1150 this->ConvolveRightNeighbors(t, _T, in, _XYZ, acc);
1152 this->Put(out, acc);
1165 template <
class TKernel =
double>
1174 _Kernel(kernel), _Size(size), _Radius((size - 1) / 2), _Norm(norm)
1189 acc = _Background / _Norm;
1192 acc = (*in) * _Kernel[_Radius];
1203 for (
int k = _Radius + 1; k < _Size; ++k) {
1212 acc +=
static_cast<double>(*in) *
static_cast<double>(_Kernel[k]);
1222 for (
int k = _Radius - 1; k >= 0; --k) {
1231 acc +=
static_cast<double>(*in) *
static_cast<double>(_Kernel[k]);
1237 void Put(T *out,
double acc)
const 1239 (*out) =
static_cast<T
>(_Norm * acc);
1246 const TKernel *_Kernel;
1256 template <
class TKernel =
double>
1268 template <
class T1,
class T2>
1269 void operator ()(
int i,
int,
int,
int,
const T1 *in, T2 *out)
const 1272 if (this->ConvolveCenterVoxel(in, acc)) {
1273 this->ConvolveLeftNeighbors (i, _X, in, 1, acc);
1274 this->ConvolveRightNeighbors(i, _X, in, 1, acc);
1276 this->Put(out, acc);
1284 template <
class TKernel =
double>
1301 template <
class T1,
class T2>
1302 void operator ()(
int,
int j,
int,
int,
const T1 *in, T2 *out)
const 1305 if (this->ConvolveCenterVoxel(in, acc)) {
1306 this->ConvolveLeftNeighbors (j, _Y, in, _X, acc);
1307 this->ConvolveRightNeighbors(j, _Y, in, _X, acc);
1309 this->Put(out, acc);
1318 template <
class TKernel =
double>
1324 _XY(image->X() * image->Y()),
1331 _XY(image->X() * image->Y()),
1335 template <
class T1,
class T2>
1336 void operator ()(
int,
int,
int k,
int,
const T1 *in, T2 *out)
const 1339 if (this->ConvolveCenterVoxel(in, acc)) {
1340 this->ConvolveLeftNeighbors (k, _Z, in, _XY, acc);
1341 this->ConvolveRightNeighbors(k, _Z, in, _XY, acc);
1343 this->Put(out, acc);
1352 template <
class TKernel =
double>
1358 _XYZ(image->X() * image->Y() * image->Z()),
1365 _XYZ(image->X() * image->Y() * image->Z()),
1369 template <
class T1,
class T2>
1370 void operator ()(
int,
int,
int,
int t,
const T1 *in, T2 *out)
const 1373 if (this->ConvolveCenterVoxel(in, acc)) {
1374 this->ConvolveLeftNeighbors (t, _T, in, _XYZ, acc);
1375 this->ConvolveRightNeighbors(t, _T, in, _XYZ, acc);
1377 this->Put(out, acc);
1390 template <
class TVoxel,
class TKernel = RealPixel>
1396 _Input(image), _Offset((image->X() % m + 1) / 2), _Factor(m)
1402 _Input(image), _Offset((image->X() % m + 1) / 2), _Factor(m)
1406 void operator ()(
int i,
int j,
int k,
int l, T *out)
const 1408 i = _Offset + i * _Factor;
1419 template <
class TVoxel,
class TKernel = RealPixel>
1425 _Input(image), _Offset((image->Y() % m + 1) / 2), _Factor(m)
1431 _Input(image), _Offset((image->Y() % m + 1) / 2), _Factor(m)
1435 void operator ()(
int i,
int j,
int k,
int l, T *out)
const 1437 j = _Offset + j * _Factor;
1448 template <
class TVoxel,
class TKernel = RealPixel>
1454 _Input(image), _Offset((image->Z() % m + 1) / 2), _Factor(m)
1460 _Input(image), _Offset((image->Z() % m + 1) / 2), _Factor(m)
1464 void operator ()(
int i,
int j,
int k,
int l, T *out)
const 1466 k = _Offset + k * _Factor;
1481 template <
class TVoxel,
class TKernel = RealPixel>
1487 _Input(image), _Offset((image->X() % m + 1) / 2), _Factor(m)
1493 _Input(image), _Offset((image->X() % m + 1) / 2), _Factor(m)
1497 void operator ()(
int i,
int j,
int k,
int l, T *out)
const 1499 i = _Offset + i * _Factor;
1510 template <
class TVoxel,
class TKernel = RealPixel>
1516 _Input(image), _Offset((image->Y() % m + 1) / 2), _Factor(m)
1522 _Input(image), _Offset((image->Y() % m + 1) / 2), _Factor(m)
1526 void operator ()(
int i,
int j,
int k,
int l, T *out)
const 1528 j = _Offset + j * _Factor;
1539 template <
class TVoxel,
class TKernel = RealPixel>
1545 _Input(image), _Offset((image->Z() % m + 1) / 2), _Factor(m)
1551 _Input(image), _Offset((image->Z() % m) / 2), _Factor(m)
1555 void operator ()(
int i,
int j,
int k,
int l, T *out)
const 1557 k = _Offset + k * _Factor;
1569 #endif // MIRTK_ConvolutionFunction_H Downsample image using convolution of original voxels with kernel in y dimension. ...
TruncatedForegroundConvolution1D(const BaseImage *image, const TKernel *kernel, int size, bool norm=true)
Constructor.
int _Z
Number of voxels in z.
bool HasBackgroundValue() const
Whether a background value has been set.
int _T
Number of voxels in t.
double GetBackgroundValueAsDouble() const
Get background value.
Compute convolution for given voxel along z dimension.
Perform convolution along t with truncation of kernel at boundary.
VoxelType * Data(int=0)
Get raw pointer to contiguous image data.
Compute convolution for given voxel along t dimension.
int _XYZ
Number of voxels in frame (nx * ny * nz)
MirroredForegroundConvolution1D(const BaseImage *image, const TKernel *kernel, int size, double norm=1.0)
Constructor.
const GenericImage< TVoxel > * _Input
Image to downsample.
int _X
Number of voxels in x.
const BaseImage * _Image
Image defining foreground region.
int _Offset
Vector component offset.
int _Offset
Vector component offset.
int _Offset
Vector component offset.
int _T
Number of voxels in t.
Perform convolution of weighted image along t with truncation of kernel at boundary.
const TKernel * _Kernel
Convolution kernel.
int _Offset
Vector component offset.
Mirror image at boundary.
Downsample image using convolution of original voxels with kernel in z dimension. ...
const TKernel * _Kernel
Convolution kernel.
Compute convolution of voxel with kernel in x dimension.
const GenericImage< TVoxel > * _Input
Image to downsample.
bool _Normalize
Wether to divide by sum of kernel weights.
Perform convolution of image foreground along z with truncation of kernel at boundary.
bool _Normalize
Wether to divide by sum of kernel weights.
int _Offset2
Weight component offset.
int _XY
Number of voxels in slice (nx * ny)
Compute convolution of voxel with kernel in x dimension.
void ConvolveRightNeighbors(int i, int n, const T *in, int s, double &acc, double &sum) const
Apply kernel to right neighbors of given voxel.
int _Z
Number of voxels in z.
int _Radius
Radius of kernel.
Downsample image using convolution of original voxels with kernel in z dimension. ...
double Epsilon()
Tolerance used for floating point comparisons.
int _XY
Number of voxels in slice (nx * ny)
int _Radius
Radius of kernel.
const BaseImage * _Image
Image defining foreground region.
int _Offset
Offset of first voxel.
Perform convolution of weighted image along x with truncation of kernel at boundary.
const BaseImage * _Image
Image defining foreground region.
int _Factor
Downsampling factor.
int operator()(int i, int N) const
bool _Normalize
Wether to divide by sum of kernel weights.
void ConvolveRightNeighbors(int i, int n, const T *in, int s, double &acc) const
Apply kernel to right neighbors of given voxel.
bool ConvolveCenterVoxel(const T *in, double &acc, double &sum) const
Apply kernel initially at center voxel.
int _Factor
Downsampling factor.
Base class of 1D convolution functions which truncate the kernel at the foreground boundary...
int _Offset1
Image component offset.
Base class of 1D convolution functions which extends the foreground into background.
Perform convolution along z with truncation of kernel at boundary.
Compute convolution for given voxel along t dimension.
int _XYZ
Number of voxels in frame (nx * ny * nz)
int _Radius
Radius of kernel.
int _T
Number of voxels in t dimension (nt)
int _Radius
Radius of kernel.
int _Y
Number of voxels in y dimension (ny)
int _Y
Number of voxels in y.
const TKernel * _Kernel
Convolution kernel.
int _Offset
Vector component offset.
bool ConvolveCenterVoxel(const T *in, double &acc) const
Apply kernel initially at center voxel.
bool IsForeground(int) const
Whether voxel is within foreground without index-out-of-bounds check.
int _Radius
Radius of kernel.
int _Z
Number of voxels in z dimension (nz)
Downsample image using convolution of original voxels with kernel in y dimension. ...
int _Offset
Offset of first voxel.
const GenericImage< TVoxel > * _Input
Image to downsample.
const TKernel * _Kernel
Convolution kernel.
const TKernel * _Kernel
Convolution kernel.
MIRTKCU_API bool AreEqualOrNaN(double a, double b, double tol=1e-12)
Determine equality of two floating point numbers including check if both are NaN. ...
int _Factor
Downsampling factor.
int _T
Number of voxels in t dimension (nt)
int _Radius
Radius of kernel.
bool _Normalize
Wether to divide by sum of kernel weights.
bool _Normalize
Wether to divide by sum of kernel weights.
bool ConvolveCenterVoxel(const T *in, double &acc) const
Apply kernel initially at center voxel.
Base class of 1D convolution functions which mirror the foreground into background.
int _XYZ
Number of voxels in volume (nx * ny * nz)
Compute convolution for given voxel along t dimension.
int _Radius
Radius of kernel.
int _X
Number of voxels in x.
ExtendedForegroundConvolution1D(const BaseImage *image, const TKernel *kernel, int size, double norm=1.0)
Constructor.
int _Offset
Offset of first voxel.
int _Offset
Vector component offset.
int _XY
Number of voxels in slice (nx * ny)
void ConvolveRightNeighbors(int i, int n, const T *in, int s, double &acc) const
Apply kernel to right neighbors of given voxel.
int _X
Number of voxels in x.
int _Offset2
Weight component offset.
Perform convolution along y with truncation of kernel at boundary.
int _XY
Number of voxels in slice (nx * ny)
int _Factor
Downsampling factor.
const TKernel * _Kernel
Convolution kernel.
const TKernel * _Kernel
Convolution kernel.
int _XYZ
Number of voxels in volume (nx * ny * nz)
int _Radius
Radius of kernel.
Downsample image using convolution of original voxels with kernel in x dimension. ...
Compute convolution of voxel with kernel in x dimension.
Compute convolution for given voxel along z dimension.
int _X
Number of voxels in x dimension (nx)
Perform convolution of image foreground along x with truncation of kernel at boundary.
bool _Normalize
Wether to divide by sum of kernel weights.
int _X
Number of voxels in x dimension (nx)
int _Offset
Offset of first voxel.
int _Size
Size of kernel = 2 * _Radius + 1.
int _Radius
Radius of kernel.
Downsample image using convolution of original voxels with kernel in x dimension. ...
bool _Normalize
Wether to divide by sum of kernel weights.
int _X
Number of voxels in x.
int _XY
Number of voxels in slice (nx * ny)
int _Y
Number of voxels in y.
int _T
Number of voxels in t.
const TKernel * _Kernel
Convolution kernel.
int _Offset2
Weight component offset.
const GenericImage< TVoxel > * _Input
Image to downsample.
int _Radius
Radius of kernel.
int _Radius
Radius of kernel.
Perform convolution of weighted image along z with truncation of kernel at boundary.
int _XYZ
Number of voxels in frame (nx * ny * nz)
const TKernel * _Kernel
Convolution kernel.
int _Radius
Radius of kernel.
MIRTKCU_API bool AreEqual(double a, double b, double tol=1e-12)
Determine equality of two floating point numbers.
int _Offset1
Image component offset.
int _Offset
Offset of first voxel.
int _Offset
Offset of first voxel.
int _Radius
Radius of kernel.
void ConvolveLeftNeighbors(int i, int n, const T *in, int s, double &acc) const
Apply kernel to left neighbors of given voxel.
int _X
Number of voxels in x dimension (nx)
Perform convolution of image foreground along t with truncation of kernel at boundary.
Compute convolution for given voxel along z dimension.
void ConvolveLeftNeighbors(int i, int n, const T *in, int s, double &acc, double &sum) const
Apply kernel to left neighbors of given voxel.
int _Z
Number of voxels in z dimension (nz)
int NumberOfVoxels() const
Returns the total number of voxels.
int _X
Number of voxels in x.
const TKernel * _Kernel
Convolution kernel.
int _X
Number of voxels in x dimension (nx)
bool _Normalize
Wether to divide by sum of kernel weights.
bool _Normalize
Whether to normalize by sum of overlapping kernel weights.
void ConvolveLeftNeighbors(int i, int n, const T *in, int s, double &acc) const
Apply kernel to left neighbors of given voxel.
const TKernel * _Kernel
Convolution kernel.
int _Y
Number of voxels in y dimension (ny)
int _Offset
Vector component offset.
Compute convolution for given voxel along y dimension.
const GenericImage< TVoxel > * _Input
Image to downsample.
Compute convolution for given voxel along y dimension.
int _Factor
Downsampling factor.
int _Factor
Downsampling factor.
int _X
Number of voxels in x dimension (nx)
const GenericImage< TVoxel > * _Input
Image to downsample.
int _T
Number of voxels in t dimension (nt)
int _Offset
Vector component offset.
double _Background
Background value (padding)
int _XY
Number of voxels in slice (nx * ny)
int _Y
Number of voxels in y.
int _Z
Number of voxels in z dimension (nz)
int _Offset
Vector component offset.
int _X
Number of voxels in x.
Perform convolution along x with truncation of kernel at boundary.
Perform convolution of weighted image along y with truncation of kernel at boundary.
const TKernel * _Kernel
Convolution kernel.
const TKernel * _Kernel
Convolution kernel.
int _XYZ
Number of voxels in volume (nx * ny * nz)
int _Z
Number of voxels in z.
int _Offset1
Image component offset.
int _Y
Number of voxels in y dimension (ny)
const BaseImage * _Image
Image defining foreground region.
Perform convolution of image foreground along y with truncation of kernel at boundary.
Compute convolution for given voxel along y dimension.
int _X
Number of voxels in x dimension (nx)