16 template <
typename PixelType>
24 Image2(
int dimension0,
int dimension1);
40 inline size_t GetIndex(std::array<int, 2>
const&
coord)
const;
49 inline PixelType
const&
operator() (
int x,
int y)
const;
50 inline PixelType&
operator() (std::array<int, 2>
const& coord);
51 inline PixelType
const&
operator() (std::array<int,2>
const& coord)
const;
52 inline PixelType&
Get(
int x,
int y);
53 inline PixelType
const&
Get(
int x,
int y)
const;
54 inline PixelType&
Get(std::array<int, 2> coord);
55 inline PixelType
const&
Get(std::array<int, 2> coord)
const;
72 void GetCorners(std::array<int, 4>& nbr)
const;
73 void GetFull(std::array<int, 9>& nbr)
const;
76 void GetCorners(
int x,
int y, std::array<size_t, 4>& nbr)
const;
77 void GetFull(
int x,
int y, std::array<size_t, 9>& nbr)
const;
95 template <
typename PixelType>
100 template <
typename PixelType>
105 template <
typename PixelType>
108 Image<PixelType>(
std::vector<
int>{ dimension0, dimension1 })
112 template <
typename PixelType>
115 Image<PixelType>(image)
119 template <
typename PixelType>
126 template <
typename PixelType>
129 *
this = std::move(
image);
132 template <
typename PixelType>
139 template <
typename PixelType>
145 template <
typename PixelType>
inline 148 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 152 return static_cast<size_t>(
x) +
153 static_cast<size_t>(this->
mDimensions[0]) *
static_cast<size_t>(
y);
155 LogError(
"Invalid coordinates (" + std::to_string(x) +
"," +
156 std::to_string(y) +
").");
159 return static_cast<size_t>(
x) +
160 static_cast<size_t>(this->
mDimensions[0]) *
static_cast<size_t>(
y);
164 template <
typename PixelType>
inline 167 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 168 if (0 <= coord[0] && coord[0] < this->
mDimensions[0]
169 && 0 <= coord[1] && coord[1] < this->
mDimensions[1])
171 return static_cast<size_t>(coord[0]) +
172 static_cast<size_t>(this->
mDimensions[0]) *
static_cast<size_t>(coord[1]);
174 LogError(
"Invalid coordinates (" + std::to_string(coord[0]) +
"," +
175 std::to_string(coord[1]) +
").");
178 return static_cast<size_t>(coord[0]) +
179 static_cast<size_t>(this->
mDimensions[0]) *
static_cast<size_t>(coord[1]);
183 template <
typename PixelType>
inline 186 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 187 if (index < mNumPixels)
189 x =
static_cast<int>(index % this->
mDimensions[0]);
190 y =
static_cast<int>(index / this->
mDimensions[0]);
194 LogError(
"Invalid index " + std::to_string(index) +
".");
199 x =
static_cast<int>(index % this->
mDimensions[0]);
200 y =
static_cast<int>(index / this->
mDimensions[0]);
204 template <
typename PixelType>
inline 207 std::array<int, 2>
coord;
208 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 209 if (index < mNumPixels)
211 coord[0] =
static_cast<int>(index % this->
mDimensions[0]);
212 coord[1] =
static_cast<int>(index / this->
mDimensions[0]);
216 LogError(
"Invalid index " + std::to_string(index) +
".");
221 coord[0] =
static_cast<int>(index % this->
mDimensions[0]);
222 coord[1] =
static_cast<int>(index / this->
mDimensions[0]);
227 template <
typename PixelType>
inline 230 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 234 return this->
mPixels[x + this->mDimensions[0] *
y];
236 LogError(
"Invalid coordinates (" + std::to_string(x) +
"," +
237 std::to_string(y) +
").");
240 return this->
mPixels[x + this->mDimensions[0] *
y];
244 template <
typename PixelType>
inline 247 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 251 return this->
mPixels[x + this->mDimensions[0] *
y];
253 LogError(
"Invalid coordinates (" + std::to_string(x) +
"," +
254 std::to_string(y) +
").");
257 return this->
mPixels[x + this->mDimensions[0] *
y];
261 template <
typename PixelType>
inline 264 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 265 if (0 <= coord[0] && coord[0] < this->
mDimensions[0]
266 && 0 <= coord[1] && coord[1] < this->
mDimensions[1])
270 LogError(
"Invalid coordinates (" + std::to_string(coord[0]) +
"," +
271 std::to_string(coord[1]) +
").");
278 template <
typename PixelType>
inline 281 #if defined(GTE_IMAGICS_ASSERT_ON_INVALID_INDEX) 282 if (0 <= coord[0] && coord[0] < this->
mDimensions[0]
283 && 0 <= coord[1] && coord[1] < this->
mDimensions[1])
287 LogError(
"Invalid coordinates (" + std::to_string(coord[0]) +
"," +
288 std::to_string(coord[1]) +
").");
295 template <
typename PixelType>
320 template <
typename PixelType>
345 template <
typename PixelType>
349 for (
int i = 0; i < 2; ++i)
364 template <
typename PixelType>
368 for (
int i = 0; i < 2; ++i)
383 template <
typename PixelType>
393 template <
typename PixelType>
407 template <
typename PixelType>
417 template <
typename PixelType>
432 template <
typename PixelType>
436 std::array<int, 4> inbr;
438 for (
int i = 0; i < 4; ++i)
440 nbr[i] = index + inbr[i];
444 template <
typename PixelType>
448 std::array<int, 8> inbr;
450 for (
int i = 0; i < 8; ++i)
452 nbr[i] = index + inbr[i];
456 template <
typename PixelType>
460 std::array<int, 4> inbr;
462 for (
int i = 0; i < 4; ++i)
464 nbr[i] = index + inbr[i];
468 template <
typename PixelType>
472 std::array<int, 9> inbr;
474 for (
int i = 0; i < 9; ++i)
476 nbr[i] = index + inbr[i];
480 template <
typename PixelType>
483 nbr[0] = { { -1, 0 } };
484 nbr[1] = { { +1, 0 } };
485 nbr[2] = { { 0, -1 } };
486 nbr[3] = { { 0, +1 } };
489 template <
typename PixelType>
492 nbr[0] = { { -1, -1 } };
493 nbr[1] = { { 0, -1 } };
494 nbr[2] = { { +1, -1 } };
495 nbr[3] = { { -1, 0 } };
496 nbr[4] = { { +1, 0 } };
497 nbr[5] = { { -1, +1 } };
498 nbr[6] = { { 0, +1 } };
499 nbr[7] = { { +1, +1 } };
502 template <
typename PixelType>
505 nbr[0] = { { 0, 0 } };
506 nbr[1] = { { 1, 0 } };
507 nbr[2] = { { 0, 1 } };
508 nbr[3] = { { 1, 1 } };
511 template <
typename PixelType>
514 nbr[0] = { { -1, -1 } };
515 nbr[1] = { { 0, -1 } };
516 nbr[2] = { { +1, -1 } };
517 nbr[3] = { { -1, 0 } };
518 nbr[4] = { { 0, 0 } };
519 nbr[5] = { { +1, 0 } };
520 nbr[6] = { { -1, +1 } };
521 nbr[7] = { { 0, +1 } };
522 nbr[8] = { { +1, +1 } };
525 template <
typename PixelType>
528 std::array<std::array<int, 2>, 4> inbr;
530 for (
int i = 0; i < 4; ++i)
532 nbr[i][0] =
static_cast<size_t>(
x) + inbr[i][0];
533 nbr[i][1] =
static_cast<size_t>(
y) + inbr[i][1];
537 template <
typename PixelType>
540 std::array<std::array<int, 2>, 8> inbr;
542 for (
int i = 0; i < 8; ++i)
544 nbr[i][0] =
static_cast<size_t>(
x) + inbr[i][0];
545 nbr[i][1] =
static_cast<size_t>(
y) + inbr[i][1];
549 template <
typename PixelType>
552 std::array<std::array<int, 2>, 4> inbr;
554 for (
int i = 0; i < 4; ++i)
556 nbr[i][0] =
static_cast<size_t>(
x) + inbr[i][0];
557 nbr[i][1] =
static_cast<size_t>(
y) + inbr[i][1];
561 template <
typename PixelType>
564 std::array<std::array<int, 2>, 9> inbr;
566 for (
int i = 0; i < 9; ++i)
568 nbr[i][0] =
static_cast<size_t>(
x) + inbr[i][0];
569 nbr[i][1] =
static_cast<size_t>(
y) + inbr[i][1];
std::vector< int > mDimensions
Image2 & operator=(Image2 const &image)
size_t GetIndex(int x, int y) const
Image & operator=(Image const &image)
void GetFull(std::array< int, 9 > &nbr) const
PixelType & Get(int x, int y)
GLenum GLenum GLsizei void * image
void Reconstruct(int dimension0, int dimension1)
void GetCoordinates(size_t index, int &x, int &y) const
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
#define LogError(message)
PixelType & operator()(int x, int y)
void Reconstruct(std::vector< int > const &dimensions)
void GetNeighborhood(std::array< int, 4 > &nbr) const
std::vector< PixelType > mPixels
void GetCorners(std::array< int, 4 > &nbr) const