Visual Servoing Platform  version 3.6.1 under development (2024-11-21)
vpImage.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See https://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Image handling.
32  */
33 
39 #ifndef VP_IMAGE_H
40 #define VP_IMAGE_H
41 
42 #include <visp3/core/vpConfig.h>
43 #include <visp3/core/vpEndian.h>
44 #include <visp3/core/vpException.h>
45 #include <visp3/core/vpImageException.h>
46 #include <visp3/core/vpImagePoint.h>
47 #include <visp3/core/vpRGBa.h>
48 #include <visp3/core/vpRGBf.h>
49 
50 #if defined(VISP_HAVE_THREADS)
51 #include <thread>
52 #endif
53 
54 #include <fstream>
55 #include <iomanip> // std::setw
56 #include <iostream>
57 #include <math.h>
58 #include <string.h>
59 
60 // Visual Studio 2010 or previous is missing inttypes.h
61 #if defined(_MSC_VER) && (_MSC_VER < 1700)
62 typedef long long int64_t;
63 typedef unsigned short uint16_t;
64 #else
65 #include <inttypes.h>
66 #endif
67 
68 BEGIN_VISP_NAMESPACE
69 class vpDisplay;
70 // Ref: http://en.cppreference.com/w/cpp/language/friend#Template_friends
71 template <class Type> class vpImage; // forward declare to make function declaration possible
72 
73 // declarations
74 template <class Type> std::ostream &operator<<(std::ostream &s, const vpImage<Type> &I);
75 
76 std::ostream &operator<<(std::ostream &s, const vpImage<unsigned char> &I);
77 std::ostream &operator<<(std::ostream &s, const vpImage<char> &I);
78 std::ostream &operator<<(std::ostream &s, const vpImage<float> &I);
79 std::ostream &operator<<(std::ostream &s, const vpImage<double> &I);
80 
130 template <class Type> class vpImage
131 {
132  friend class vpImageConvert;
133 
134 public:
135  Type *bitmap;
137 
141  vpImage(const vpImage<Type> &img);
142 #if ((__cplusplus >= 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L))) // Check if cxx11 or higher
144  vpImage(vpImage<Type> &&img);
145 #endif
147  vpImage(unsigned int height, unsigned int width);
149  vpImage(unsigned int height, unsigned int width, Type value);
151  vpImage(Type *const array, unsigned int height, unsigned int width, bool copyData = false);
153  virtual ~vpImage();
154 
157 
158  // destructor
159  void destroy();
160 
161  // Returns a new image that's double size of the current image
163 
171  inline unsigned int getCols() const { return width; }
172 
181  inline unsigned int getHeight() const { return height; }
182 
183  // Return the maximum value within the bitmap
184  Type getMaxValue(bool onlyFiniteVal = true) const;
185  // Return the mean value of the bitmap
186  double getMeanValue(const vpImage<bool> *p_mask = nullptr, unsigned int *nbValidPoints = nullptr) const;
187 
188  // Return the minumum value within the bitmap
189  Type getMinValue(bool onlyFiniteVal = true) const;
190  // Look for the minumum and the maximum value within the bitmap
191  void getMinMaxValue(Type &min, Type &max, bool onlyFiniteVal = true) const;
192  // Look for the minumum and the maximum value within the bitmap and get their location
193  void getMinMaxLoc(vpImagePoint *minLoc, vpImagePoint *maxLoc, Type *minVal = nullptr, Type *maxVal = nullptr) const;
194 
203  inline unsigned int getNumberOfPixel() const { return npixels; }
204 
212  inline unsigned int getRows() const { return height; }
213 
221  inline unsigned int getSize() const { return width * height; }
222 
223  double getStdev(const vpImage<bool> *p_mask = nullptr, unsigned int *nbValidPoints = nullptr) const;
224  double getStdev(const double &mean, const vpImage<bool> *p_mask = nullptr, unsigned int *nbValidPoints = nullptr) const;
225 
226  double getSum(const vpImage<bool> *p_mask = nullptr, unsigned int *nbValidPoints = nullptr) const;
227 
228  // Gets the value of a pixel at a location.
229  Type getValue(unsigned int i, unsigned int j) const;
230  // Gets the value of a pixel at a location with bilinear interpolation.
231  Type getValue(double i, double j) const;
232  // Gets the value of a pixel at a location with bilinear interpolation.
233  Type getValue(const vpImagePoint &ip) const;
234 
242  inline unsigned int getWidth() const { return width; }
243 
244  // Returns a new image that's half size of the current image
245  void halfSizeImage(vpImage<Type> &res) const;
246 
248  void init(unsigned int height, unsigned int width);
250  void init(unsigned int height, unsigned int width, Type value);
252  void init(Type *const array, unsigned int height, unsigned int width, bool copyData = false);
253  void insert(const vpImage<Type> &src, const vpImagePoint &topLeft);
254 
255  //------------------------------------------------------------------
256  // Access to the image
257 
259  inline Type *operator[](unsigned int i) { return row[i]; }
260  inline Type *operator[](int i) { return row[i]; }
261 
263  inline const Type *operator[](unsigned int i) const { return row[i]; }
264  inline const Type *operator[](int i) const { return row[i]; }
265 
272  inline Type operator()(unsigned int i, unsigned int j) const { return bitmap[(i * width) + j]; }
273 
278  inline void operator()(unsigned int i, unsigned int j, const Type &v) { bitmap[(i * width) + j] = v; }
279 
290  inline Type operator()(const vpImagePoint &ip) const
291  {
292  unsigned int i = static_cast<unsigned int>(ip.get_i());
293  unsigned int j = static_cast<unsigned int>(ip.get_j());
294 
295  return bitmap[(i * width) + j];
296  }
297 
306  inline void operator()(const vpImagePoint &ip, const Type &v)
307  {
308  unsigned int i = static_cast<unsigned int>(ip.get_i());
309  unsigned int j = static_cast<unsigned int>(ip.get_j());
310 
311  bitmap[(i * width) + j] = v;
312  }
313 
314  vpImage<Type> operator-(const vpImage<Type> &B) const;
315 
317  vpImage<Type> &operator=(const vpImage<Type> &other);
318 #if ((__cplusplus >= 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L))) // Check if cxx11 or higher
320  vpImage<Type> &operator=(vpImage<Type> &&other);
321 #endif
322 
323  vpImage<Type> &operator=(const Type &v);
324  bool operator==(const vpImage<Type> &I) const;
325  bool operator!=(const vpImage<Type> &I) const;
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);
331 
332  // Perform a look-up table transformation
333  void performLut(const Type(&lut)[256], unsigned int nbThreads = 1);
334 
335  // Returns a new image that's a quarter size of the current image
336  void quarterSizeImage(vpImage<Type> &res) const;
337 
338  // set the size of the image without initializing it.
339  void resize(unsigned int h, unsigned int w);
340  // set the size of the image and initialize it.
341  void resize(unsigned int h, unsigned int w, const Type &val);
342 
343  void sub(const vpImage<Type> &B, vpImage<Type> &C) const;
344  void sub(const vpImage<Type> &A, const vpImage<Type> &B, vpImage<Type> &C) const;
345  void subsample(unsigned int v_scale, unsigned int h_scale, vpImage<Type> &sampled) const;
346 
347  // See https://stackoverflow.com/questions/11562/how-to-overload-stdswap to understand why swap is in visp namespace
348  friend void swap(vpImage<Type> &first, vpImage<Type> &second)
349  {
350  using std::swap;
351  swap(first.bitmap, second.bitmap);
352  swap(first.display, second.display);
353  swap(first.npixels, second.npixels);
354  swap(first.width, second.width);
355  swap(first.height, second.height);
356  swap(first.row, second.row);
357  }
358 
360 
361 private:
362  unsigned int npixels;
363  unsigned int width;
364  unsigned int height;
365  Type **row;
366  bool hasOwnership;
367 };
368 
369 #include <visp3/core/vpImage_operators.h>
370 #include <visp3/core/vpImage_lut.h>
371 #include <visp3/core/vpImage_getters.h>
372 
376 template <class Type> void vpImage<Type>::init(unsigned int h, unsigned int w, Type value)
377 {
378  init(h, w);
379  std::fill(bitmap, bitmap + npixels, value);
380 }
381 
385 template <class Type> void vpImage<Type>::init(unsigned int h, unsigned int w)
386 {
387  if (h != this->height) {
388  if (row != nullptr) {
389  delete[] row;
390  row = nullptr;
391  }
392  }
393 
394  if ((h != this->height) || (w != this->width)) {
395  if (bitmap != nullptr) {
396  if (hasOwnership) {
397  delete[] bitmap;
398  }
399  bitmap = nullptr;
400  }
401  }
402 
403  this->width = w;
404  this->height = h;
405 
406  npixels = width * height;
407 
408  if (bitmap == nullptr) {
409  bitmap = new Type[npixels];
410  hasOwnership = true;
411  }
412  if (bitmap == nullptr) {
413  throw(vpException(vpException::memoryAllocationError, "cannot allocate bitmap "));
414  }
415  if (row == nullptr) {
416  row = new Type *[height];
417  }
418  if (row == nullptr) {
419  throw(vpException(vpException::memoryAllocationError, "cannot allocate row "));
420  }
421 
422  for (unsigned int i = 0; i < height; ++i) {
423  row[i] = bitmap + (i * width);
424  }
425 }
426 
430 template <class Type> void vpImage<Type>::init(Type *const array, unsigned int h, unsigned int w, bool copyData)
431 {
432  if (h != this->height) {
433  if (row != nullptr) {
434  delete[] row;
435  row = nullptr;
436  }
437  }
438 
439  // Delete bitmap if copyData==false, otherwise only if the dimension differs
440  if ((copyData && ((h != this->height) || (w != this->width))) || (!copyData)) {
441  if (bitmap != nullptr) {
442  if (hasOwnership) {
443  delete[] bitmap;
444  }
445  bitmap = nullptr;
446  }
447  }
448 
449  hasOwnership = copyData;
450  this->width = w;
451  this->height = h;
452 
453  npixels = width * height;
454 
455  if (copyData) {
456  if (bitmap == nullptr) {
457  bitmap = new Type[npixels];
458  }
459 
460  if (bitmap == nullptr) {
461  throw(vpException(vpException::memoryAllocationError, "cannot allocate bitmap "));
462  }
463 
464  // Copy the image data
465  memcpy(static_cast<void *>(bitmap), static_cast<void *>(array), static_cast<size_t>(npixels * sizeof(Type)));
466  }
467  else {
468  // Copy the address of the array in the bitmap
469  bitmap = array;
470  }
471 
472  if (row == nullptr) {
473  row = new Type *[height];
474  }
475  if (row == nullptr) {
476  throw(vpException(vpException::memoryAllocationError, "cannot allocate row "));
477  }
478 
479  for (unsigned int i = 0; i < height; ++i) {
480  row[i] = bitmap + (i * width);
481  }
482 }
483 
487 template <class Type>
488 vpImage<Type>::vpImage(unsigned int h, unsigned int w)
489  : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
490 {
491  Type val(0);
492  init(h, w, val);
493 }
494 
498 template <class Type>
499 vpImage<Type>::vpImage(unsigned int h, unsigned int w, Type value)
500  : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
501 {
502  init(h, w, value);
503 }
504 
508 template <class Type>
509 vpImage<Type>::vpImage(Type *const array, unsigned int h, unsigned int w, bool copyData)
510  : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
511 {
512  init(array, h, w, copyData);
513 }
514 
518 template <class Type>
519 vpImage<Type>::vpImage() : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
520 { }
521 
542 template <class Type> void vpImage<Type>::resize(unsigned int h, unsigned int w) { init(h, w); }
543 
563 template <class Type> void vpImage<Type>::resize(unsigned int h, unsigned int w, const Type &val) { init(h, w, val); }
564 
571 template <class Type> void vpImage<Type>::destroy()
572 {
573  if (bitmap != nullptr) {
574  if (hasOwnership) {
575  delete[] bitmap;
576  }
577  bitmap = nullptr;
578  }
579 
580  if (row != nullptr) {
581  delete[] row;
582  row = nullptr;
583  }
584 }
585 
592 template <class Type> vpImage<Type>::~vpImage() { destroy(); }
593 
597 template <class Type>
599  : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
600 {
601  resize(I.getHeight(), I.getWidth());
602  if (bitmap) {
603  memcpy(static_cast<void *>(bitmap), static_cast<void *>(I.bitmap), I.npixels * sizeof(Type));
604  }
605 }
606 
607 #if ((__cplusplus >= 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L))) // Check if cxx11 or higher
611 template <class Type>
613  : bitmap(I.bitmap), display(I.display), npixels(I.npixels), width(I.width), height(I.height), row(I.row),
614  hasOwnership(I.hasOwnership)
615 {
616  I.bitmap = nullptr;
617  I.display = nullptr;
618  I.npixels = 0;
619  I.width = 0;
620  I.height = 0;
621  I.row = nullptr;
622  I.hasOwnership = false;
623 }
624 #endif
625 
637 template <class Type> void vpImage<Type>::insert(const vpImage<Type> &src, const vpImagePoint &topLeft)
638 {
639  int itl = static_cast<int>(topLeft.get_i());
640  int jtl = static_cast<int>(topLeft.get_j());
641 
642  int dest_ibegin = 0;
643  int dest_jbegin = 0;
644  int src_ibegin = 0;
645  int src_jbegin = 0;
646  int dest_w = static_cast<int>(this->getWidth());
647  int dest_h = static_cast<int>(this->getHeight());
648  int src_w = static_cast<int>(src.getWidth());
649  int src_h = static_cast<int>(src.getHeight());
650  int wsize = static_cast<int>(src.getWidth());
651  int hsize = static_cast<int>(src.getHeight());
652 
653  if ((itl >= dest_h) || (jtl >= dest_w)) {
654  return;
655  }
656 
657  if (itl < 0) {
658  src_ibegin = -itl;
659  }
660  else {
661  dest_ibegin = itl;
662  }
663 
664  if (jtl < 0) {
665  src_jbegin = -jtl;
666  }
667  else {
668  dest_jbegin = jtl;
669  }
670 
671  if ((src_w - src_jbegin) >(dest_w - dest_jbegin)) {
672  wsize = dest_w - dest_jbegin;
673  }
674  else {
675  wsize = src_w - src_jbegin;
676  }
677 
678  if ((src_h - src_ibegin) > (dest_h - dest_ibegin)) {
679  hsize = dest_h - dest_ibegin;
680  }
681  else {
682  hsize = src_h - src_ibegin;
683  }
684 
685  for (int i = 0; i < hsize; ++i) {
686  Type *srcBitmap = src.bitmap + (((src_ibegin + i) * src_w) + src_jbegin);
687  Type *destBitmap = this->bitmap + (((dest_ibegin + i) * dest_w) + dest_jbegin);
688 
689  memcpy(static_cast<void *>(destBitmap), static_cast<void *>(srcBitmap), static_cast<size_t>(wsize) * sizeof(Type));
690  }
691 }
692 
723 template <class Type> void vpImage<Type>::halfSizeImage(vpImage<Type> &res) const
724 {
725  unsigned int h = height / 2;
726  unsigned int w = width / 2;
727  res.resize(h, w);
728  for (unsigned int i = 0; i < h; ++i) {
729  for (unsigned int j = 0; j < w; ++j) {
730  res[i][j] = (*this)[i << 1][j << 1];
731  }
732  }
733 }
734 
752 template <class Type>
753 void vpImage<Type>::subsample(unsigned int v_scale, unsigned int h_scale, vpImage<Type> &sampled) const
754 {
755  if ((v_scale == 1) && (h_scale == 1)) {
756  sampled = *this;
757  return;
758  }
759  unsigned int h = height / v_scale;
760  unsigned int w = width / h_scale;
761  sampled.resize(h, w);
762  for (unsigned int i = 0; i < h; ++i) {
763  for (unsigned int j = 0; j < w; ++j) {
764  sampled[i][j] = (*this)[i * v_scale][j * h_scale];
765  }
766  }
767 }
768 
791 template <class Type> void vpImage<Type>::quarterSizeImage(vpImage<Type> &res) const
792 {
793  unsigned int h = height / 4;
794  unsigned int w = width / 4;
795  const unsigned int magic_2 = 2;
796  res.resize(h, w);
797  for (unsigned int i = 0; i < h; ++i) {
798  for (unsigned int j = 0; j < w; ++j) {
799  res[i][j] = (*this)[i << magic_2][j << magic_2];
800  }
801  }
802 }
803 
835 template <class Type> void vpImage<Type>::doubleSizeImage(vpImage<Type> &res)
836 {
837  const unsigned int magic_2 = 2;
838  unsigned int h = height * magic_2;
839  unsigned int w = width * magic_2;
840 
841  res.resize(h, w);
842 
843  for (unsigned int i = 0; i < h; ++i) {
844  for (unsigned int j = 0; j < w; ++j) {
845  res[i][j] = (*this)[i >> 1][j >> 1];
846  }
847  }
848 
849  /*
850  A B C
851  E F G
852  H I J
853  A C H J are pixels from original image
854  B E G I are interpolated pixels
855  */
856 
857  // interpolate pixels B and I
858  for (unsigned int i = 0; i < h; i += magic_2) {
859  for (unsigned int j = 1; j < (w - 1); j += magic_2) {
860  res[i][j] = static_cast<Type>(0.5 * ((*this)[i >> 1][j >> 1] + (*this)[i >> 1][(j >> 1) + 1]));
861  }
862  }
863 
864  // interpolate pixels E and G
865  for (unsigned int i = 1; i < (h - 1); i += magic_2) {
866  for (unsigned int j = 0; j < w; j += magic_2) {
867  res[i][j] = static_cast<Type>(0.5 * ((*this)[i >> 1][j >> 1] + (*this)[(i >> 1) + 1][j >> 1]));
868  }
869  }
870 
871  // interpolate pixel F
872  for (unsigned int i = 1; i < (h - 1); i += magic_2) {
873  for (unsigned int j = 1; j < (w - 1); j += magic_2) {
874  res[i][j] = static_cast<Type>(0.25 * ((*this)[i >> 1][j >> 1] + (*this)[i >> 1][(j >> 1) + 1] +
875  (*this)[(i >> 1) + 1][j >> 1] + (*this)[(i >> 1) + 1][(j >> 1) + 1]));
876  }
877  }
878 }
879 
913 template <class Type> void vpImage<Type>::sub(const vpImage<Type> &B, vpImage<Type> &C) const
914 {
915 
916  try {
917  if ((this->getHeight() != C.getHeight()) || (this->getWidth() != C.getWidth())) {
918  C.resize(this->getHeight(), this->getWidth());
919  }
920  }
921  catch (const vpException &me) {
922  std::cout << me << std::endl;
923  throw;
924  }
925 
926  if ((this->getWidth() != B.getWidth()) || (this->getHeight() != B.getHeight())) {
927  throw(vpException(vpException::memoryAllocationError, "vpImage mismatch in vpImage/vpImage subtraction"));
928  }
929 
930  unsigned int this_width = this->getWidth();
931  unsigned int this_height = this->getHeight();
932  for (unsigned int i = 0; i < (this_width * this_height); ++i) {
933  *(C.bitmap + i) = *(bitmap + i) - *(B.bitmap + i);
934  }
935 }
936 
948 template <class Type> void vpImage<Type>::sub(const vpImage<Type> &A, const vpImage<Type> &B, vpImage<Type> &C) const
949 {
950 
951  try {
952  if ((A.getHeight() != C.getHeight()) || (A.getWidth() != C.getWidth())) {
953  C.resize(A.getHeight(), A.getWidth());
954  }
955  }
956  catch (const vpException &me) {
957  std::cout << me << std::endl;
958  throw;
959  }
960 
961  if ((A.getWidth() != B.getWidth()) || (A.getHeight() != B.getHeight())) {
962  throw(vpException(vpException::memoryAllocationError, "vpImage mismatch in vpImage/vpImage subtraction "));
963  }
964 
965  unsigned int a_width = A.getWidth();
966  unsigned int a_height = A.getHeight();
967  for (unsigned int i = 0; i < (a_width * a_height); ++i) {
968  *(C.bitmap + i) = *(A.bitmap + i) - *(B.bitmap + i);
969  }
970 }
971 
972 END_VISP_NAMESPACE
973 #endif
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Definition: vpArray2D.h:614
Class that defines generic functionalities for display.
Definition: vpDisplay.h:178
error that can be emitted by ViSP classes.
Definition: vpException.h:60
@ memoryAllocationError
Memory allocation error.
Definition: vpException.h:64
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:82
double get_j() const
Definition: vpImagePoint.h:125
double get_i() const
Definition: vpImagePoint.h:114
Definition of the vpImage class member functions.
Definition: vpImage.h:131
Type operator()(const vpImagePoint &ip) const
Definition: vpImage.h:290
void destroy()
Destructor : Memory de-allocation.
Definition: vpImage.h:571
void subsample(unsigned int v_scale, unsigned int h_scale, vpImage< Type > &sampled) const
Definition: vpImage.h:753
void halfSizeImage(vpImage< Type > &res) const
Definition: vpImage.h:723
Type * operator[](int i)
Definition: vpImage.h:260
double getSum(const vpImage< bool > *p_mask=nullptr, unsigned int *nbValidPoints=nullptr) const
Compute the sum of image intensities.
Type getMinValue(bool onlyFiniteVal=true) const
Return the minimum value within the bitmap.
vpImage< Type > & operator=(const vpImage< Type > &other)
Copy operator.
void quarterSizeImage(vpImage< Type > &res) const
Definition: vpImage.h:791
void getMinMaxLoc(vpImagePoint *minLoc, vpImagePoint *maxLoc, Type *minVal=nullptr, Type *maxVal=nullptr) const
Get the position of the minimum and/or the maximum pixel value within the bitmap and the correspondin...
void init(unsigned int height, unsigned int width)
Set the size of the image.
Definition: vpImage.h:385
Type * operator[](unsigned int i)
operator[] allows operation like I[i] = x.
Definition: vpImage.h:259
void resize(unsigned int h, unsigned int w, const Type &val)
resize the image : Image initialization
Definition: vpImage.h:563
unsigned int getWidth() const
Definition: vpImage.h:242
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
Definition: vpImage.h:542
unsigned int getNumberOfPixel() const
Definition: vpImage.h:203
void doubleSizeImage(vpImage< Type > &res)
Definition: vpImage.h:835
vpImage(unsigned int height, unsigned int width, Type value)
constructor set the size of the image and init all the pixel
Definition: vpImage.h:499
void performLut(const Type(&lut)[256], unsigned int nbThreads=1)
Definition: vpImage_lut.h:176
friend std::ostream & operator<<(std::ostream &s, const vpImage< Type > &I)
const Type * operator[](int i) const
Definition: vpImage.h:264
bool operator==(const vpImage< Type > &I) const
void insert(const vpImage< Type > &src, const vpImagePoint &topLeft)
Definition: vpImage.h:637
void sub(const vpImage< Type > &A, const vpImage< Type > &B, vpImage< Type > &C) const
Definition: vpImage.h:948
Type getValue(unsigned int i, unsigned int j) const
vpImage< Type > operator-(const vpImage< Type > &B) const
void init(unsigned int height, unsigned int width, Type value)
Set the size of the image and initialize all the elements to 'value'.
Definition: vpImage.h:376
unsigned int getSize() const
Definition: vpImage.h:221
vpImage(const vpImage< Type > &img)
copy constructor
Definition: vpImage.h:598
friend void swap(vpImage< Type > &first, vpImage< Type > &second)
Definition: vpImage.h:348
unsigned int getCols() const
Definition: vpImage.h:171
Type * bitmap
points toward the bitmap
Definition: vpImage.h:135
const Type * operator[](unsigned int i) const
operator[] allows operation like x = I[i]
Definition: vpImage.h:263
double getStdev(const vpImage< bool > *p_mask=nullptr, unsigned int *nbValidPoints=nullptr) const
Return the standard deviation of the bitmap.
void sub(const vpImage< Type > &B, vpImage< Type > &C) const
Definition: vpImage.h:913
vpImage(Type *const array, unsigned int height, unsigned int width, bool copyData=false)
constructor from an image stored as a continuous array in memory
Definition: vpImage.h:509
void init(Type *const array, unsigned int height, unsigned int width, bool copyData=false)
Initialization from an image stored as a continuous array in memory.
Definition: vpImage.h:430
Type getMaxValue(bool onlyFiniteVal=true) const
Return the maximum value within the bitmap.
virtual ~vpImage()
destructor
Definition: vpImage.h:592
unsigned int getHeight() const
Definition: vpImage.h:181
unsigned int getRows() const
Definition: vpImage.h:212
void getMinMaxValue(Type &min, Type &max, bool onlyFiniteVal=true) const
Look for the minimum and the maximum value within the bitmap.
vpDisplay * display
Definition: vpImage.h:136
vpImage()
constructor
Definition: vpImage.h:519
void operator()(const vpImagePoint &ip, const Type &v)
Definition: vpImage.h:306
Type operator()(unsigned int i, unsigned int j) const
Definition: vpImage.h:272
bool operator!=(const vpImage< Type > &I) const
double getMeanValue(const vpImage< bool > *p_mask=nullptr, unsigned int *nbValidPoints=nullptr) const
Return the mean value of the bitmap.
void init(unsigned int h, unsigned int w, Type value)
Definition: vpImage.h:376
vpImage(unsigned int height, unsigned int width)
constructor set the size of the image
Definition: vpImage.h:488
void operator()(unsigned int i, unsigned int j, const Type &v)
Definition: vpImage.h:278