47 #include <visp3/core/vpConfig.h> 48 #include <visp3/core/vpDebug.h> 49 #include <visp3/core/vpEndian.h> 50 #include <visp3/core/vpException.h> 51 #include <visp3/core/vpImageException.h> 52 #include <visp3/core/vpImagePoint.h> 53 #include <visp3/core/vpRGBa.h> 55 #if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0)) 56 #include <visp3/core/vpThread.h> 66 #if defined(_MSC_VER) && (_MSC_VER < 1700) 67 typedef long long int64_t;
68 typedef unsigned short uint16_t;
70 # include <inttypes.h> 129 template <
class Type> std::ostream &operator<<(std::ostream &, const vpImage<Type> &);
131 std::ostream &operator<<(std::ostream &, const vpImage<unsigned char> &);
132 std::ostream &operator<<(std::ostream &, const vpImage<char> &);
133 std::ostream &operator<<(std::ostream &, const vpImage<float> &);
134 std::ostream &operator<<(std::ostream &, const vpImage<double> &);
138 template <
class Type>
class vpImage 150 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 154 vpImage(
unsigned int height,
unsigned int width);
157 vpImage(
unsigned int height,
unsigned int width, Type value);
159 vpImage(Type *
const array,
unsigned int height,
unsigned int width,
bool copyData =
false);
179 inline unsigned int getCols()
const {
return width; }
188 inline unsigned int getHeight()
const {
return height; }
218 inline unsigned int getRows()
const {
return height; }
227 inline unsigned int getSize()
const {
return width * height; }
230 Type
getValue(
unsigned int i,
unsigned int j)
const;
232 Type
getValue(
double i,
double j)
const;
246 inline unsigned int getWidth()
const {
return width; }
252 void init(
unsigned int height,
unsigned int width);
254 void init(
unsigned int height,
unsigned int width, Type value);
256 void init(Type *
const array,
unsigned int height,
unsigned int width,
bool copyData =
false);
267 inline const Type *
operator[](
unsigned int i)
const {
return row[i]; }
268 inline const Type *
operator[](
int i)
const {
return row[i]; }
276 inline Type
operator()(
unsigned int i,
unsigned int j)
const {
return bitmap[i * width + j]; }
282 inline void operator()(
unsigned int i,
unsigned int j,
const Type &v) { bitmap[i * width + j] = v; }
296 unsigned int i = (
unsigned int)ip.
get_i();
297 unsigned int j = (
unsigned int)ip.
get_j();
299 return bitmap[i * width + j];
312 unsigned int i = (
unsigned int)ip.
get_i();
313 unsigned int j = (
unsigned int)ip.
get_j();
315 bitmap[i * width + j] = v;
326 friend std::ostream &operator<< <>(std::ostream &s,
const vpImage<Type> &I);
327 friend std::ostream &operator<<(std::ostream &s, const vpImage<unsigned char> &I);
328 friend std::ostream &operator<<(std::ostream &s, const vpImage<char> &I);
329 friend std::ostream &operator<<(std::ostream &s, const vpImage<float> &I);
330 friend std::ostream &operator<<(std::ostream &s, const vpImage<double> &I);
333 void performLut(
const Type (&lut)[256],
unsigned int nbThreads = 1);
339 void resize(
unsigned int h,
unsigned int w);
341 void resize(
unsigned int h,
unsigned int w,
const Type &val);
352 unsigned int npixels;
359 template <
class Type> std::ostream &operator<<(std::ostream &s, const vpImage<Type> &I)
365 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
366 for (
unsigned int j = 0; j < I.
getWidth() - 1; j++) {
374 if (i < I.getHeight() - 1) {
382 inline std::ostream &operator<<(std::ostream &s, const vpImage<unsigned char> &I)
388 std::ios_base::fmtflags original_flags = s.flags();
390 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
391 for (
unsigned int j = 0; j < I.
getWidth() - 1; j++) {
392 s << std::setw(3) << static_cast<unsigned>(I[i][j]) <<
" ";
396 s << std::setw(3) << static_cast<unsigned>(I[i][I.
getWidth() - 1]);
404 s.flags(original_flags);
408 inline std::ostream &operator<<(std::ostream &s, const vpImage<char> &I)
414 std::ios_base::fmtflags original_flags = s.flags();
416 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
417 for (
unsigned int j = 0; j < I.
getWidth() - 1; j++) {
418 s << std::setw(4) << static_cast<int>(I[i][j]) <<
" ";
422 s << std::setw(4) << static_cast<int>(I[i][I.
getWidth() - 1]);
430 s.flags(original_flags);
434 inline std::ostream &operator<<(std::ostream &s, const vpImage<float> &I)
440 std::ios_base::fmtflags original_flags = s.flags();
443 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
444 for (
unsigned int j = 0; j < I.
getWidth() - 1; j++) {
452 if (i < I.getHeight() - 1) {
457 s.flags(original_flags);
461 inline std::ostream &operator<<(std::ostream &s, const vpImage<double> &I)
467 std::ios_base::fmtflags original_flags = s.flags();
470 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
471 for (
unsigned int j = 0; j < I.
getWidth() - 1; j++) {
479 if (i < I.getHeight() - 1) {
484 s.flags(original_flags);
488 #if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0)) 491 struct ImageLut_Param_t {
492 unsigned int m_start_index;
493 unsigned int m_end_index;
495 unsigned char m_lut[256];
496 unsigned char *m_bitmap;
498 ImageLut_Param_t() : m_start_index(0), m_end_index(0), m_lut(), m_bitmap(NULL) {}
500 ImageLut_Param_t(
unsigned int start_index,
unsigned int end_index,
unsigned char *
bitmap)
501 : m_start_index(start_index), m_end_index(end_index), m_lut(), m_bitmap(bitmap)
508 ImageLut_Param_t *imageLut_param =
static_cast<ImageLut_Param_t *
>(args);
509 unsigned int start_index = imageLut_param->m_start_index;
510 unsigned int end_index = imageLut_param->m_end_index;
512 unsigned char *
bitmap = imageLut_param->m_bitmap;
514 unsigned char *ptrStart = bitmap + start_index;
515 unsigned char *ptrEnd = bitmap + end_index;
516 unsigned char *ptrCurrent = ptrStart;
523 if (end_index - start_index >= 8) {
525 for (; ptrCurrent <= ptrEnd - 8;) {
526 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
529 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
532 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
535 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
538 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
541 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
544 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
547 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
552 for (; ptrCurrent != ptrEnd; ++ptrCurrent) {
553 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
559 struct ImageLutRGBa_Param_t {
560 unsigned int m_start_index;
561 unsigned int m_end_index;
564 unsigned char *m_bitmap;
566 ImageLutRGBa_Param_t() : m_start_index(0), m_end_index(0), m_lut(), m_bitmap(NULL) {}
568 ImageLutRGBa_Param_t(
unsigned int start_index,
unsigned int end_index,
unsigned char *
bitmap)
569 : m_start_index(start_index), m_end_index(end_index), m_lut(), m_bitmap(bitmap)
576 ImageLutRGBa_Param_t *imageLut_param =
static_cast<ImageLutRGBa_Param_t *
>(args);
577 unsigned int start_index = imageLut_param->m_start_index;
578 unsigned int end_index = imageLut_param->m_end_index;
580 unsigned char *
bitmap = imageLut_param->m_bitmap;
582 unsigned char *ptrStart = bitmap + start_index * 4;
583 unsigned char *ptrEnd = bitmap + end_index * 4;
584 unsigned char *ptrCurrent = ptrStart;
586 if (end_index - start_index >= 4 * 2) {
588 for (; ptrCurrent <= ptrEnd - 4 * 2;) {
589 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].R;
591 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].G;
593 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].B;
595 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].A;
598 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].R;
600 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].G;
602 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].B;
604 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].A;
609 while (ptrCurrent != ptrEnd) {
610 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].R;
613 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].G;
616 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].B;
619 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].A;
645 if (h != this->height) {
653 if ((h != this->height) || (w != this->width)) {
666 npixels = width * height;
669 bitmap =
new Type[npixels];
678 row =
new Type *[height];
683 for (
unsigned int i = 0; i < height; i++)
684 row[i] =
bitmap + i * width;
690 template <
class Type>
693 if (h != this->height) {
701 if ((copyData && ((h != this->height) || (w != this->width))) || !copyData) {
710 hasOwnership = copyData;
714 npixels = width * height;
718 bitmap =
new Type[npixels];
725 memcpy(static_cast<void*>(
bitmap), static_cast<void*>(array), (
size_t)(npixels *
sizeof(Type)));
732 row =
new Type *[height];
737 for (
unsigned int i = 0; i < height; i++) {
738 row[i] =
bitmap + i * width;
745 template <
class Type>
747 :
bitmap(NULL),
display(NULL), npixels(0), width(0), height(0), row(NULL), hasOwnership(true)
755 template <
class Type>
757 :
bitmap(NULL),
display(NULL), npixels(0), width(0), height(0), row(NULL), hasOwnership(true)
765 template <
class Type>
767 :
bitmap(NULL),
display(NULL), npixels(0), width(0), height(0), row(NULL), hasOwnership(true)
769 init(array, h, w, copyData);
776 bitmap(NULL),
display(NULL), npixels(0), width(0), height(0), row(NULL), hasOwnership(true)
861 template <
class Type>
863 :
bitmap(NULL),
display(NULL), npixels(0), width(0), height(0), row(NULL), hasOwnership(true)
866 memcpy(static_cast<void*>(
bitmap), static_cast<void*>(I.
bitmap), I.npixels *
sizeof(Type));
869 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 873 template <
class Type>
875 :
bitmap(I.
bitmap),
display(I.
display), npixels(I.npixels), width(I.width), height(I.height), row(I.row), hasOwnership(I.hasOwnership)
883 I.hasOwnership =
false;
897 for (
unsigned int i = 0; i < npixels; i++) {
909 if ((height == 0) || (width == 0))
912 return getSum() / (height * width);
925 for (
unsigned int i = 0; i < npixels; i++)
944 for (
unsigned int i = 0; i < npixels; i++) {
973 template <
class Type>
978 "values of an empty image"));
982 for (
unsigned int i = 0; i < height; i++) {
983 for (
unsigned int j = 0; j < width; j++) {
984 if (row[i][j] < min) {
989 if (row[i][j] > max) {
1033 for (
unsigned int i = 0; i < npixels; i++)
1053 for (
unsigned int i = 0; i < npixels; i++) {
1069 return !(*
this == I);
1117 int itl = (int)topLeft.
get_i();
1118 int jtl = (int)topLeft.
get_j();
1120 int dest_ibegin = 0;
1121 int dest_jbegin = 0;
1124 int dest_w = (int)this->
getWidth();
1131 if (itl >= dest_h || jtl >= dest_w)
1144 if (src_w - src_jbegin > dest_w - dest_jbegin)
1145 wsize = dest_w - dest_jbegin;
1147 wsize = src_w - src_jbegin;
1149 if (src_h - src_ibegin > dest_h - dest_ibegin)
1150 hsize = dest_h - dest_ibegin;
1152 hsize = src_h - src_ibegin;
1154 for (
int i = 0; i < hsize; i++) {
1155 Type *srcBitmap = src.
bitmap + ((src_ibegin + i) * src_w + src_jbegin);
1156 Type *destBitmap = this->
bitmap + ((dest_ibegin + i) * dest_w + dest_jbegin);
1158 memcpy(static_cast<void*>(destBitmap), static_cast<void*>(srcBitmap), (
size_t)wsize *
sizeof(Type));
1194 unsigned int h = height / 2;
1195 unsigned int w = width / 2;
1197 for (
unsigned int i = 0; i < h; i++)
1198 for (
unsigned int j = 0; j < w; j++)
1199 res[i][j] = (*
this)[i << 1][j << 1];
1219 template <
class Type>
1222 if (v_scale == 1 && h_scale == 1) {
1226 unsigned int h = height / v_scale;
1227 unsigned int w = width / h_scale;
1229 for (
unsigned int i = 0; i < h; i++)
1230 for (
unsigned int j = 0; j < w; j++)
1231 sampled[i][j] = (*
this)[i * v_scale][j * h_scale];
1258 unsigned int h = height / 4;
1259 unsigned int w = width / 4;
1261 for (
unsigned int i = 0; i < h; i++)
1262 for (
unsigned int j = 0; j < w; j++)
1263 res[i][j] = (*
this)[i << 2][j << 2];
1305 for (
int i = 0; i < h; i++)
1306 for (
int j = 0; j < w; j++)
1307 res[i][j] = (*
this)[i >> 1][j >> 1];
1318 for (
int i = 0; i < h; i += 2)
1319 for (
int j = 1; j < w - 1; j += 2)
1320 res[i][j] = (Type)(0.5 * ((*this)[i >> 1][j >> 1] + (*this)[i >> 1][(j >> 1) + 1]));
1323 for (
int i = 1; i < h - 1; i += 2)
1324 for (
int j = 0; j < w; j += 2)
1325 res[i][j] = (Type)(0.5 * ((*this)[i >> 1][j >> 1] + (*this)[(i >> 1) + 1][j >> 1]));
1328 for (
int i = 1; i < h - 1; i += 2)
1329 for (
int j = 1; j < w - 1; j += 2)
1330 res[i][j] = (Type)(0.25 * ((*this)[i >> 1][j >> 1] + (*this)[i >> 1][(j >> 1) + 1] +
1331 (*
this)[(i >> 1) + 1][j >> 1] + (*
this)[(i >> 1) + 1][(j >> 1) + 1]));
1348 if (i >= height || j >= width) {
1373 if (i < 0 || j < 0 || i+1 > height || j+1 > width) {
1376 if (height * width == 0) {
1380 unsigned int iround =
static_cast<unsigned int>(floor(i));
1381 unsigned int jround =
static_cast<unsigned int>(floor(j));
1383 double rratio = i -
static_cast<double>(iround);
1384 double cratio = j -
static_cast<double>(jround);
1386 double rfrac = 1.0 - rratio;
1387 double cfrac = 1.0 - cratio;
1389 unsigned int iround_1 = (std::min)(height - 1, iround + 1);
1390 unsigned int jround_1 = (std::min)(width - 1, jround + 1);
1392 double value = (
static_cast<double>(row[iround][jround]) * rfrac + static_cast<double>(row[iround_1][jround]) * rratio) * cfrac +
1393 (static_cast<double>(row[iround][jround_1]) * rfrac +
static_cast<double>(row[iround_1][jround_1]) * rratio) * cratio;
1403 if (i < 0 || j < 0 || i+1 > height || j+1 > width) {
1406 if (height * width == 0) {
1410 unsigned int iround =
static_cast<unsigned int>(floor(i));
1411 unsigned int jround =
static_cast<unsigned int>(floor(j));
1413 double rratio = i -
static_cast<double>(iround);
1414 double cratio = j -
static_cast<double>(jround);
1416 double rfrac = 1.0 - rratio;
1417 double cfrac = 1.0 - cratio;
1419 unsigned int iround_1 = (std::min)(height - 1, iround + 1);
1420 unsigned int jround_1 = (std::min)(width - 1, jround + 1);
1422 return (row[iround][jround] * rfrac + row[iround_1][jround] * rratio) * cfrac +
1423 (row[iround][jround_1] * rfrac + row[iround_1][jround_1] * rratio) * cratio;
1430 if (i < 0 || j < 0 || i+1 > height || j+1 > width) {
1433 if (height * width == 0) {
1438 #if (defined(VISP_LITTLE_ENDIAN) || defined(VISP_BIG_ENDIAN)) && !(defined(__alpha__) || defined(_M_ALPHA)) 1440 const int32_t precision = 1 << 16;
1441 int64_t y =
static_cast<int64_t
>(i * precision);
1442 int64_t x =
static_cast<int64_t
>(j * precision);
1444 int64_t iround = y & (~0xFFFF);
1445 int64_t jround = x & (~0xFFFF);
1447 int64_t rratio = y - iround;
1448 int64_t cratio = x - jround;
1450 int64_t rfrac = precision - rratio;
1451 int64_t cfrac = precision - cratio;
1453 int64_t x_ = x >> 16;
1454 int64_t y_ = y >> 16;
1456 if (y_ + 1 < height && x_ + 1 < width) {
1460 return static_cast<unsigned char>((((up & 0x00FF) * rfrac + (down & 0x00FF) * rratio) * cfrac +
1461 ((up >> 8) * rfrac + (down >> 8) * rratio) * cratio) >> 32);
1462 }
else if (y_ + 1 < height) {
1463 return static_cast<unsigned char>(((row[y_][x_] * rfrac + row[y_ + 1][x_] * rratio)) >> 16);
1464 }
else if (x_ + 1 < width) {
1466 return static_cast<unsigned char>(((up & 0x00FF) * cfrac + (up >> 8) * cratio) >> 16);
1471 unsigned int iround =
static_cast<unsigned int>(floor(i));
1472 unsigned int jround =
static_cast<unsigned int>(floor(j));
1474 if (iround >= height || jround >= width) {
1477 "Pixel outside the image"));
1480 double rratio = i -
static_cast<double>(iround);
1481 double cratio = j -
static_cast<double>(jround);
1483 double rfrac = 1.0 - rratio;
1484 double cfrac = 1.0 - cratio;
1486 unsigned int iround_1 = (std::min)(height - 1, iround + 1);
1487 unsigned int jround_1 = (std::min)(width - 1, jround + 1);
1489 double value = (
static_cast<double>(row[iround][jround]) * rfrac + static_cast<double>(row[iround_1][jround]) * rratio) * cfrac +
1490 (static_cast<double>(row[iround][jround_1]) * rfrac +
static_cast<double>(row[iround_1][jround_1]) * rratio) * cratio;
1500 if (i < 0 || j < 0 || i+1 > height || j+1 > width) {
1503 if (height * width == 0) {
1507 unsigned int iround =
static_cast<unsigned int>(floor(i));
1508 unsigned int jround =
static_cast<unsigned int>(floor(j));
1510 double rratio = i -
static_cast<double>(iround);
1511 double cratio = j -
static_cast<double>(jround);
1513 double rfrac = 1.0 - rratio;
1514 double cfrac = 1.0 - cratio;
1516 unsigned int iround_1 = (std::min)(height - 1, iround + 1);
1517 unsigned int jround_1 = (std::min)(width - 1, jround + 1);
1519 double valueR = (
static_cast<double>(row[iround][jround].R) * rfrac + static_cast<double>(row[iround_1][jround].R) * rratio) * cfrac +
1520 (static_cast<double>(row[iround][jround_1].R) * rfrac +
static_cast<double>(row[iround_1][jround_1].R) * rratio) * cratio;
1521 double valueG = (
static_cast<double>(row[iround][jround].G) * rfrac + static_cast<double>(row[iround_1][jround].G) * rratio) * cfrac +
1522 (static_cast<double>(row[iround][jround_1].G) * rfrac +
static_cast<double>(row[iround_1][jround_1].G) * rratio) * cratio;
1523 double valueB = (
static_cast<double>(row[iround][jround].B) * rfrac + static_cast<double>(row[iround_1][jround].B) * rratio) * cfrac +
1524 (static_cast<double>(row[iround][jround_1].B) * rfrac +
static_cast<double>(row[iround_1][jround_1].B) * rratio) * cratio;
1581 if ((height == 0) || (width == 0))
1585 for (
unsigned int i = 0; i < height * width; ++i) {
1586 res +=
static_cast<double>(
bitmap[i]);
1627 std::cout << me << std::endl;
1658 std::cout << me << std::endl;
1681 std::cerr <<
"Not implemented !" << std::endl;
1697 unsigned char *ptrStart = (
unsigned char *)
bitmap;
1698 unsigned char *ptrEnd = ptrStart + size;
1699 unsigned char *ptrCurrent = ptrStart;
1701 bool use_single_thread = (nbThreads == 0 || nbThreads == 1);
1702 #if !defined(VISP_HAVE_PTHREAD) && !defined(_WIN32) 1703 use_single_thread =
true;
1706 if (!use_single_thread &&
getSize() <= nbThreads) {
1707 use_single_thread =
true;
1710 if (use_single_thread) {
1713 while (ptrCurrent != ptrEnd) {
1714 *ptrCurrent = lut[*ptrCurrent];
1718 #if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0)) 1721 std::vector<vpThread *> threadpool;
1722 std::vector<ImageLut_Param_t *> imageLutParams;
1724 unsigned int image_size =
getSize();
1725 unsigned int step = image_size / nbThreads;
1726 unsigned int last_step = image_size - step * (nbThreads - 1);
1728 for (
unsigned int index = 0; index < nbThreads; index++) {
1729 unsigned int start_index = index * step;
1730 unsigned int end_index = (index + 1) * step;
1732 if (index == nbThreads - 1) {
1733 end_index = start_index + last_step;
1736 ImageLut_Param_t *imageLut_param =
new ImageLut_Param_t(start_index, end_index,
bitmap);
1737 memcpy(imageLut_param->m_lut, lut, 256 *
sizeof(
unsigned char));
1739 imageLutParams.push_back(imageLut_param);
1743 threadpool.push_back(imageLut_thread);
1746 for (
size_t cpt = 0; cpt < threadpool.size(); cpt++) {
1748 threadpool[cpt]->join();
1752 for (
size_t cpt = 0; cpt < threadpool.size(); cpt++) {
1753 delete threadpool[cpt];
1756 for (
size_t cpt = 0; cpt < imageLutParams.size(); cpt++) {
1757 delete imageLutParams[cpt];
1776 unsigned char *ptrStart = (
unsigned char *)
bitmap;
1777 unsigned char *ptrEnd = ptrStart + size * 4;
1778 unsigned char *ptrCurrent = ptrStart;
1780 bool use_single_thread = (nbThreads == 0 || nbThreads == 1);
1781 #if !defined(VISP_HAVE_PTHREAD) && !defined(_WIN32) 1782 use_single_thread =
true;
1785 if (!use_single_thread &&
getSize() <= nbThreads) {
1786 use_single_thread =
true;
1789 if (use_single_thread) {
1791 while (ptrCurrent != ptrEnd) {
1792 *ptrCurrent = lut[*ptrCurrent].R;
1795 *ptrCurrent = lut[*ptrCurrent].G;
1798 *ptrCurrent = lut[*ptrCurrent].B;
1801 *ptrCurrent = lut[*ptrCurrent].A;
1805 #if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0)) 1807 std::vector<vpThread *> threadpool;
1808 std::vector<ImageLutRGBa_Param_t *> imageLutParams;
1810 unsigned int image_size =
getSize();
1811 unsigned int step = image_size / nbThreads;
1812 unsigned int last_step = image_size - step * (nbThreads - 1);
1814 for (
unsigned int index = 0; index < nbThreads; index++) {
1815 unsigned int start_index = index * step;
1816 unsigned int end_index = (index + 1) * step;
1818 if (index == nbThreads - 1) {
1819 end_index = start_index + last_step;
1822 ImageLutRGBa_Param_t *imageLut_param =
new ImageLutRGBa_Param_t(start_index, end_index, (
unsigned char *)
bitmap);
1823 memcpy(static_cast<void*>(imageLut_param->m_lut), lut, 256 *
sizeof(
vpRGBa));
1825 imageLutParams.push_back(imageLut_param);
1829 threadpool.push_back(imageLut_thread);
1832 for (
size_t cpt = 0; cpt < threadpool.size(); cpt++) {
1834 threadpool[cpt]->join();
1838 for (
size_t cpt = 0; cpt < threadpool.size(); cpt++) {
1839 delete threadpool[cpt];
1842 for (
size_t cpt = 0; cpt < imageLutParams.size(); cpt++) {
1843 delete imageLutParams[cpt];
1854 swap(first.npixels, second.npixels);
1855 swap(first.width, second.width);
1856 swap(first.height, second.height);
1857 swap(first.row, second.row);
void quarterSizeImage(vpImage< Type > &res) const
unsigned int getCols() const
void performLut(const Type(&lut)[256], unsigned int nbThreads=1)
VISP_EXPORT uint16_t reinterpret_cast_uchar_to_uint16_LE(unsigned char *const ptr)
void doubleSizeImage(vpImage< Type > &res)
Class that defines generic functionnalities for display.
unsigned int getWidth() const
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
void getMinMaxValue(Type &min, Type &max) const
Look for the minimum and the maximum value within the bitmap.
Type * bitmap
points toward the bitmap
Type operator()(const vpImagePoint &ip) const
void operator()(unsigned int i, unsigned int j, const Type &v)
error that can be emited by ViSP classes.
Type getMinValue() const
Return the minimum value within the bitmap.
virtual ~vpImage()
destructor
vpImage< Type > & operator=(vpImage< Type > other)
Copy operator.
unsigned int getRows() const
Type getValue(unsigned int i, unsigned int j) const
friend void swap(vpImage< Type > &first, vpImage< Type > &second)
unsigned int getSize() const
bool operator!=(const vpImage< Type > &I)
void operator()(const vpImagePoint &ip, const Type &v)
Type getMaxValue() const
Return the maximum value within the bitmap.
const Type * operator[](int i) const
unsigned int getNumberOfPixel() const
void init(unsigned int height, unsigned int width)
Set the size of the image.
void insert(const vpImage< Type > &src, const vpImagePoint &topLeft)
void destroy()
Destructor : Memory de-allocation.
const Type * operator[](unsigned int i) const
operator[] allows operation like x = I[i]
Type * operator[](unsigned int i)
operator[] allows operation like I[i] = x.
void subsample(unsigned int v_scale, unsigned int h_scale, vpImage< Type > &sampled) const
static int round(double x)
void halfSizeImage(vpImage< Type > &res) const
void set_ij(double ii, double jj)
Type operator()(unsigned int i, unsigned int j) const
vpImage< Type > operator-(const vpImage< Type > &B)
Type getMeanValue() const
Return the mean value of the bitmap.
unsigned int getHeight() const
void getMinMaxLoc(vpImagePoint *minLoc, vpImagePoint *maxLoc, Type *minVal=NULL, Type *maxVal=NULL) const
Get the position of the minimum and/or the maximum pixel value within the bitmap and the correspondin...
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition of the vpImage class member functions.
bool operator==(const vpImage< Type > &I)
void sub(const vpImage< Type > &B, vpImage< Type > &C)