Visual Servoing Platform  version 3.6.1 under development (2024-07-18)
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 
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 
318 
319  vpImage<Type> &operator=(const Type &v);
320  bool operator==(const vpImage<Type> &I) const;
321  bool operator!=(const vpImage<Type> &I) const;
322  friend std::ostream &operator<< <>(std::ostream &s, const vpImage<Type> &I);
323  friend std::ostream &operator<<(std::ostream &s, const vpImage<unsigned char> &I);
324  friend std::ostream &operator<<(std::ostream &s, const vpImage<char> &I);
325  friend std::ostream &operator<<(std::ostream &s, const vpImage<float> &I);
326  friend std::ostream &operator<<(std::ostream &s, const vpImage<double> &I);
327 
328  // Perform a look-up table transformation
329  void performLut(const Type(&lut)[256], unsigned int nbThreads = 1);
330 
331  // Returns a new image that's a quarter size of the current image
332  void quarterSizeImage(vpImage<Type> &res) const;
333 
334  // set the size of the image without initializing it.
335  void resize(unsigned int h, unsigned int w);
336  // set the size of the image and initialize it.
337  void resize(unsigned int h, unsigned int w, const Type &val);
338 
339  void sub(const vpImage<Type> &B, vpImage<Type> &C) const;
340  void sub(const vpImage<Type> &A, const vpImage<Type> &B, vpImage<Type> &C) const;
341  void subsample(unsigned int v_scale, unsigned int h_scale, vpImage<Type> &sampled) const;
342 
343  // See https://stackoverflow.com/questions/11562/how-to-overload-stdswap to understand why swap is in visp namespace
344  friend void swap(vpImage<Type> &first, vpImage<Type> &second)
345  {
346  using std::swap;
347  swap(first.bitmap, second.bitmap);
348  swap(first.display, second.display);
349  swap(first.npixels, second.npixels);
350  swap(first.width, second.width);
351  swap(first.height, second.height);
352  swap(first.row, second.row);
353  }
354 
356 
357 private:
358  unsigned int npixels;
359  unsigned int width;
360  unsigned int height;
361  Type **row;
362  bool hasOwnership;
363 };
364 
365 #include <visp3/core/vpImage_operators.h>
366 #include <visp3/core/vpImage_lut.h>
367 #include <visp3/core/vpImage_getters.h>
368 
372 template <class Type> void vpImage<Type>::init(unsigned int h, unsigned int w, Type value)
373 {
374  init(h, w);
375  std::fill(bitmap, bitmap + npixels, value);
376 }
377 
381 template <class Type> void vpImage<Type>::init(unsigned int h, unsigned int w)
382 {
383  if (h != this->height) {
384  if (row != nullptr) {
385  delete[] row;
386  row = nullptr;
387  }
388  }
389 
390  if ((h != this->height) || (w != this->width)) {
391  if (bitmap != nullptr) {
392  if (hasOwnership) {
393  delete[] bitmap;
394  }
395  bitmap = nullptr;
396  }
397  }
398 
399  this->width = w;
400  this->height = h;
401 
402  npixels = width * height;
403 
404  if (bitmap == nullptr) {
405  bitmap = new Type[npixels];
406  hasOwnership = true;
407  }
408  if (bitmap == nullptr) {
409  throw(vpException(vpException::memoryAllocationError, "cannot allocate bitmap "));
410  }
411  if (row == nullptr) {
412  row = new Type *[height];
413  }
414  if (row == nullptr) {
415  throw(vpException(vpException::memoryAllocationError, "cannot allocate row "));
416  }
417 
418  for (unsigned int i = 0; i < height; ++i) {
419  row[i] = bitmap + (i * width);
420  }
421 }
422 
426 template <class Type> void vpImage<Type>::init(Type *const array, unsigned int h, unsigned int w, bool copyData)
427 {
428  if (h != this->height) {
429  if (row != nullptr) {
430  delete[] row;
431  row = nullptr;
432  }
433  }
434 
435  // Delete bitmap if copyData==false, otherwise only if the dimension differs
436  if ((copyData && ((h != this->height) || (w != this->width))) || (!copyData)) {
437  if (bitmap != nullptr) {
438  if (hasOwnership) {
439  delete[] bitmap;
440  }
441  bitmap = nullptr;
442  }
443  }
444 
445  hasOwnership = copyData;
446  this->width = w;
447  this->height = h;
448 
449  npixels = width * height;
450 
451  if (copyData) {
452  if (bitmap == nullptr) {
453  bitmap = new Type[npixels];
454  }
455 
456  if (bitmap == nullptr) {
457  throw(vpException(vpException::memoryAllocationError, "cannot allocate bitmap "));
458  }
459 
460  // Copy the image data
461  memcpy(static_cast<void *>(bitmap), static_cast<void *>(array), static_cast<size_t>(npixels * sizeof(Type)));
462  }
463  else {
464  // Copy the address of the array in the bitmap
465  bitmap = array;
466  }
467 
468  if (row == nullptr) {
469  row = new Type *[height];
470  }
471  if (row == nullptr) {
472  throw(vpException(vpException::memoryAllocationError, "cannot allocate row "));
473  }
474 
475  for (unsigned int i = 0; i < height; ++i) {
476  row[i] = bitmap + (i * width);
477  }
478 }
479 
483 template <class Type>
484 vpImage<Type>::vpImage(unsigned int h, unsigned int w)
485  : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
486 {
487  Type val(0);
488  init(h, w, val);
489 }
490 
494 template <class Type>
495 vpImage<Type>::vpImage(unsigned int h, unsigned int w, Type value)
496  : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
497 {
498  init(h, w, value);
499 }
500 
504 template <class Type>
505 vpImage<Type>::vpImage(Type *const array, unsigned int h, unsigned int w, bool copyData)
506  : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
507 {
508  init(array, h, w, copyData);
509 }
510 
514 template <class Type>
515 vpImage<Type>::vpImage() : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
516 { }
517 
538 template <class Type> void vpImage<Type>::resize(unsigned int h, unsigned int w) { init(h, w); }
539 
559 template <class Type> void vpImage<Type>::resize(unsigned int h, unsigned int w, const Type &val) { init(h, w, val); }
560 
567 template <class Type> void vpImage<Type>::destroy()
568 {
569  if (bitmap != nullptr) {
570  if (hasOwnership) {
571  delete[] bitmap;
572  }
573  bitmap = nullptr;
574  }
575 
576  if (row != nullptr) {
577  delete[] row;
578  row = nullptr;
579  }
580 }
581 
588 template <class Type> vpImage<Type>::~vpImage() { destroy(); }
589 
593 template <class Type>
595  : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
596 {
597  resize(I.getHeight(), I.getWidth());
598  if (bitmap) {
599  memcpy(static_cast<void *>(bitmap), static_cast<void *>(I.bitmap), I.npixels * sizeof(Type));
600  }
601 }
602 
603 #if ((__cplusplus >= 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L))) // Check if cxx11 or higher
607 template <class Type>
609  : bitmap(I.bitmap), display(I.display), npixels(I.npixels), width(I.width), height(I.height), row(I.row),
610  hasOwnership(I.hasOwnership)
611 {
612  I.bitmap = nullptr;
613  I.display = nullptr;
614  I.npixels = 0;
615  I.width = 0;
616  I.height = 0;
617  I.row = nullptr;
618  I.hasOwnership = false;
619 }
620 #endif
621 
633 template <class Type> void vpImage<Type>::insert(const vpImage<Type> &src, const vpImagePoint &topLeft)
634 {
635  int itl = static_cast<int>(topLeft.get_i());
636  int jtl = static_cast<int>(topLeft.get_j());
637 
638  int dest_ibegin = 0;
639  int dest_jbegin = 0;
640  int src_ibegin = 0;
641  int src_jbegin = 0;
642  int dest_w = static_cast<int>(this->getWidth());
643  int dest_h = static_cast<int>(this->getHeight());
644  int src_w = static_cast<int>(src.getWidth());
645  int src_h = static_cast<int>(src.getHeight());
646  int wsize = static_cast<int>(src.getWidth());
647  int hsize = static_cast<int>(src.getHeight());
648 
649  if ((itl >= dest_h) || (jtl >= dest_w)) {
650  return;
651  }
652 
653  if (itl < 0) {
654  src_ibegin = -itl;
655  }
656  else {
657  dest_ibegin = itl;
658  }
659 
660  if (jtl < 0) {
661  src_jbegin = -jtl;
662  }
663  else {
664  dest_jbegin = jtl;
665  }
666 
667  if ((src_w - src_jbegin) >(dest_w - dest_jbegin)) {
668  wsize = dest_w - dest_jbegin;
669  }
670  else {
671  wsize = src_w - src_jbegin;
672  }
673 
674  if ((src_h - src_ibegin) > (dest_h - dest_ibegin)) {
675  hsize = dest_h - dest_ibegin;
676  }
677  else {
678  hsize = src_h - src_ibegin;
679  }
680 
681  for (int i = 0; i < hsize; ++i) {
682  Type *srcBitmap = src.bitmap + (((src_ibegin + i) * src_w) + src_jbegin);
683  Type *destBitmap = this->bitmap + (((dest_ibegin + i) * dest_w) + dest_jbegin);
684 
685  memcpy(static_cast<void *>(destBitmap), static_cast<void *>(srcBitmap), static_cast<size_t>(wsize) * sizeof(Type));
686  }
687 }
688 
719 template <class Type> void vpImage<Type>::halfSizeImage(vpImage<Type> &res) const
720 {
721  unsigned int h = height / 2;
722  unsigned int w = width / 2;
723  res.resize(h, w);
724  for (unsigned int i = 0; i < h; ++i) {
725  for (unsigned int j = 0; j < w; ++j) {
726  res[i][j] = (*this)[i << 1][j << 1];
727  }
728  }
729 }
730 
748 template <class Type>
749 void vpImage<Type>::subsample(unsigned int v_scale, unsigned int h_scale, vpImage<Type> &sampled) const
750 {
751  if ((v_scale == 1) && (h_scale == 1)) {
752  sampled = *this;
753  return;
754  }
755  unsigned int h = height / v_scale;
756  unsigned int w = width / h_scale;
757  sampled.resize(h, w);
758  for (unsigned int i = 0; i < h; ++i) {
759  for (unsigned int j = 0; j < w; ++j) {
760  sampled[i][j] = (*this)[i * v_scale][j * h_scale];
761  }
762  }
763 }
764 
787 template <class Type> void vpImage<Type>::quarterSizeImage(vpImage<Type> &res) const
788 {
789  unsigned int h = height / 4;
790  unsigned int w = width / 4;
791  const unsigned int magic_2 = 2;
792  res.resize(h, w);
793  for (unsigned int i = 0; i < h; ++i) {
794  for (unsigned int j = 0; j < w; ++j) {
795  res[i][j] = (*this)[i << magic_2][j << magic_2];
796  }
797  }
798 }
799 
831 template <class Type> void vpImage<Type>::doubleSizeImage(vpImage<Type> &res)
832 {
833  const unsigned int magic_2 = 2;
834  unsigned int h = height * magic_2;
835  unsigned int w = width * magic_2;
836 
837  res.resize(h, w);
838 
839  for (unsigned int i = 0; i < h; ++i) {
840  for (unsigned int j = 0; j < w; ++j) {
841  res[i][j] = (*this)[i >> 1][j >> 1];
842  }
843  }
844 
845  /*
846  A B C
847  E F G
848  H I J
849  A C H J are pixels from original image
850  B E G I are interpolated pixels
851  */
852 
853  // interpolate pixels B and I
854  for (unsigned int i = 0; i < h; i += magic_2) {
855  for (unsigned int j = 1; j < (w - 1); j += magic_2) {
856  res[i][j] = static_cast<Type>(0.5 * ((*this)[i >> 1][j >> 1] + (*this)[i >> 1][(j >> 1) + 1]));
857  }
858  }
859 
860  // interpolate pixels E and G
861  for (unsigned int i = 1; i < (h - 1); i += magic_2) {
862  for (unsigned int j = 0; j < w; j += magic_2) {
863  res[i][j] = static_cast<Type>(0.5 * ((*this)[i >> 1][j >> 1] + (*this)[(i >> 1) + 1][j >> 1]));
864  }
865  }
866 
867  // interpolate pixel F
868  for (unsigned int i = 1; i < (h - 1); i += magic_2) {
869  for (unsigned int j = 1; j < (w - 1); j += magic_2) {
870  res[i][j] = static_cast<Type>(0.25 * ((*this)[i >> 1][j >> 1] + (*this)[i >> 1][(j >> 1) + 1] +
871  (*this)[(i >> 1) + 1][j >> 1] + (*this)[(i >> 1) + 1][(j >> 1) + 1]));
872  }
873  }
874 }
875 
909 template <class Type> void vpImage<Type>::sub(const vpImage<Type> &B, vpImage<Type> &C) const
910 {
911 
912  try {
913  if ((this->getHeight() != C.getHeight()) || (this->getWidth() != C.getWidth())) {
914  C.resize(this->getHeight(), this->getWidth());
915  }
916  }
917  catch (const vpException &me) {
918  std::cout << me << std::endl;
919  throw;
920  }
921 
922  if ((this->getWidth() != B.getWidth()) || (this->getHeight() != B.getHeight())) {
923  throw(vpException(vpException::memoryAllocationError, "vpImage mismatch in vpImage/vpImage subtraction"));
924  }
925 
926  unsigned int this_width = this->getWidth();
927  unsigned int this_height = this->getHeight();
928  for (unsigned int i = 0; i < (this_width * this_height); ++i) {
929  *(C.bitmap + i) = *(bitmap + i) - *(B.bitmap + i);
930  }
931 }
932 
944 template <class Type> void vpImage<Type>::sub(const vpImage<Type> &A, const vpImage<Type> &B, vpImage<Type> &C) const
945 {
946 
947  try {
948  if ((A.getHeight() != C.getHeight()) || (A.getWidth() != C.getWidth())) {
949  C.resize(A.getHeight(), A.getWidth());
950  }
951  }
952  catch (const vpException &me) {
953  std::cout << me << std::endl;
954  throw;
955  }
956 
957  if ((A.getWidth() != B.getWidth()) || (A.getHeight() != B.getHeight())) {
958  throw(vpException(vpException::memoryAllocationError, "vpImage mismatch in vpImage/vpImage subtraction "));
959  }
960 
961  unsigned int a_width = A.getWidth();
962  unsigned int a_height = A.getHeight();
963  for (unsigned int i = 0; i < (a_width * a_height); ++i) {
964  *(C.bitmap + i) = *(A.bitmap + i) - *(B.bitmap + i);
965  }
966 }
967 
968 END_VISP_NAMESPACE
969 #endif
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Definition: vpArray2D.h:611
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:567
void subsample(unsigned int v_scale, unsigned int h_scale, vpImage< Type > &sampled) const
Definition: vpImage.h:749
void halfSizeImage(vpImage< Type > &res) const
Definition: vpImage.h:719
vpImage< Type > & operator=(vpImage< Type > other)
Copy operator.
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.
void quarterSizeImage(vpImage< Type > &res) const
Definition: vpImage.h:787
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:381
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:559
unsigned int getWidth() const
Definition: vpImage.h:242
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
Definition: vpImage.h:538
unsigned int getNumberOfPixel() const
Definition: vpImage.h:203
void doubleSizeImage(vpImage< Type > &res)
Definition: vpImage.h:831
vpImage(unsigned int height, unsigned int width, Type value)
constructor set the size of the image and init all the pixel
Definition: vpImage.h:495
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:633
void sub(const vpImage< Type > &A, const vpImage< Type > &B, vpImage< Type > &C) const
Definition: vpImage.h:944
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:372
unsigned int getSize() const
Definition: vpImage.h:221
vpImage(const vpImage< Type > &img)
copy constructor
Definition: vpImage.h:594
friend void swap(vpImage< Type > &first, vpImage< Type > &second)
Definition: vpImage.h:344
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:909
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:505
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:426
Type getMaxValue(bool onlyFiniteVal=true) const
Return the maximum value within the bitmap.
virtual ~vpImage()
destructor
Definition: vpImage.h:588
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:515
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:372
vpImage(unsigned int height, unsigned int width)
constructor set the size of the image
Definition: vpImage.h:484
void operator()(unsigned int i, unsigned int j, const Type &v)
Definition: vpImage.h:278