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>
116 template <
class Type>
class vpImage;
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]; }
257 inline Type *
operator[](
const 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);
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;
358 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
359 for (
unsigned int j = 0; j < I.
getWidth() - 1; j++) {
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);
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);
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++) {
450 s.flags(original_flags);
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++) {
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;
640 std::fill(bitmap, bitmap + npixels, value);
662 if (h != this->height) {
670 if ((h != this->height) || (w != this->width)) {
671 if (bitmap != NULL) {
681 npixels = width * height;
684 bitmap =
new Type[npixels];
686 if (bitmap == NULL) {
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) {
725 if (bitmap != NULL) {
734 npixels = width * height;
738 bitmap =
new Type[npixels];
740 if (bitmap == NULL) {
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>
827 vpImage<Type>::vpImage(Type *
const array,
const unsigned int h,
const unsigned int w,
const bool copyData)
828 : bitmap(NULL), display(NULL), npixels(0), width(0), height(0), row(NULL)
830 init(array, h, w, copyData);
842 template <
class Type>
vpImage<Type>::vpImage() : bitmap(NULL), display(NULL), npixels(0), width(0), height(0), row(NULL)
887 template <
class Type>
void vpImage<Type>::resize(
unsigned int h,
unsigned int w,
const Type &val) { init(h, w, val); }
899 if (bitmap != NULL) {
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>
938 : bitmap(I.bitmap), display(I.display), npixels(I.npixels), width(I.width), height(I.height), row(I.row)
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++)
1005 min = max = bitmap[0];
1006 for (
unsigned int i = 0; i < npixels; i++) {
1007 if (bitmap[i] < min)
1009 if (bitmap[i] > max)
1035 template <
class Type>
1040 "values of an empty image"));
1042 Type min = bitmap[0], max = bitmap[0];
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++) {
1116 if (bitmap[i] != I.
bitmap[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();
1198 int dest_h = (int)this->getHeight();
1199 int src_w = (int)src.getWidth();
1200 int src_h = (int)src.getHeight();
1201 int wsize = (int)src.getWidth();
1202 int hsize = (int)src.getHeight();
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]);
1744 C.
resize(this->getHeight(), this->getWidth());
1746 std::cout << me << std::endl;
1750 if ((this->getWidth() != B.
getWidth()) || (this->getHeight() != B.
getHeight())) {
1754 for (
unsigned int i = 0; i < this->getWidth() * this->getHeight(); i++) {
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);