Visual Servoing Platform  version 3.6.1 under development (2025-01-22)
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  // static const unsigned int val_256 = 256;
334  // void performLut(const Type(&lut)[val_256], unsigned int nbThreads = 1); // Doesn't pass CI
335  void performLut(const Type(&lut)[256], unsigned int nbThreads = 1);
336 
337  // Returns a new image that's a quarter size of the current image
338  void quarterSizeImage(vpImage<Type> &res) const;
339 
340  // set the size of the image without initializing it.
341  void resize(unsigned int h, unsigned int w);
342  // set the size of the image and initialize it.
343  void resize(unsigned int h, unsigned int w, const Type &val);
344 
345  void sub(const vpImage<Type> &B, vpImage<Type> &C) const;
346  void sub(const vpImage<Type> &A, const vpImage<Type> &B, vpImage<Type> &C) const;
347  void subsample(unsigned int v_scale, unsigned int h_scale, vpImage<Type> &sampled) const;
348 
349  // See https://stackoverflow.com/questions/11562/how-to-overload-stdswap to understand why swap is in visp namespace
350  friend void swap(vpImage<Type> &first, vpImage<Type> &second)
351  {
352  using std::swap;
353  swap(first.bitmap, second.bitmap);
354  swap(first.display, second.display);
355  swap(first.npixels, second.npixels);
356  swap(first.width, second.width);
357  swap(first.height, second.height);
358  swap(first.row, second.row);
359  }
360 
362 
363 private:
364  unsigned int npixels;
365  unsigned int width;
366  unsigned int height;
367  Type **row;
368  bool hasOwnership;
369 };
370 
371 #include <visp3/core/vpImage_operators.h>
372 #include <visp3/core/vpImage_lut.h>
373 #include <visp3/core/vpImage_getters.h>
374 
378 template <class Type> void vpImage<Type>::init(unsigned int h, unsigned int w, Type value)
379 {
380  init(h, w);
381  std::fill(bitmap, bitmap + npixels, value);
382 }
383 
387 template <class Type> void vpImage<Type>::init(unsigned int h, unsigned int w)
388 {
389  if (h != this->height) {
390  if (row != nullptr) {
391  delete[] row;
392  row = nullptr;
393  }
394  }
395 
396  if ((h != this->height) || (w != this->width)) {
397  if (bitmap != nullptr) {
398  if (hasOwnership) {
399  delete[] bitmap;
400  }
401  bitmap = nullptr;
402  }
403  }
404 
405  this->width = w;
406  this->height = h;
407 
408  npixels = width * height;
409 
410  if (bitmap == nullptr) {
411  bitmap = new Type[npixels];
412  hasOwnership = true;
413  }
414  if (bitmap == nullptr) {
415  throw(vpException(vpException::memoryAllocationError, "cannot allocate bitmap "));
416  }
417  if (row == nullptr) {
418  row = new Type *[height];
419  }
420  if (row == nullptr) {
421  throw(vpException(vpException::memoryAllocationError, "cannot allocate row "));
422  }
423 
424  for (unsigned int i = 0; i < height; ++i) {
425  row[i] = bitmap + (i * width);
426  }
427 }
428 
432 template <class Type> void vpImage<Type>::init(Type *const array, unsigned int h, unsigned int w, bool copyData)
433 {
434  if (h != this->height) {
435  if (row != nullptr) {
436  delete[] row;
437  row = nullptr;
438  }
439  }
440 
441  // Delete bitmap if copyData==false, otherwise only if the dimension differs
442  if ((copyData && ((h != this->height) || (w != this->width))) || (!copyData)) {
443  if (bitmap != nullptr) {
444  if (hasOwnership) {
445  delete[] bitmap;
446  }
447  bitmap = nullptr;
448  }
449  }
450 
451  hasOwnership = copyData;
452  this->width = w;
453  this->height = h;
454 
455  npixels = width * height;
456 
457  if (copyData) {
458  if (bitmap == nullptr) {
459  bitmap = new Type[npixels];
460  }
461 
462  if (bitmap == nullptr) {
463  throw(vpException(vpException::memoryAllocationError, "cannot allocate bitmap "));
464  }
465 
466  // Copy the image data
467  memcpy(static_cast<void *>(bitmap), static_cast<void *>(array), static_cast<size_t>(npixels * sizeof(Type)));
468  }
469  else {
470  // Copy the address of the array in the bitmap
471  bitmap = array;
472  }
473 
474  if (row == nullptr) {
475  row = new Type *[height];
476  }
477  if (row == nullptr) {
478  throw(vpException(vpException::memoryAllocationError, "cannot allocate row "));
479  }
480 
481  for (unsigned int i = 0; i < height; ++i) {
482  row[i] = bitmap + (i * width);
483  }
484 }
485 
489 template <class Type>
490 vpImage<Type>::vpImage(unsigned int h, unsigned int w)
491  : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
492 {
493  Type val(0);
494  init(h, w, val);
495 }
496 
500 template <class Type>
501 vpImage<Type>::vpImage(unsigned int h, unsigned int w, Type value)
502  : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
503 {
504  init(h, w, value);
505 }
506 
510 template <class Type>
511 vpImage<Type>::vpImage(Type *const array, unsigned int h, unsigned int w, bool copyData)
512  : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
513 {
514  init(array, h, w, copyData);
515 }
516 
520 template <class Type>
521 vpImage<Type>::vpImage() : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
522 { }
523 
544 template <class Type> void vpImage<Type>::resize(unsigned int h, unsigned int w) { init(h, w); }
545 
565 template <class Type> void vpImage<Type>::resize(unsigned int h, unsigned int w, const Type &val) { init(h, w, val); }
566 
573 template <class Type> void vpImage<Type>::destroy()
574 {
575  if (bitmap != nullptr) {
576  if (hasOwnership) {
577  delete[] bitmap;
578  }
579  bitmap = nullptr;
580  }
581 
582  if (row != nullptr) {
583  delete[] row;
584  row = nullptr;
585  }
586 }
587 
594 template <class Type> vpImage<Type>::~vpImage() { destroy(); }
595 
599 template <class Type>
601  : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
602 {
603  resize(I.getHeight(), I.getWidth());
604  if (bitmap) {
605  memcpy(static_cast<void *>(bitmap), static_cast<void *>(I.bitmap), I.npixels * sizeof(Type));
606  }
607 }
608 
609 #if ((__cplusplus >= 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L))) // Check if cxx11 or higher
613 template <class Type>
615  : bitmap(I.bitmap), display(I.display), npixels(I.npixels), width(I.width), height(I.height), row(I.row),
616  hasOwnership(I.hasOwnership)
617 {
618  I.bitmap = nullptr;
619  I.display = nullptr;
620  I.npixels = 0;
621  I.width = 0;
622  I.height = 0;
623  I.row = nullptr;
624  I.hasOwnership = false;
625 }
626 #endif
627 
639 template <class Type> void vpImage<Type>::insert(const vpImage<Type> &src, const vpImagePoint &topLeft)
640 {
641  int itl = static_cast<int>(topLeft.get_i());
642  int jtl = static_cast<int>(topLeft.get_j());
643 
644  int dest_ibegin = 0;
645  int dest_jbegin = 0;
646  int src_ibegin = 0;
647  int src_jbegin = 0;
648  int dest_w = static_cast<int>(this->getWidth());
649  int dest_h = static_cast<int>(this->getHeight());
650  int src_w = static_cast<int>(src.getWidth());
651  int src_h = static_cast<int>(src.getHeight());
652  int wsize = static_cast<int>(src.getWidth());
653  int hsize = static_cast<int>(src.getHeight());
654 
655  if ((itl >= dest_h) || (jtl >= dest_w)) {
656  return;
657  }
658 
659  if (itl < 0) {
660  src_ibegin = -itl;
661  }
662  else {
663  dest_ibegin = itl;
664  }
665 
666  if (jtl < 0) {
667  src_jbegin = -jtl;
668  }
669  else {
670  dest_jbegin = jtl;
671  }
672 
673  if ((src_w - src_jbegin) >(dest_w - dest_jbegin)) {
674  wsize = dest_w - dest_jbegin;
675  }
676  else {
677  wsize = src_w - src_jbegin;
678  }
679 
680  if ((src_h - src_ibegin) > (dest_h - dest_ibegin)) {
681  hsize = dest_h - dest_ibegin;
682  }
683  else {
684  hsize = src_h - src_ibegin;
685  }
686 
687  for (int i = 0; i < hsize; ++i) {
688  Type *srcBitmap = src.bitmap + (((src_ibegin + i) * src_w) + src_jbegin);
689  Type *destBitmap = this->bitmap + (((dest_ibegin + i) * dest_w) + dest_jbegin);
690 
691  memcpy(static_cast<void *>(destBitmap), static_cast<void *>(srcBitmap), static_cast<size_t>(wsize) * sizeof(Type));
692  }
693 }
694 
725 template <class Type> void vpImage<Type>::halfSizeImage(vpImage<Type> &res) const
726 {
727  unsigned int h = height / 2;
728  unsigned int w = width / 2;
729  res.resize(h, w);
730  for (unsigned int i = 0; i < h; ++i) {
731  for (unsigned int j = 0; j < w; ++j) {
732  res[i][j] = (*this)[i << 1][j << 1];
733  }
734  }
735 }
736 
754 template <class Type>
755 void vpImage<Type>::subsample(unsigned int v_scale, unsigned int h_scale, vpImage<Type> &sampled) const
756 {
757  if ((v_scale == 1) && (h_scale == 1)) {
758  sampled = *this;
759  return;
760  }
761  unsigned int h = height / v_scale;
762  unsigned int w = width / h_scale;
763  sampled.resize(h, w);
764  for (unsigned int i = 0; i < h; ++i) {
765  for (unsigned int j = 0; j < w; ++j) {
766  sampled[i][j] = (*this)[i * v_scale][j * h_scale];
767  }
768  }
769 }
770 
793 template <class Type> void vpImage<Type>::quarterSizeImage(vpImage<Type> &res) const
794 {
795  unsigned int h = height / 4;
796  unsigned int w = width / 4;
797  const unsigned int magic_2 = 2;
798  res.resize(h, w);
799  for (unsigned int i = 0; i < h; ++i) {
800  for (unsigned int j = 0; j < w; ++j) {
801  res[i][j] = (*this)[i << magic_2][j << magic_2];
802  }
803  }
804 }
805 
837 template <class Type> void vpImage<Type>::doubleSizeImage(vpImage<Type> &res)
838 {
839  const unsigned int magic_2 = 2;
840  unsigned int h = height * magic_2;
841  unsigned int w = width * magic_2;
842 
843  res.resize(h, w);
844 
845  for (unsigned int i = 0; i < h; ++i) {
846  for (unsigned int j = 0; j < w; ++j) {
847  res[i][j] = (*this)[i >> 1][j >> 1];
848  }
849  }
850 
851  /*
852  A B C
853  E F G
854  H I J
855  A C H J are pixels from original image
856  B E G I are interpolated pixels
857  */
858 
859  // interpolate pixels B and I
860  for (unsigned int i = 0; i < h; i += magic_2) {
861  for (unsigned int j = 1; j < (w - 1); j += magic_2) {
862  res[i][j] = static_cast<Type>(0.5 * ((*this)[i >> 1][j >> 1] + (*this)[i >> 1][(j >> 1) + 1]));
863  }
864  }
865 
866  // interpolate pixels E and G
867  for (unsigned int i = 1; i < (h - 1); i += magic_2) {
868  for (unsigned int j = 0; j < w; j += magic_2) {
869  res[i][j] = static_cast<Type>(0.5 * ((*this)[i >> 1][j >> 1] + (*this)[(i >> 1) + 1][j >> 1]));
870  }
871  }
872 
873  // interpolate pixel F
874  for (unsigned int i = 1; i < (h - 1); i += magic_2) {
875  for (unsigned int j = 1; j < (w - 1); j += magic_2) {
876  res[i][j] = static_cast<Type>(0.25 * ((*this)[i >> 1][j >> 1] + (*this)[i >> 1][(j >> 1) + 1] +
877  (*this)[(i >> 1) + 1][j >> 1] + (*this)[(i >> 1) + 1][(j >> 1) + 1]));
878  }
879  }
880 }
881 
915 template <class Type> void vpImage<Type>::sub(const vpImage<Type> &B, vpImage<Type> &C) const
916 {
917 
918  try {
919  if ((this->getHeight() != C.getHeight()) || (this->getWidth() != C.getWidth())) {
920  C.resize(this->getHeight(), this->getWidth());
921  }
922  }
923  catch (const vpException &me) {
924  std::cout << me << std::endl;
925  throw;
926  }
927 
928  if ((this->getWidth() != B.getWidth()) || (this->getHeight() != B.getHeight())) {
929  throw(vpException(vpException::memoryAllocationError, "vpImage mismatch in vpImage/vpImage subtraction"));
930  }
931 
932  unsigned int this_width = this->getWidth();
933  unsigned int this_height = this->getHeight();
934  for (unsigned int i = 0; i < (this_width * this_height); ++i) {
935  *(C.bitmap + i) = *(bitmap + i) - *(B.bitmap + i);
936  }
937 }
938 
950 template <class Type> void vpImage<Type>::sub(const vpImage<Type> &A, const vpImage<Type> &B, vpImage<Type> &C) const
951 {
952 
953  try {
954  if ((A.getHeight() != C.getHeight()) || (A.getWidth() != C.getWidth())) {
955  C.resize(A.getHeight(), A.getWidth());
956  }
957  }
958  catch (const vpException &me) {
959  std::cout << me << std::endl;
960  throw;
961  }
962 
963  if ((A.getWidth() != B.getWidth()) || (A.getHeight() != B.getHeight())) {
964  throw(vpException(vpException::memoryAllocationError, "vpImage mismatch in vpImage/vpImage subtraction "));
965  }
966 
967  unsigned int a_width = A.getWidth();
968  unsigned int a_height = A.getHeight();
969  for (unsigned int i = 0; i < (a_width * a_height); ++i) {
970  *(C.bitmap + i) = *(A.bitmap + i) - *(B.bitmap + i);
971  }
972 }
973 
974 END_VISP_NAMESPACE
975 #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:573
void subsample(unsigned int v_scale, unsigned int h_scale, vpImage< Type > &sampled) const
Definition: vpImage.h:755
void halfSizeImage(vpImage< Type > &res) const
Definition: vpImage.h:725
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:793
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:387
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:565
unsigned int getWidth() const
Definition: vpImage.h:242
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
Definition: vpImage.h:544
unsigned int getNumberOfPixel() const
Definition: vpImage.h:203
void doubleSizeImage(vpImage< Type > &res)
Definition: vpImage.h:837
vpImage(unsigned int height, unsigned int width, Type value)
constructor set the size of the image and init all the pixel
Definition: vpImage.h:501
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:639
void sub(const vpImage< Type > &A, const vpImage< Type > &B, vpImage< Type > &C) const
Definition: vpImage.h:950
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:378
unsigned int getSize() const
Definition: vpImage.h:221
vpImage(const vpImage< Type > &img)
copy constructor
Definition: vpImage.h:600
friend void swap(vpImage< Type > &first, vpImage< Type > &second)
Definition: vpImage.h:350
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:915
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:511
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:432
Type getMaxValue(bool onlyFiniteVal=true) const
Return the maximum value within the bitmap.
virtual ~vpImage()
destructor
Definition: vpImage.h:594
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:521
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:378
vpImage(unsigned int height, unsigned int width)
constructor set the size of the image
Definition: vpImage.h:490
void operator()(unsigned int i, unsigned int j, const Type &v)
Definition: vpImage.h:278