47 #include <visp3/core/vpConfig.h> 48 #include <visp3/core/vpDebug.h> 49 #include <visp3/core/vpException.h> 50 #include <visp3/core/vpImageException.h> 51 #include <visp3/core/vpImagePoint.h> 52 #include <visp3/core/vpRGBa.h> 53 #if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0)) 54 #include <visp3/core/vpThread.h> 119 template <
class Type> std::ostream &operator<<(std::ostream &, const vpImage<Type> &);
121 std::ostream &operator<<(std::ostream &, const vpImage<unsigned char> &);
122 std::ostream &operator<<(std::ostream &, const vpImage<char> &);
123 std::ostream &operator<<(std::ostream &, const vpImage<float> &);
124 std::ostream &operator<<(std::ostream &, const vpImage<double> &);
128 template <
class Type>
class vpImage 140 #ifdef VISP_HAVE_CPP11_COMPATIBILITY 144 vpImage(
unsigned int height,
unsigned int width);
147 vpImage(
unsigned int height,
unsigned int width, Type value);
149 vpImage(Type *
const array,
const unsigned int height,
const unsigned int width,
const bool copyData =
false);
169 inline unsigned int getCols()
const {
return width; }
178 inline unsigned int getHeight()
const {
return height; }
211 inline unsigned int getRows()
const {
return height; }
219 inline unsigned int getSize()
const {
return width * height; }
222 Type
getValue(
unsigned int i,
unsigned int j)
const;
224 Type
getValue(
double i,
double j)
const;
239 inline unsigned int getWidth()
const {
return width; }
245 void init(
unsigned int height,
unsigned int width);
247 void init(
unsigned int height,
unsigned int width, Type value);
249 void init(Type *
const array,
const unsigned int height,
const unsigned int width,
const bool copyData =
false);
256 inline Type *
operator[](
const unsigned int i) {
return row[i]; }
260 inline const Type *
operator[](
unsigned int i)
const {
return row[i]; }
261 inline const Type *
operator[](
int i)
const {
return row[i]; }
270 inline Type
operator()(
const unsigned int i,
const unsigned int j)
const {
return bitmap[i * width + j]; }
276 inline void operator()(
const unsigned int i,
const unsigned int j,
const Type &v) { bitmap[i * width + j] = v; }
290 unsigned int i = (
unsigned int)ip.
get_i();
291 unsigned int j = (
unsigned int)ip.
get_j();
293 return bitmap[i * width + j];
306 unsigned int i = (
unsigned int)ip.
get_i();
307 unsigned int j = (
unsigned int)ip.
get_j();
309 bitmap[i * width + j] = v;
320 friend std::ostream &operator<< <>(std::ostream &s,
const vpImage<Type> &I);
321 friend std::ostream &operator<<(std::ostream &s, const vpImage<unsigned char> &I);
322 friend std::ostream &operator<<(std::ostream &s, const vpImage<char> &I);
323 friend std::ostream &operator<<(std::ostream &s, const vpImage<float> &I);
324 friend std::ostream &operator<<(std::ostream &s, const vpImage<double> &I);
327 void performLut(
const Type (&lut)[256],
const unsigned int nbThreads = 1);
333 void resize(
const unsigned int h,
const unsigned int w);
335 void resize(
const unsigned int h,
const unsigned int w,
const Type &val);
346 unsigned int npixels;
352 template <
class Type> std::ostream &operator<<(std::ostream &s, const vpImage<Type> &I)
358 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
359 for (
unsigned int j = 0; j < I.
getWidth() - 1; j++) {
367 if (i < I.getHeight() - 1) {
375 inline std::ostream &operator<<(std::ostream &s, const vpImage<unsigned char> &I)
381 std::ios_base::fmtflags original_flags = s.flags();
383 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
384 for (
unsigned int j = 0; j < I.
getWidth() - 1; j++) {
385 s << std::setw(3) << static_cast<unsigned>(I[i][j]) <<
" ";
389 s << std::setw(3) << static_cast<unsigned>(I[i][I.
getWidth() - 1]);
397 s.flags(original_flags);
401 inline std::ostream &operator<<(std::ostream &s, const vpImage<char> &I)
407 std::ios_base::fmtflags original_flags = s.flags();
409 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
410 for (
unsigned int j = 0; j < I.
getWidth() - 1; j++) {
411 s << std::setw(4) << static_cast<int>(I[i][j]) <<
" ";
415 s << std::setw(4) << static_cast<int>(I[i][I.
getWidth() - 1]);
423 s.flags(original_flags);
427 inline std::ostream &operator<<(std::ostream &s, const vpImage<float> &I)
433 std::ios_base::fmtflags original_flags = s.flags();
436 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
437 for (
unsigned int j = 0; j < I.
getWidth() - 1; j++) {
445 if (i < I.getHeight() - 1) {
450 s.flags(original_flags);
454 inline std::ostream &operator<<(std::ostream &s, const vpImage<double> &I)
460 std::ios_base::fmtflags original_flags = s.flags();
463 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
464 for (
unsigned int j = 0; j < I.
getWidth() - 1; j++) {
472 if (i < I.getHeight() - 1) {
477 s.flags(original_flags);
481 #if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0)) 484 struct ImageLut_Param_t {
485 unsigned int m_start_index;
486 unsigned int m_end_index;
488 unsigned char m_lut[256];
489 unsigned char *m_bitmap;
491 ImageLut_Param_t() : m_start_index(0), m_end_index(0), m_lut(), m_bitmap(NULL) {}
493 ImageLut_Param_t(
const unsigned int start_index,
const unsigned int end_index,
unsigned char *
bitmap)
494 : m_start_index(start_index), m_end_index(end_index), m_lut(), m_bitmap(bitmap)
501 ImageLut_Param_t *imageLut_param =
static_cast<ImageLut_Param_t *
>(args);
502 unsigned int start_index = imageLut_param->m_start_index;
503 unsigned int end_index = imageLut_param->m_end_index;
505 unsigned char *
bitmap = imageLut_param->m_bitmap;
507 unsigned char *ptrStart = bitmap + start_index;
508 unsigned char *ptrEnd = bitmap + end_index;
509 unsigned char *ptrCurrent = ptrStart;
516 if (end_index - start_index >= 8) {
518 for (; ptrCurrent <= ptrEnd - 8;) {
519 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
522 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
525 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
528 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
531 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
534 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
537 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
540 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
545 for (; ptrCurrent != ptrEnd; ++ptrCurrent) {
546 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
552 struct ImageLutRGBa_Param_t {
553 unsigned int m_start_index;
554 unsigned int m_end_index;
557 unsigned char *m_bitmap;
559 ImageLutRGBa_Param_t() : m_start_index(0), m_end_index(0), m_lut(), m_bitmap(NULL) {}
561 ImageLutRGBa_Param_t(
const unsigned int start_index,
const unsigned int end_index,
unsigned char *
bitmap)
562 : m_start_index(start_index), m_end_index(end_index), m_lut(), m_bitmap(bitmap)
569 ImageLutRGBa_Param_t *imageLut_param =
static_cast<ImageLutRGBa_Param_t *
>(args);
570 unsigned int start_index = imageLut_param->m_start_index;
571 unsigned int end_index = imageLut_param->m_end_index;
573 unsigned char *
bitmap = imageLut_param->m_bitmap;
575 unsigned char *ptrStart = bitmap + start_index * 4;
576 unsigned char *ptrEnd = bitmap + end_index * 4;
577 unsigned char *ptrCurrent = ptrStart;
579 if (end_index - start_index >= 4 * 2) {
581 for (; ptrCurrent <= ptrEnd - 4 * 2;) {
582 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].R;
584 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].G;
586 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].B;
588 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].A;
591 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].R;
593 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].G;
595 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].B;
597 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].A;
602 while (ptrCurrent != ptrEnd) {
603 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].R;
606 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].G;
609 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].B;
612 *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].A;
662 if (h != this->height) {
670 if ((h != this->height) || (w != this->width)) {
681 npixels = width * height;
684 bitmap =
new Type[npixels];
691 row =
new Type *[height];
696 for (
unsigned int i = 0; i < height; i++)
697 row[i] =
bitmap + i * width;
713 template <
class Type>
714 void vpImage<Type>::init(Type *
const array,
const unsigned int h,
const unsigned int w,
const bool copyData)
716 if (h != this->height) {
724 if ((copyData && ((h != this->height) || (w != this->width))) || !copyData) {
734 npixels = width * height;
738 bitmap =
new Type[npixels];
745 memcpy(static_cast<void*>(
bitmap), static_cast<void*>(array), (
size_t)(npixels *
sizeof(Type)));
752 row =
new Type *[height];
757 for (
unsigned int i = 0; i < height; i++) {
758 row[i] =
bitmap + i * width;
780 template <
class Type>
782 :
bitmap(NULL),
display(NULL), npixels(0), width(0), height(0), row(NULL)
804 template <
class Type>
806 :
bitmap(NULL),
display(NULL), npixels(0), width(0), height(0), row(NULL)
826 template <
class Type>
828 :
bitmap(NULL),
display(NULL), npixels(0), width(0), height(0), row(NULL)
830 init(array, h, w, copyData);
925 template <
class Type>
929 memcpy(static_cast<void*>(
bitmap), static_cast<void*>(I.
bitmap), I.npixels *
sizeof(Type));
932 #ifdef VISP_HAVE_CPP11_COMPATIBILITY 936 template <
class Type>
959 for (
unsigned int i = 0; i < npixels; i++) {
971 if ((height == 0) || (width == 0))
974 return getSum() / (height * width);
987 for (
unsigned int i = 0; i < npixels; i++)
1006 for (
unsigned int i = 0; i < npixels; i++) {
1035 template <
class Type>
1040 "values of an empty image"));
1044 for (
unsigned int i = 0; i < height; i++) {
1045 for (
unsigned int j = 0; j < width; j++) {
1046 if (row[i][j] < min) {
1051 if (row[i][j] > max) {
1095 for (
unsigned int i = 0; i < npixels; i++)
1115 for (
unsigned int i = 0; i < npixels; i++) {
1142 return !(*
this == I);
1190 int itl = (int)topLeft.
get_i();
1191 int jtl = (int)topLeft.
get_j();
1193 int dest_ibegin = 0;
1194 int dest_jbegin = 0;
1197 int dest_w = (int)this->
getWidth();
1204 if (itl >= dest_h || jtl >= dest_w)
1217 if (src_w - src_jbegin > dest_w - dest_jbegin)
1218 wsize = dest_w - dest_jbegin;
1220 wsize = src_w - src_jbegin;
1222 if (src_h - src_ibegin > dest_h - dest_ibegin)
1223 hsize = dest_h - dest_ibegin;
1225 hsize = src_h - src_ibegin;
1227 for (
int i = 0; i < hsize; i++) {
1228 Type *srcBitmap = src.
bitmap + ((src_ibegin + i) * src_w + src_jbegin);
1229 Type *destBitmap = this->
bitmap + ((dest_ibegin + i) * dest_w + dest_jbegin);
1231 memcpy(static_cast<void*>(destBitmap), static_cast<void*>(srcBitmap), (
size_t)wsize *
sizeof(Type));
1267 unsigned int h = height / 2;
1268 unsigned int w = width / 2;
1270 for (
unsigned int i = 0; i < h; i++)
1271 for (
unsigned int j = 0; j < w; j++)
1272 res[i][j] = (*
this)[i << 1][j << 1];
1292 template <
class Type>
1295 unsigned int h = height / v_scale;
1296 unsigned int w = width / h_scale;
1298 for (
unsigned int i = 0; i < h; i++)
1299 for (
unsigned int j = 0; j < w; j++)
1300 sampled[i][j] = (*
this)[i * v_scale][j * h_scale];
1329 unsigned int h = height / 4;
1330 unsigned int w = width / 4;
1332 for (
unsigned int i = 0; i < h; i++)
1333 for (
unsigned int j = 0; j < w; j++)
1334 res[i][j] = (*
this)[i << 2][j << 2];
1377 for (
int i = 0; i < h; i++)
1378 for (
int j = 0; j < w; j++)
1379 res[i][j] = (*
this)[i >> 1][j >> 1];
1390 for (
int i = 0; i < h; i += 2)
1391 for (
int j = 1; j < w - 1; j += 2)
1392 res[i][j] = (Type)(0.5 * ((*this)[i >> 1][j >> 1] + (*this)[i >> 1][(j >> 1) + 1]));
1395 for (
int i = 1; i < h - 1; i += 2)
1396 for (
int j = 0; j < w; j += 2)
1397 res[i][j] = (Type)(0.5 * ((*this)[i >> 1][j >> 1] + (*this)[(i >> 1) + 1][j >> 1]));
1400 for (
int i = 1; i < h - 1; i += 2)
1401 for (
int j = 1; j < w - 1; j += 2)
1402 res[i][j] = (Type)(0.25 * ((*this)[i >> 1][j >> 1] + (*this)[i >> 1][(j >> 1) + 1] +
1403 (*
this)[(i >> 1) + 1][j >> 1] + (*
this)[(i >> 1) + 1][(j >> 1) + 1]));
1422 if (i >= height || j >= width) {
1451 unsigned int iround, jround;
1452 double rfrac, cfrac;
1454 iround = (
unsigned int)floor(i);
1455 jround = (
unsigned int)floor(j);
1457 if (iround >= height || jround >= width) {
1462 i = (double)(height - 1);
1465 j = (double)(width - 1);
1467 double rratio = i - (double)iround;
1470 double cratio = j - (double)jround;
1474 rfrac = 1.0f - rratio;
1475 cfrac = 1.0f - cratio;
1477 double value = ((double)row[iround][jround] * rfrac + (
double)row[iround + 1][jround] * rratio) * cfrac +
1478 ((
double)row[iround][jround + 1] * rfrac + (double)row[iround + 1][jround + 1] * rratio) * cratio;
1503 unsigned int iround, jround;
1504 double rfrac, cfrac;
1506 iround = (
unsigned int)floor(i);
1507 jround = (
unsigned int)floor(j);
1509 if (iround >= height || jround >= width) {
1514 i = (double)(height - 1);
1517 j = (double)(width - 1);
1519 double rratio = i - (double)iround;
1522 double cratio = j - (double)jround;
1526 rfrac = 1.0f - rratio;
1527 cfrac = 1.0f - cratio;
1529 double value = ((double)row[iround][jround] * rfrac + (
double)row[iround + 1][jround] * rratio) * cfrac +
1530 ((
double)row[iround][jround + 1] * rfrac + (double)row[iround + 1][jround + 1] * rratio) * cratio;
1536 unsigned int iround, jround;
1537 double rfrac, cfrac;
1539 iround = (
unsigned int)floor(i);
1540 jround = (
unsigned int)floor(j);
1542 if (iround >= height || jround >= width) {
1547 i = (double)(height - 1);
1550 j = (double)(width - 1);
1552 double rratio = i - (double)iround;
1555 double cratio = j - (double)jround;
1559 rfrac = 1.0f - rratio;
1560 cfrac = 1.0f - cratio;
1562 double valueR = ((double)row[iround][jround].R * rfrac + (
double)row[iround + 1][jround].R * rratio) * cfrac +
1563 ((
double)row[iround][jround + 1].R * rfrac + (double)row[iround + 1][jround + 1].R * rratio) * cratio;
1564 double valueG = ((double)row[iround][jround].G * rfrac + (
double)row[iround + 1][jround].G * rratio) * cfrac +
1565 ((
double)row[iround][jround + 1].G * rfrac + (double)row[iround + 1][jround + 1].G * rratio) * cratio;
1566 double valueB = ((double)row[iround][jround].B * rfrac + (
double)row[iround + 1][jround].B * rratio) * cfrac +
1567 ((
double)row[iround][jround + 1].B * rfrac + (double)row[iround + 1][jround + 1].B * rratio) * cratio;
1593 unsigned int iround, jround;
1594 double rfrac, cfrac;
1596 iround = (
unsigned int)floor(ip.
get_i());
1597 jround = (
unsigned int)floor(ip.
get_j());
1599 if (iround >= height || jround >= width) {
1603 if (ip.
get_i() > height - 1)
1604 ip.
set_i((
double)(height - 1));
1606 if (ip.
get_j() > width - 1)
1607 ip.
set_j((
double)(width - 1));
1609 double rratio = ip.
get_i() - (double)iround;
1612 double cratio = ip.
get_j() - (double)jround;
1616 rfrac = 1.0f - rratio;
1617 cfrac = 1.0f - cratio;
1619 double value = ((double)row[iround][jround] * rfrac + (
double)row[iround + 1][jround] * rratio) * cfrac +
1620 ((
double)row[iround][jround + 1] * rfrac + (double)row[iround + 1][jround + 1] * rratio) * cratio;
1626 unsigned int iround, jround;
1627 double rfrac, cfrac;
1629 iround = (
unsigned int)floor(ip.
get_i());
1630 jround = (
unsigned int)floor(ip.
get_j());
1632 if (iround >= height || jround >= width) {
1636 if (ip.
get_i() > height - 1)
1637 ip.
set_i((
double)(height - 1));
1639 if (ip.
get_j() > width - 1)
1640 ip.
set_j((
double)(width - 1));
1642 double rratio = ip.
get_i() - (double)iround;
1645 double cratio = ip.
get_j() - (double)jround;
1649 rfrac = 1.0f - rratio;
1650 cfrac = 1.0f - cratio;
1652 double value = ((double)row[iround][jround] * rfrac + (
double)row[iround + 1][jround] * rratio) * cfrac +
1653 ((
double)row[iround][jround + 1] * rfrac + (double)row[iround + 1][jround + 1] * rratio) * cratio;
1659 unsigned int iround, jround;
1660 double rfrac, cfrac;
1662 iround = (
unsigned int)floor(ip.
get_i());
1663 jround = (
unsigned int)floor(ip.
get_j());
1665 if (iround >= height || jround >= width) {
1669 if (ip.
get_i() > height - 1)
1670 ip.
set_i((
double)(height - 1));
1672 if (ip.
get_j() > width - 1)
1673 ip.
set_j((
double)(width - 1));
1675 double rratio = ip.
get_i() - (double)iround;
1678 double cratio = ip.
get_j() - (double)jround;
1682 rfrac = 1.0f - rratio;
1683 cfrac = 1.0f - cratio;
1685 double valueR = ((double)row[iround][jround].R * rfrac + (
double)row[iround + 1][jround].R * rratio) * cfrac +
1686 ((
double)row[iround][jround + 1].R * rfrac + (double)row[iround + 1][jround + 1].R * rratio) * cratio;
1687 double valueG = ((double)row[iround][jround].G * rfrac + (
double)row[iround + 1][jround].G * rratio) * cfrac +
1688 ((
double)row[iround][jround + 1].G * rfrac + (double)row[iround + 1][jround + 1].G * rratio) * cratio;
1689 double valueB = ((double)row[iround][jround].B * rfrac + (
double)row[iround + 1][jround].B * rratio) * cfrac +
1690 ((
double)row[iround][jround + 1].B * rfrac + (double)row[iround + 1][jround + 1].B * rratio) * cratio;
1700 if ((height == 0) || (width == 0))
1704 for (
unsigned int i = 0; i < height * width; ++i) {
1705 res +=
static_cast<double>(
bitmap[i]);
1746 std::cout << me << std::endl;
1777 std::cout << me << std::endl;
1802 std::cerr <<
"Not implemented !" << std::endl;
1817 unsigned char *ptrStart = (
unsigned char *)
bitmap;
1818 unsigned char *ptrEnd = ptrStart + size;
1819 unsigned char *ptrCurrent = ptrStart;
1821 bool use_single_thread = (nbThreads == 0 || nbThreads == 1);
1822 #if !defined(VISP_HAVE_PTHREAD) && !defined(_WIN32) 1823 use_single_thread =
true;
1826 if (!use_single_thread &&
getSize() <= nbThreads) {
1827 use_single_thread =
true;
1830 if (use_single_thread) {
1833 while (ptrCurrent != ptrEnd) {
1834 *ptrCurrent = lut[*ptrCurrent];
1838 #if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0)) 1841 std::vector<vpThread *> threadpool;
1842 std::vector<ImageLut_Param_t *> imageLutParams;
1844 unsigned int image_size =
getSize();
1845 unsigned int step = image_size / nbThreads;
1846 unsigned int last_step = image_size - step * (nbThreads - 1);
1848 for (
unsigned int index = 0; index < nbThreads; index++) {
1849 unsigned int start_index = index * step;
1850 unsigned int end_index = (index + 1) * step;
1852 if (index == nbThreads - 1) {
1853 end_index = start_index + last_step;
1856 ImageLut_Param_t *imageLut_param =
new ImageLut_Param_t(start_index, end_index,
bitmap);
1857 memcpy(imageLut_param->m_lut, lut, 256 *
sizeof(
unsigned char));
1859 imageLutParams.push_back(imageLut_param);
1863 threadpool.push_back(imageLut_thread);
1866 for (
size_t cpt = 0; cpt < threadpool.size(); cpt++) {
1868 threadpool[cpt]->join();
1872 for (
size_t cpt = 0; cpt < threadpool.size(); cpt++) {
1873 delete threadpool[cpt];
1876 for (
size_t cpt = 0; cpt < imageLutParams.size(); cpt++) {
1877 delete imageLutParams[cpt];
1894 unsigned char *ptrStart = (
unsigned char *)
bitmap;
1895 unsigned char *ptrEnd = ptrStart + size * 4;
1896 unsigned char *ptrCurrent = ptrStart;
1898 bool use_single_thread = (nbThreads == 0 || nbThreads == 1);
1899 #if !defined(VISP_HAVE_PTHREAD) && !defined(_WIN32) 1900 use_single_thread =
true;
1903 if (!use_single_thread &&
getSize() <= nbThreads) {
1904 use_single_thread =
true;
1907 if (use_single_thread) {
1909 while (ptrCurrent != ptrEnd) {
1910 *ptrCurrent = lut[*ptrCurrent].R;
1913 *ptrCurrent = lut[*ptrCurrent].G;
1916 *ptrCurrent = lut[*ptrCurrent].B;
1919 *ptrCurrent = lut[*ptrCurrent].A;
1923 #if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0)) 1925 std::vector<vpThread *> threadpool;
1926 std::vector<ImageLutRGBa_Param_t *> imageLutParams;
1928 unsigned int image_size =
getSize();
1929 unsigned int step = image_size / nbThreads;
1930 unsigned int last_step = image_size - step * (nbThreads - 1);
1932 for (
unsigned int index = 0; index < nbThreads; index++) {
1933 unsigned int start_index = index * step;
1934 unsigned int end_index = (index + 1) * step;
1936 if (index == nbThreads - 1) {
1937 end_index = start_index + last_step;
1940 ImageLutRGBa_Param_t *imageLut_param =
new ImageLutRGBa_Param_t(start_index, end_index, (
unsigned char *)
bitmap);
1941 memcpy(imageLut_param->m_lut, lut, 256 *
sizeof(
vpRGBa));
1943 imageLutParams.push_back(imageLut_param);
1947 threadpool.push_back(imageLut_thread);
1950 for (
size_t cpt = 0; cpt < threadpool.size(); cpt++) {
1952 threadpool[cpt]->join();
1956 for (
size_t cpt = 0; cpt < threadpool.size(); cpt++) {
1957 delete threadpool[cpt];
1960 for (
size_t cpt = 0; cpt < imageLutParams.size(); cpt++) {
1961 delete imageLutParams[cpt];
1972 swap(first.npixels, second.npixels);
1973 swap(first.width, second.width);
1974 swap(first.height, second.height);
1975 swap(first.row, second.row);
void quarterSizeImage(vpImage< Type > &res) const
unsigned int getCols() const
void doubleSizeImage(vpImage< Type > &res)
Class that defines generic functionnalities for display.
unsigned int getWidth() const
void init(unsigned int height, unsigned int width)
Set the size of the image.
Type operator()(const unsigned int i, const unsigned int j) const
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
error that can be emited by ViSP classes.
Type getMinValue() const
Return the minimum value within the bitmap.
Type * operator[](const unsigned int i)
operator[] allows operation like I[i] = x.
virtual ~vpImage()
destructor
static int round(const double x)
vpImage< Type > & operator=(vpImage< Type > other)
Copy operator.
unsigned int getRows() const
void set_i(const double ii)
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 resize(const unsigned int h, const unsigned int w)
resize the image : Image initialization
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]
void set_j(const double jj)
void subsample(unsigned int v_scale, unsigned int h_scale, vpImage< Type > &sampled) const
void halfSizeImage(vpImage< Type > &res) const
Type * operator[](const int i)
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 ...
void operator()(const unsigned int i, const unsigned int j, const Type &v)
void performLut(const Type(&lut)[256], const unsigned int nbThreads=1)
Definition of the vpImage class member functions.
bool operator==(const vpImage< Type > &I)
void sub(const vpImage< Type > &B, vpImage< Type > &C)
void set_ij(const double ii, const double jj)