16 template <
typename PixelType>
24 Image3(
int dimension0,
int dimension1,
int dimension2);
36 void Reconstruct(
int dimension0,
int dimension1,
int dimension2);
40 inline size_t GetIndex(std::array<int, 3>
const&
coord)
const;
48 inline PixelType&
operator() (
int x,
int y,
int z);
49 inline PixelType
const&
operator() (
int x,
int y,
int z)
const;
50 inline PixelType&
operator() (std::array<int, 3>
const& coord);
51 inline PixelType
const&
operator() (std::array<int,3>
const& coord)
const;
52 inline PixelType&
Get(
int x,
int y,
int z);
53 inline PixelType
const&
Get(
int x,
int y,
int z)
const;
54 inline PixelType&
Get(std::array<int, 3> coord);
55 inline PixelType
const&
Get(std::array<int, 3> coord)
const;
76 void GetCorners(std::array<int, 8>& nbr)
const;
77 void GetFull(std::array<int, 27>& nbr)
const;
78 void GetNeighborhood(
int x,
int y,
int z, std::array<size_t, 6>& nbr)
const;
79 void GetNeighborhood(
int x,
int y,
int z, std::array<size_t, 18>& nbr)
const;
80 void GetNeighborhood(
int x,
int y,
int z, std::array<size_t, 26>& nbr)
const;
81 void GetCorners(
int x,
int y,
int z, std::array<size_t, 8>& nbr)
const;
82 void GetFull(
int x,
int y,
int z, std::array<size_t, 27>& nbr)
const;
98 void GetFull(
int x,
int y,
int z,
std::array<std::array<size_t, 3>, 27>& nbr)
const;
102 template <
typename PixelType>
107 template <
typename PixelType>
112 template <
typename PixelType>
115 Image<PixelType>(
std::vector<
int>{ dimension0, dimension1, dimension2 })
119 template <
typename PixelType>
122 Image<PixelType>(image)
126 template <
typename PixelType>
133 template <
typename PixelType>
136 *
this = std::move(
image);
139 template <
typename PixelType>
146 template <
typename PixelType>
152 template <
typename PixelType>
inline 155 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 160 return static_cast<size_t>(
x) +
161 static_cast<size_t>(this->mDimensions[0]) * (
static_cast<size_t>(
y) +
162 static_cast<size_t>(this->mDimensions[1]) *
static_cast<size_t>(
z));
164 LogError(
"Invalid coordinates (" + std::to_string(x) +
"," +
165 std::to_string(y) +
"," + std::to_string(z) +
").");
168 return static_cast<size_t>(
x) +
169 static_cast<size_t>(this->mDimensions[0]) * (
static_cast<size_t>(
y) +
170 static_cast<size_t>(this->mDimensions[1]) *
static_cast<size_t>(
z));
174 template <
typename PixelType>
inline 177 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 178 if (0 <= coord[0] && coord[0] < this->
mDimensions[0]
179 && 0 <= coord[1] && coord[1] < this->
mDimensions[1]
180 && 0 <= coord[2] && coord[2] < this->
mDimensions[2])
182 return static_cast<size_t>(coord[0]) +
183 static_cast<size_t>(this->
mDimensions[0]) * (
static_cast<size_t>(coord[1]) +
184 static_cast<size_t>(this->
mDimensions[1]) *
static_cast<size_t>(coord[2]));
186 LogError(
"Invalid coordinates (" + std::to_string(coord[0]) +
"," +
187 std::to_string(coord[1]) +
"," + std::to_string(coord[2]) +
").");
190 return static_cast<size_t>(coord[0]) +
191 static_cast<size_t>(this->
mDimensions[0]) * (
static_cast<size_t>(coord[1]) +
192 static_cast<size_t>(this->
mDimensions[1]) *
static_cast<size_t>(coord[2]));
196 template <
typename PixelType>
inline 199 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 200 if (index < mNumPixels)
202 x =
static_cast<int>(index % this->
mDimensions[0]);
204 y =
static_cast<int>(index % this->
mDimensions[1]);
205 z =
static_cast<int>(index / this->
mDimensions[1]);
209 LogError(
"Invalid index " + std::to_string(index) +
".");
215 x =
static_cast<int>(index % this->
mDimensions[0]);
217 y =
static_cast<int>(index % this->
mDimensions[1]);
218 z =
static_cast<int>(index / this->
mDimensions[1]);
222 template <
typename PixelType>
inline 225 std::array<int, 3>
coord;
226 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 227 if (index < mNumPixels)
229 coord[0] =
static_cast<int>(index % this->
mDimensions[0]);
231 coord[1] =
static_cast<int>(index % this->
mDimensions[1]);
232 coord[2] =
static_cast<int>(index / this->
mDimensions[1]);
236 LogError(
"Invalid index " + std::to_string(index) +
".");
242 coord[0] =
static_cast<int>(index % this->
mDimensions[0]);
244 coord[1] =
static_cast<int>(index % this->
mDimensions[1]);
245 coord[2] =
static_cast<int>(index / this->
mDimensions[1]);
250 template <
typename PixelType>
inline 253 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 258 size_t i =
static_cast<size_t>(
x) +
259 static_cast<size_t>(this->mDimensions[0]) * (
static_cast<size_t>(
y) +
260 static_cast<size_t>(this->mDimensions[1]) *
static_cast<size_t>(
z));
263 LogError(
"Invalid coordinates (" + std::to_string(x) +
"," +
264 std::to_string(y) +
"," + std::to_string(z) +
").");
267 size_t i =
static_cast<size_t>(
x) +
268 static_cast<size_t>(this->mDimensions[0]) * (
static_cast<size_t>(
y) +
269 static_cast<size_t>(this->mDimensions[1]) *
static_cast<size_t>(
z));
274 template <
typename PixelType>
inline 277 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 282 size_t i =
static_cast<size_t>(
x) +
283 static_cast<size_t>(this->mDimensions[0]) * (
static_cast<size_t>(
y) +
284 static_cast<size_t>(this->mDimensions[1]) *
static_cast<size_t>(
z));
287 LogError(
"Invalid coordinates (" + std::to_string(x) +
"," +
288 std::to_string(y) +
"," + std::to_string(z) +
").");
291 size_t i =
static_cast<size_t>(
x) +
292 static_cast<size_t>(this->mDimensions[0]) * (
static_cast<size_t>(
y) +
293 static_cast<size_t>(this->mDimensions[1]) *
static_cast<size_t>(
z));
298 template <
typename PixelType>
inline 301 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 302 if (0 <= coord[0] && coord[0] < this->
mDimensions[0]
303 && 0 <= coord[1] && coord[1] < this->
mDimensions[1]
304 && 0 <= coord[2] && coord[2] < this->
mDimensions[2])
306 size_t i =
static_cast<size_t>(coord[0]) +
307 static_cast<size_t>(this->
mDimensions[0]) * (
static_cast<size_t>(coord[1]) +
308 static_cast<size_t>(this->
mDimensions[1]) *
static_cast<size_t>(coord[2]));
311 LogError(
"Invalid coordinates (" + std::to_string(coord[0]) +
"," +
312 std::to_string(coord[1]) +
"," + std::to_string(coord[2]) +
").");
315 size_t i =
static_cast<size_t>(coord[0]) +
316 static_cast<size_t>(this->
mDimensions[0]) * (
static_cast<size_t>(coord[1]) +
317 static_cast<size_t>(this->
mDimensions[1] * coord[2]));
322 template <
typename PixelType>
inline 325 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 326 if (0 <= coord[0] && coord[0] < this->
mDimensions[0]
327 && 0 <= coord[1] && coord[1] < this->
mDimensions[1]
328 && 0 <= coord[2] && coord[2] < this->
mDimensions[2])
330 size_t i =
static_cast<size_t>(coord[0]) +
331 static_cast<size_t>(this->
mDimensions[0]) * (
static_cast<size_t>(coord[1]) +
332 static_cast<size_t>(this->
mDimensions[1]) *
static_cast<size_t>(coord[2]));
335 LogError(
"Invalid coordinates (" + std::to_string(coord[0]) +
"," +
336 std::to_string(coord[1]) +
"," + std::to_string(coord[2]) +
").");
339 size_t i =
static_cast<size_t>(coord[0]) +
340 static_cast<size_t>(this->
mDimensions[0]) * (
static_cast<size_t>(coord[1]) +
341 static_cast<size_t>(this->
mDimensions[1] * coord[2]));
346 template <
typename PixelType>
377 size_t i =
static_cast<size_t>(
x) +
378 static_cast<size_t>(this->
mDimensions[0]) * (
static_cast<size_t>(
y) +
379 static_cast<size_t>(this->
mDimensions[1]) *
static_cast<size_t>(
z));
383 template <
typename PixelType>
414 size_t i =
static_cast<size_t>(
x) +
415 static_cast<size_t>(this->
mDimensions[0]) * (
static_cast<size_t>(
y) +
416 static_cast<size_t>(this->
mDimensions[1]) *
static_cast<size_t>(
z));
420 template <
typename PixelType>
424 for (
int d = 0; d < 3; ++d)
436 size_t i =
static_cast<size_t>(coord[0]) +
437 static_cast<size_t>(this->
mDimensions[0]) * (
static_cast<size_t>(coord[1]) +
438 static_cast<size_t>(this->
mDimensions[1] * coord[2]));
442 template <
typename PixelType>
446 for (
int d = 0; d < 3; ++d)
458 size_t i =
static_cast<size_t>(coord[0]) +
459 static_cast<size_t>(this->
mDimensions[0]) * (
static_cast<size_t>(coord[1]) +
460 static_cast<size_t>(this->
mDimensions[1] * coord[2]));
464 template <
typename PixelType>
477 template <
typename PixelType>
492 nbr[10] = -1 + dim01;
493 nbr[11] = +1 + dim01;
494 nbr[12] = -dim0 + dim01;
495 nbr[13] = +dim0 + dim01;
496 nbr[14] = -1 - dim01;
497 nbr[15] = +1 - dim01;
498 nbr[16] = -dim0 - dim01;
499 nbr[17] = +dim0 - dim01;
502 template <
typename PixelType>
517 nbr[10] = -1 + dim01;
518 nbr[11] = +1 + dim01;
519 nbr[12] = -dim0 + dim01;
520 nbr[13] = +dim0 + dim01;
521 nbr[14] = -1 - dim01;
522 nbr[15] = +1 - dim01;
523 nbr[16] = -dim0 - dim01;
524 nbr[17] = +dim0 - dim01;
525 nbr[18] = -1 - dim0 - dim01;
526 nbr[19] = +1 - dim0 - dim01;
527 nbr[20] = -1 + dim0 - dim01;
528 nbr[21] = +1 + dim0 - dim01;
529 nbr[22] = -1 - dim0 + dim01;
530 nbr[23] = +1 - dim0 + dim01;
531 nbr[24] = -1 + dim0 + dim01;
532 nbr[25] = +1 + dim0 + dim01;
535 template <
typename PixelType>
546 nbr[6] = dim01 + dim0;
547 nbr[7] = dim01 + dim0 + 1;
550 template <
typename PixelType>
555 nbr[0] = -1 - dim0 - dim01;
556 nbr[1] = -dim0 - dim01;
557 nbr[2] = +1 - dim0 - dim01;
561 nbr[6] = -1 + dim0 - dim01;
562 nbr[7] = +dim0 - dim01;
563 nbr[8] = +1 + dim0 - dim01;
573 nbr[18] = -1 - dim0 + dim01;
574 nbr[19] = -dim0 + dim01;
575 nbr[20] = +1 - dim0 + dim01;
576 nbr[21] = -1 + dim01;
578 nbr[23] = +1 + dim01;
579 nbr[24] = -1 + dim0 + dim01;
580 nbr[25] = +dim0 + dim01;
581 nbr[26] = +1 + dim0 + dim01;
584 template <
typename PixelType>
588 std::array<int, 6> inbr;
590 for (
int i = 0; i < 6; ++i)
592 nbr[i] = index + inbr[i];
596 template <
typename PixelType>
600 std::array<int, 18> inbr;
602 for (
int i = 0; i < 18; ++i)
604 nbr[i] = index + inbr[i];
608 template <
typename PixelType>
612 std::array<int, 26> inbr;
614 for (
int i = 0; i < 26; ++i)
616 nbr[i] = index + inbr[i];
620 template <
typename PixelType>
624 std::array<int, 8> inbr;
626 for (
int i = 0; i < 8; ++i)
628 nbr[i] = index + inbr[i];
632 template <
typename PixelType>
636 std::array<int, 27> inbr;
638 for (
int i = 0; i < 27; ++i)
640 nbr[i] = index + inbr[i];
644 template <
typename PixelType>
647 nbr[0] = { { -1, 0, 0 } };
648 nbr[1] = { { +1, 0, 0 } };
649 nbr[2] = { { 0, -1, 0 } };
650 nbr[3] = { { 0, +1, 0 } };
651 nbr[4] = { { 0, 0, -1 } };
652 nbr[5] = { { 0, 0, +1 } };
655 template <
typename PixelType>
658 nbr[0] = { { -1, 0, 0 } };
659 nbr[1] = { { +1, 0, 0 } };
660 nbr[2] = { { 0, -1, 0 } };
661 nbr[3] = { { 0, +1, 0 } };
662 nbr[4] = { { 0, 0, -1 } };
663 nbr[5] = { { 0, 0, +1 } };
664 nbr[6] = { { -1, -1, 0 } };
665 nbr[7] = { { +1, -1, 0 } };
666 nbr[8] = { { -1, +1, 0 } };
667 nbr[9] = { { +1, +1, 0 } };
668 nbr[10] = { { -1, 0, +1 } };
669 nbr[11] = { { +1, 0, +1 } };
670 nbr[12] = { { 0, -1, +1 } };
671 nbr[13] = { { 0, +1, +1 } };
672 nbr[14] = { { -1, 0, -1 } };
673 nbr[15] = { { +1, 0, -1 } };
674 nbr[16] = { { 0, -1, -1 } };
675 nbr[17] = { { 0, +1, -1 } };
678 template <
typename PixelType>
681 nbr[0] = { { -1, 0, 0 } };
682 nbr[1] = { { +1, 0, 0 } };
683 nbr[2] = { { 0, -1, 0 } };
684 nbr[3] = { { 0, +1, 0 } };
685 nbr[4] = { { 0, 0, -1 } };
686 nbr[5] = { { 0, 0, +1 } };
687 nbr[6] = { { -1, -1, 0 } };
688 nbr[7] = { { +1, -1, 0 } };
689 nbr[8] = { { -1, +1, 0 } };
690 nbr[9] = { { +1, +1, 0 } };
691 nbr[10] = { { -1, 0, +1 } };
692 nbr[11] = { { +1, 0, +1 } };
693 nbr[12] = { { 0, -1, +1 } };
694 nbr[13] = { { 0, +1, +1 } };
695 nbr[14] = { { -1, 0, -1 } };
696 nbr[15] = { { +1, 0, -1 } };
697 nbr[16] = { { 0, -1, -1 } };
698 nbr[17] = { { 0, +1, -1 } };
699 nbr[18] = { { -1, -1, -1 } };
700 nbr[19] = { { +1, -1, -1 } };
701 nbr[20] = { { -1, +1, -1 } };
702 nbr[21] = { { +1, +1, -1 } };
703 nbr[22] = { { -1, -1, +1 } };
704 nbr[23] = { { +1, -1, +1 } };
705 nbr[24] = { { -1, +1, +1 } };
706 nbr[25] = { { +1, +1, +1 } };
709 template <
typename PixelType>
712 nbr[0] = { { 0, 0, 0 } };
713 nbr[1] = { { 1, 0, 0 } };
714 nbr[2] = { { 0, 1, 0 } };
715 nbr[3] = { { 1, 1, 0 } };
716 nbr[4] = { { 0, 0, 1 } };
717 nbr[5] = { { 1, 0, 1 } };
718 nbr[6] = { { 0, 1, 1 } };
719 nbr[7] = { { 1, 1, 1 } };
722 template <
typename PixelType>
725 nbr[0] = { { -1, -1, -1 } };
726 nbr[1] = { { 0, -1, -1 } };
727 nbr[2] = { { +1, -1, -1 } };
728 nbr[3] = { { -1, 0, -1 } };
729 nbr[4] = { { 0, 0, -1 } };
730 nbr[5] = { { +1, 0, -1 } };
731 nbr[6] = { { -1, +1, -1 } };
732 nbr[7] = { { 0, +1, -1 } };
733 nbr[8] = { { +1, +1, -1 } };
734 nbr[9] = { { -1, -1, 0 } };
735 nbr[10] = { { 0, -1, 0 } };
736 nbr[11] = { { +1, -1, 0 } };
737 nbr[12] = { { -1, 0, 0 } };
738 nbr[13] = { { 0, 0, 0 } };
739 nbr[14] = { { +1, 0, 0 } };
740 nbr[15] = { { -1, +1, 0 } };
741 nbr[16] = { { 0, +1, 0 } };
742 nbr[17] = { { +1, +1, 0 } };
743 nbr[18] = { { -1, -1, +1 } };
744 nbr[19] = { { 0, -1, +1 } };
745 nbr[20] = { { +1, -1, +1 } };
746 nbr[21] = { { -1, 0, +1 } };
747 nbr[22] = { { 0, 0, +1 } };
748 nbr[23] = { { +1, 0, +1 } };
749 nbr[24] = { { -1, +1, +1 } };
750 nbr[25] = { { 0, +1, +1 } };
751 nbr[26] = { { +1, +1, +1 } };
754 template <
typename PixelType>
757 std::array<std::array<int, 3>, 6> inbr;
759 for (
int i = 0; i < 6; ++i)
761 nbr[i][0] =
static_cast<size_t>(
x) + inbr[i][0];
762 nbr[i][1] =
static_cast<size_t>(
y) + inbr[i][1];
763 nbr[i][2] =
static_cast<size_t>(
z) + inbr[i][2];
767 template <
typename PixelType>
770 std::array<std::array<int, 3>, 18> inbr;
772 for (
int i = 0; i < 18; ++i)
774 nbr[i][0] =
static_cast<size_t>(
x) + inbr[i][0];
775 nbr[i][1] =
static_cast<size_t>(
y) + inbr[i][1];
776 nbr[i][2] =
static_cast<size_t>(
z) + inbr[i][2];
780 template <
typename PixelType>
783 std::array<std::array<int, 3>, 26> inbr;
785 for (
int i = 0; i < 26; ++i)
787 nbr[i][0] =
static_cast<size_t>(
x) + inbr[i][0];
788 nbr[i][1] =
static_cast<size_t>(
y) + inbr[i][1];
789 nbr[i][2] =
static_cast<size_t>(
z) + inbr[i][2];
793 template <
typename PixelType>
795 std::array<std::array<size_t, 3>, 8>& nbr)
const 797 std::array<std::array<int, 3>, 8> inbr;
799 for (
int i = 0; i < 8; ++i)
801 nbr[i][0] =
static_cast<size_t>(
x) + inbr[i][0];
802 nbr[i][1] =
static_cast<size_t>(
y) + inbr[i][1];
803 nbr[i][2] =
static_cast<size_t>(
z) + inbr[i][2];
807 template <
typename PixelType>
809 std::array<std::array<size_t, 3>, 27>& nbr)
const 811 std::array<std::array<int, 3>, 27> inbr;
813 for (
int i = 0; i < 27; ++i)
815 nbr[i][0] =
static_cast<size_t>(
x) + inbr[i][0];
816 nbr[i][1] =
static_cast<size_t>(
y) + inbr[i][1];
817 nbr[i][2] =
static_cast<size_t>(
z) + inbr[i][2];
std::vector< int > mDimensions
Image & operator=(Image const &image)
PixelType & operator()(int x, int y, int z)
Image3 & operator=(Image3 const &image)
GLenum GLenum GLsizei void * image
void GetCorners(std::array< int, 8 > &nbr) const
void Reconstruct(int dimension0, int dimension1, int dimension2)
void GetNeighborhood(std::array< int, 6 > &nbr) const
PixelType & Get(int x, int y, int z)
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
#define LogError(message)
void GetCoordinates(size_t index, int &x, int &y, int &z) const
void Reconstruct(std::vector< int > const &dimensions)
GLdouble GLdouble GLdouble z
std::vector< PixelType > mPixels
void GetFull(std::array< int, 27 > &nbr) const
size_t GetIndex(int x, int y, int z) const