Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpImage.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
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 http://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  * Authors:
34  * Eric Marchand
35  *
36  *****************************************************************************/
37 
38 
44 #ifndef vpImage_H
45 #define vpImage_H
46 
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>
55 #endif
56 
57 #include <fstream>
58 #include <iostream>
59 #include <iomanip> // std::setw
60 #include <math.h>
61 #include <string.h>
62 
63 class vpDisplay;
64 
115 //Ref: http://en.cppreference.com/w/cpp/language/friend#Template_friends
116 template<class Type>
117 class vpImage; // forward declare to make function declaration possible
118 
119 // declarations
120 template<class Type>
121 std::ostream& operator<<(std::ostream&, const vpImage<Type>&);
122 
123 std::ostream& operator<<(std::ostream&, const vpImage<unsigned char>&);
124 std::ostream& operator<<(std::ostream&, const vpImage<char>&);
125 std::ostream& operator<<(std::ostream&, const vpImage<float>&);
126 std::ostream& operator<<(std::ostream&, const vpImage<double>&);
127 
128 template<class Type>
129 class vpImage
130 {
131  friend class vpImageConvert;
132 
133 public:
134  Type *bitmap ;
136 
138  vpImage() ;
140  vpImage(const vpImage<Type>&);
142  vpImage(unsigned int height, unsigned int width) ;
144  vpImage(unsigned int height, unsigned int width, Type value) ;
146  vpImage(Type * const array, const unsigned int height, const unsigned int width, const bool copyData=false) ;
148  virtual ~vpImage() ;
149 
152 
153  // destructor
154  void destroy();
155 
156  // Returns a new image that's double size of the current image
157  void doubleSizeImage(vpImage<Type> &res);
158 
166  inline unsigned int getCols() const { return width ; }
175  inline unsigned int getHeight() const { return height; }
176 
177  // Return the maximum value within the bitmap
178  Type getMaxValue() const ;
179  // Return the minumum value within the bitmap
180  Type getMinValue() const ;
181  //Look for the minumum and the maximum value within the bitmap
182  void getMinMaxValue(Type &min, Type &max) const;
183 
194  inline unsigned int getNumberOfPixel() const{ return npixels; }
195 
204  inline unsigned int getRows() const { return height ; }
212  inline unsigned int getSize() const { return width*height ; }
213 
214  // Gets the value of a pixel at a location with bilinear interpolation.
215  Type getValue(double i, double j) const;
216  // Gets the value of a pixel at a location with bilinear interpolation.
217  Type getValue(vpImagePoint &ip) const;
226  inline unsigned int getWidth() const { return width; }
227 
228  // Returns a new image that's half size of the current image
229  void halfSizeImage(vpImage<Type> &res) const;
230 
232  void init(unsigned int height, unsigned int width) ;
234  void init(unsigned int height, unsigned int width, Type value) ;
236  void init(Type * const array, const unsigned int height, const unsigned int width, const bool copyData=false);
237  void insert(const vpImage<Type> &src, const vpImagePoint topLeft);
238 
239  //------------------------------------------------------------------
240  // Acces to the image
241 
243  inline Type *operator[]( const unsigned int i) { return row[i];}
244  inline Type *operator[]( const int i) { return row[i];}
245 
247  inline const Type *operator[](unsigned int i) const { return row[i];}
248  inline const Type *operator[](int i) const { return row[i];}
249 
257  inline Type operator()(const unsigned int i, const unsigned int j) const
258  {
259  return bitmap[i*width+j] ;
260  }
266  inline void operator()(const unsigned int i, const unsigned int j,
267  const Type &v)
268  {
269  bitmap[i*width+j] = v ;
270  }
282  inline Type operator()(const vpImagePoint &ip) const
283  {
284  unsigned int i = (unsigned int) ip.get_i();
285  unsigned int j = (unsigned int) ip.get_j();
286 
287  return bitmap[i*width+j] ;
288  }
298  inline void operator()(const vpImagePoint &ip, const Type &v)
299  {
300  unsigned int i = (unsigned int) ip.get_i();
301  unsigned int j = (unsigned int) ip.get_j();
302 
303  bitmap[i*width+j] = v ;
304  }
305 
307 
310 
311  vpImage<Type>& operator=(const Type &v);
312  bool operator==(const vpImage<Type> &I);
313  bool operator!=(const vpImage<Type> &I);
314  friend std::ostream& operator<< <> (std::ostream &s, const vpImage<Type> &I);
315  friend std::ostream& operator<<(std::ostream &s, const vpImage<unsigned char> &I);
316  friend std::ostream& operator<<(std::ostream &s, const vpImage<char> &I);
317  friend std::ostream& operator<<(std::ostream &s, const vpImage<float> &I);
318  friend std::ostream& operator<<(std::ostream &s, const vpImage<double> &I);
319 
320  // Perform a look-up table transformation
321  void performLut(const Type (&lut)[256], const unsigned int nbThreads=1);
322 
323  // Returns a new image that's a quarter size of the current image
324  void quarterSizeImage(vpImage<Type> &res) const;
325 
326  // set the size of the image without initializing it.
327  void resize(const unsigned int h, const unsigned int w);
328  // set the size of the image and initialize it.
329  void resize(const unsigned int h, const unsigned int w, const Type val);
330 
331  void sub(const vpImage<Type> &B, vpImage<Type> &C);
332  void sub(const vpImage<Type> &A, const vpImage<Type> &B, vpImage<Type> &C);
333  void subsample(unsigned int v_scale, unsigned int h_scale, vpImage<Type> &sampled) const;
334 
336 
337 private:
338  unsigned int npixels ;
339  unsigned int width ;
340  unsigned int height ;
341  Type **row ;
342 };
343 
344 template<class Type>
345 std::ostream& operator<<(std::ostream &s, const vpImage<Type> &I) {
346  if (I.bitmap == NULL) {
347  return s;
348  }
349 
350  for (unsigned int i = 0; i < I.getHeight(); i++) {
351  for (unsigned int j = 0; j < I.getWidth()-1; j++) {
352  s << I[i][j] << " ";
353  }
354 
355  // We don't add " " after the last column element
356  s << I[i][I.getWidth() -1];
357 
358  // We don't add a \n character at the end of the last row line
359  if (i < I.getHeight()-1) {
360  s << std::endl;
361  }
362  }
363 
364  return s;
365 }
366 
367 inline std::ostream& operator<<(std::ostream &s, const vpImage<unsigned char> &I) {
368  if (I.bitmap == NULL) {
369  return s;
370  }
371 
372  std::ios_base::fmtflags original_flags = s.flags();
373 
374  for (unsigned int i = 0; i < I.getHeight(); i++) {
375  for (unsigned int j = 0; j < I.getWidth()-1; j++) {
376  s << std::setw(3) << static_cast<unsigned>(I[i][j]) << " ";
377  }
378 
379  // We don't add " " after the last column element
380  s << std::setw(3) << static_cast<unsigned>(I[i][I.getWidth() -1]);
381 
382  // We don't add a \n character at the end of the last row line
383  if (i < I.getHeight()-1) {
384  s << std::endl;
385  }
386  }
387 
388  s.flags(original_flags); // restore s to standard state
389  return s;
390 }
391 
392 inline std::ostream& operator<<(std::ostream &s, const vpImage<char> &I) {
393  if (I.bitmap == NULL) {
394  return s;
395  }
396 
397  std::ios_base::fmtflags original_flags = s.flags();
398 
399  for (unsigned int i = 0; i < I.getHeight(); i++) {
400  for (unsigned int j = 0; j < I.getWidth()-1; j++) {
401  s <<std::setw(4) << static_cast<int>(I[i][j]) << " ";
402  }
403 
404  // We don't add " " after the last column element
405  s << std::setw(4) << static_cast<int>(I[i][I.getWidth() -1]);
406 
407  // We don't add a \n character at the end of the last row line
408  if (i < I.getHeight()-1) {
409  s << std::endl;
410  }
411  }
412 
413  s.flags(original_flags); // restore s to standard state
414  return s;
415 }
416 
417 inline std::ostream& operator<<(std::ostream &s, const vpImage<float> &I) {
418  if (I.bitmap == NULL) {
419  return s;
420  }
421 
422  std::ios_base::fmtflags original_flags = s.flags();
423  s.precision(9); //http://en.cppreference.com/w/cpp/types/numeric_limits/max_digits10
424 
425  for (unsigned int i = 0; i < I.getHeight(); i++) {
426  for (unsigned int j = 0; j < I.getWidth()-1; j++) {
427  s << I[i][j] << " ";
428  }
429 
430  // We don't add " " after the last column element
431  s << I[i][I.getWidth() -1];
432 
433  // We don't add a \n character at the end of the last row line
434  if (i < I.getHeight()-1) {
435  s << std::endl;
436  }
437  }
438 
439  s.flags(original_flags); // restore s to standard state
440  return s;
441 }
442 
443 inline std::ostream& operator<<(std::ostream &s, const vpImage<double> &I) {
444  if (I.bitmap == NULL) {
445  return s;
446  }
447 
448  std::ios_base::fmtflags original_flags = s.flags();
449  s.precision(17); //http://en.cppreference.com/w/cpp/types/numeric_limits/max_digits10
450 
451  for (unsigned int i = 0; i < I.getHeight(); i++) {
452  for (unsigned int j = 0; j < I.getWidth()-1; j++) {
453  s << I[i][j] << " ";
454  }
455 
456  // We don't add " " after the last column element
457  s << I[i][I.getWidth() -1];
458 
459  // We don't add a \n character at the end of the last row line
460  if (i < I.getHeight()-1) {
461  s << std::endl;
462  }
463  }
464 
465  s.flags(original_flags); // restore s to standard state
466  return s;
467 }
468 
469 
470 #if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0))
471 namespace {
472  struct ImageLut_Param_t {
473  unsigned int m_start_index;
474  unsigned int m_end_index;
475 
476  unsigned char m_lut[256];
477  unsigned char *m_bitmap;
478 
479  ImageLut_Param_t() : m_start_index(0), m_end_index(0), m_lut(), m_bitmap(NULL) {
480  }
481 
482  ImageLut_Param_t(const unsigned int start_index, const unsigned int end_index,
483  unsigned char *bitmap) :
484  m_start_index(start_index), m_end_index(end_index), m_lut(), m_bitmap(bitmap) {
485  }
486  };
487 
488  vpThread::Return performLutThread(vpThread::Args args) {
489  ImageLut_Param_t *imageLut_param = ( (ImageLut_Param_t *) args );
490  unsigned int start_index = imageLut_param->m_start_index;
491  unsigned int end_index = imageLut_param->m_end_index;
492 
493  unsigned char *bitmap = imageLut_param->m_bitmap;
494 
495  unsigned char *ptrStart = bitmap + start_index;
496  unsigned char *ptrEnd = bitmap + end_index;
497  unsigned char *ptrCurrent = ptrStart;
498 
499 
500 // while(ptrCurrent != ptrEnd) {
501 // *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
502 // ++ptrCurrent;
503 // }
504 
505  if(end_index - start_index >= 8) {
506  //Unroll loop version
507  for(; ptrCurrent <= ptrEnd - 8;) {
508  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
509  ++ptrCurrent;
510 
511  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
512  ++ptrCurrent;
513 
514  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
515  ++ptrCurrent;
516 
517  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
518  ++ptrCurrent;
519 
520  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
521  ++ptrCurrent;
522 
523  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
524  ++ptrCurrent;
525 
526  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
527  ++ptrCurrent;
528 
529  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
530  ++ptrCurrent;
531  }
532  }
533 
534  for(; ptrCurrent != ptrEnd; ++ptrCurrent) {
535  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent];
536  }
537 
538  return 0;
539  }
540 
541 
542  struct ImageLutRGBa_Param_t {
543  unsigned int m_start_index;
544  unsigned int m_end_index;
545 
546  vpRGBa m_lut[256];
547  unsigned char *m_bitmap;
548 
549  ImageLutRGBa_Param_t() : m_start_index(0), m_end_index(0), m_lut(), m_bitmap(NULL) {
550  }
551 
552  ImageLutRGBa_Param_t(const unsigned int start_index, const unsigned int end_index,
553  unsigned char *bitmap) :
554  m_start_index(start_index), m_end_index(end_index), m_lut(), m_bitmap(bitmap) {
555  }
556  };
557 
558  vpThread::Return performLutRGBaThread(vpThread::Args args) {
559  ImageLutRGBa_Param_t *imageLut_param = ( (ImageLutRGBa_Param_t *) args );
560  unsigned int start_index = imageLut_param->m_start_index;
561  unsigned int end_index = imageLut_param->m_end_index;
562 
563  unsigned char *bitmap = imageLut_param->m_bitmap;
564 
565  unsigned char *ptrStart = bitmap + start_index*4;
566  unsigned char *ptrEnd = bitmap + end_index*4;
567  unsigned char *ptrCurrent = ptrStart;
568 
569 
570  if(end_index - start_index >= 4*2) {
571  //Unroll loop version
572  for(; ptrCurrent <= ptrEnd - 4*2;) {
573  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].R;
574  ptrCurrent++;
575  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].G;
576  ptrCurrent++;
577  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].B;
578  ptrCurrent++;
579  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].A;
580  ptrCurrent++;
581 
582  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].R;
583  ptrCurrent++;
584  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].G;
585  ptrCurrent++;
586  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].B;
587  ptrCurrent++;
588  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].A;
589  ptrCurrent++;
590  }
591  }
592 
593  while(ptrCurrent != ptrEnd) {
594  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].R;
595  ptrCurrent++;
596 
597  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].G;
598  ptrCurrent++;
599 
600  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].B;
601  ptrCurrent++;
602 
603  *ptrCurrent = imageLut_param->m_lut[*ptrCurrent].A;
604  ptrCurrent++;
605  }
606 
607  return 0;
608  }
609 }
610 #endif
611 
612 
626 template<class Type>
627 void
628 vpImage<Type>::init(unsigned int h, unsigned int w, Type value)
629 {
630  try
631  {
632  init(h,w) ;
633  }
634  catch(vpException &)
635  {
636  vpERROR_TRACE(" ") ;
637  throw ;
638  }
639 
640  for (unsigned int i=0 ; i < npixels ; i++)
641  bitmap[i] = value ;
642 }
643 
644 
662 template<class Type>
663 void
664 vpImage<Type>::init(unsigned int h, unsigned int w)
665 {
666  if (h != this->height) {
667  if (row != NULL) {
668  vpDEBUG_TRACE(10,"Destruction row[]");
669  delete [] row;
670  row = NULL;
671  }
672  }
673 
674  if ((h != this->height) || (w != this->width))
675  {
676  if (bitmap != NULL) {
677  vpDEBUG_TRACE(10,"Destruction bitmap[]") ;
678  delete [] bitmap;
679  bitmap = NULL;
680  }
681  }
682 
683  this->width = w ;
684  this->height = h;
685 
686  npixels=width*height;
687 
688  if (bitmap == NULL) bitmap = new Type[npixels] ;
689 
690  // vpERROR_TRACE("Allocate bitmap %p",bitmap) ;
691  if (bitmap == NULL)
692  {
693  vpERROR_TRACE("cannot allocate bitmap ") ;
695  "cannot allocate bitmap ")) ;
696  }
697 
698  if (row == NULL) row = new Type*[height] ;
699 // vpERROR_TRACE("Allocate row %p",row) ;
700  if (row == NULL)
701  {
702  vpERROR_TRACE("cannot allocate row ") ;
704  "cannot allocate row ")) ;
705  }
706 
707  unsigned int i ;
708  for ( i =0 ; i < height ; i++)
709  row[i] = bitmap + i*width ;
710 }
711 
724 template<class Type>
725 void
726 vpImage<Type>::init(Type * const array, const unsigned int h, const unsigned int w, const bool copyData)
727 {
728  if (h != this->height) {
729  if (row != NULL) {
730  delete [] row;
731  row = NULL;
732  }
733  }
734 
735  //Delete bitmap if copyData==false, otherwise only if the dimension differs
736  if ( (copyData && ((h != this->height) || (w != this->width))) || !copyData ) {
737  if (bitmap != NULL) {
738  delete [] bitmap;
739  bitmap = NULL;
740  }
741  }
742 
743  this->width = w ;
744  this->height = h;
745 
746  npixels = width*height;
747 
748  if(copyData) {
749  if (bitmap == NULL) bitmap = new Type[npixels];
750 
751  if (bitmap == NULL) {
753  "cannot allocate bitmap ")) ;
754  }
755 
756  //Copy the image data
757  memcpy(bitmap, array, (size_t) (npixels * sizeof(Type)));
758  } else {
759  //Copy the address of the array in the bitmap
760  bitmap = array;
761  }
762 
763  if (row == NULL) row = new Type*[height];
764  if (row == NULL) {
766  "cannot allocate row ")) ;
767  }
768 
769  for (unsigned int i = 0 ; i < height ; i++) {
770  row[i] = bitmap + i*width;
771  }
772 }
773 
792 template<class Type>
793 vpImage<Type>::vpImage(unsigned int h, unsigned int w)
794  : bitmap(NULL), display(NULL), npixels(0), width(0), height(0), row(NULL)
795 {
796  try
797  {
798  init(h,w,0) ;
799  }
800  catch(...)
801  {
802  throw ;
803  }
804 }
805 
823 template<class Type>
824 vpImage<Type>::vpImage (unsigned int h, unsigned int w, Type value)
825  : bitmap(NULL), display(NULL), npixels(0), width(0), height(0), row(NULL)
826 {
827  try
828  {
829  init(h,w,value) ;
830  }
831  catch(vpException &)
832  {
833  vpERROR_TRACE(" ") ;
834  throw ;
835  }
836 }
837 
852 template<class Type>
853 vpImage<Type>::vpImage (Type * const array, const unsigned int h, const unsigned int w, const bool copyData)
854  : bitmap(NULL), display(NULL), npixels(0), width(0), height(0), row(NULL)
855 {
856  try
857  {
858  init(array, h, w, copyData);
859  }
860  catch(vpException &)
861  {
862  throw ;
863  }
864 }
865 
875 template<class Type>
877  : bitmap(NULL), display(NULL), npixels(0), width(0), height(0), row(NULL)
878 {
879 }
880 
901 template<class Type>
902 void
903 vpImage<Type>::resize(unsigned int h, unsigned int w)
904 {
905  try
906  {
907  init(h, w) ;
908  }
909  catch(vpException &)
910  {
911  vpERROR_TRACE(" ") ;
912  throw ;
913  }
914 }
915 
935 template<class Type>
936 void
937 vpImage<Type>::resize(unsigned int h, unsigned int w, const Type val)
938 {
939  try
940  {
941  init(h, w, val) ;
942  }
943  catch(vpException &)
944  {
945  vpERROR_TRACE(" ") ;
946  throw ;
947  }
948 }
949 
950 
957 template<class Type>
958 void
960 {
961  // vpERROR_TRACE("Deallocate ") ;
962 
963 
964  if (bitmap!=NULL)
965  {
966  // vpERROR_TRACE("Deallocate bitmap memory %p",bitmap) ;
967 // vpDEBUG_TRACE(20,"Deallocate bitmap memory %p",bitmap) ;
968  delete [] bitmap ;
969  bitmap = NULL;
970  }
971 
972 
973  if (row!=NULL)
974  {
975  // vpERROR_TRACE("Deallocate row memory %p",row) ;
976 // vpDEBUG_TRACE(20,"Deallocate row memory %p",row) ;
977  delete [] row ;
978  row = NULL;
979  }
980 
981 }
982 
989 template<class Type>
991 {
992  destroy() ;
993 }
994 
995 
996 
1000 template<class Type>
1002  : bitmap(NULL), display(NULL), npixels(0), width(0), height(0), row(NULL)
1003 {
1004  try
1005  {
1006  resize(I.getHeight(),I.getWidth());
1007  memcpy(bitmap, I.bitmap, I.npixels*sizeof(Type)) ;
1008  for (unsigned int i =0 ; i < this->height ; i++) row[i] = bitmap + i*this->width ;
1009  }
1010  catch(vpException &)
1011  {
1012  vpERROR_TRACE(" ") ;
1013  throw ;
1014  }
1015 }
1016 
1022 template<class Type>
1024 {
1025  Type m = bitmap[0] ;
1026  for (unsigned int i=0 ; i < npixels ; i++)
1027  {
1028  if (bitmap[i]>m) m = bitmap[i] ;
1029  }
1030  return m ;
1031 }
1032 
1038 template<class Type>
1040 {
1041  Type m = bitmap[0];
1042  for (unsigned int i=0 ; i < npixels ; i++)
1043  if (bitmap[i]<m) m = bitmap[i] ;
1044  return m ;
1045 }
1046 
1047 
1054 template<class Type>
1055 void vpImage<Type>::getMinMaxValue(Type &min, Type &max) const
1056 {
1057  min = max = bitmap[0];
1058  for (unsigned int i=0 ; i < npixels ; i++)
1059  {
1060  if (bitmap[i]<min) min = bitmap[i] ;
1061  if (bitmap[i]>max) max = bitmap[i] ;
1062  }
1063 }
1064 
1068 template<class Type>
1070 {
1071  /* we first have to set the initial values of the image because resize function calls init function that test the actual size of the image */
1072  if(bitmap != NULL){
1073  delete[] bitmap;
1074  bitmap = NULL ;
1075  }
1076 
1077  if(row != NULL){
1078  delete[] row;
1079  row = NULL ;
1080  }
1081  this->width = I.width;
1082  this->height = I.height;
1083  this->npixels = I.npixels;
1084  try
1085  {
1086  if(I.npixels != 0)
1087  {
1088  if (bitmap == NULL){
1089  bitmap = new Type[npixels] ;
1090  }
1091 
1092  if (bitmap == NULL){
1093  vpERROR_TRACE("cannot allocate bitmap ") ;
1095  "cannot allocate bitmap ")) ;
1096  }
1097 
1098  if (row == NULL){
1099  row = new Type*[height] ;
1100  }
1101  if (row == NULL){
1102  vpERROR_TRACE("cannot allocate row ") ;
1104  "cannot allocate row ")) ;
1105  }
1106 
1107  memcpy(bitmap, I.bitmap, I.npixels*sizeof(Type)) ;
1108 
1109  for (unsigned int i=0; i<this->height; i++){
1110  row[i] = bitmap + i*this->width;
1111  }
1112  }
1113  }
1114  catch(vpException &)
1115  {
1116  vpERROR_TRACE(" ") ;
1117  throw ;
1118  }
1119  return (* this);
1120 }
1121 
1122 
1129 template<class Type>
1131 {
1132  for (unsigned int i=0 ; i < npixels ; i++)
1133  bitmap[i] = v ;
1134 
1135  return *this;
1136 }
1137 
1143 template<class Type>
1145 {
1146  if (this->width != I.getWidth())
1147  return false;
1148  if (this->height != I.getHeight())
1149  return false;
1150 
1151 // printf("wxh: %dx%d bitmap: %p I.bitmap %p\n", width, height, bitmap, I.bitmap);
1152  for (unsigned int i=0 ; i < npixels ; i++)
1153  {
1154  if (bitmap[i] != I.bitmap[i]) {
1155 // std::cout << "differ for pixel " << i << " (" << i%this->height << ", " << i - i%this->height << ")" << std::endl;
1156  return false;
1157  }
1158  }
1159  return true ;
1160 }
1166 template<class Type>
1168 {
1169 // if (this->width != I.getWidth())
1170 // return true;
1171 // if (this->height != I.getHeight())
1172 // return true;
1173 
1174 // for (unsigned int i=0 ; i < npixels ; i++)
1175 // {
1176 // if (bitmap[i] != I.bitmap[i])
1177 // return true;
1178 // }
1179 // return false ;
1180  return !(*this == I);
1181 }
1182 
1208 template<class Type>
1210 {
1211  vpImage<Type> C;
1212  sub(*this,B,C);
1213  return C;
1214 }
1215 
1225 template<class Type>
1226 void vpImage<Type>::insert(const vpImage<Type> &src, const vpImagePoint topLeft)
1227 {
1228  Type* srcBitmap;
1229  Type* destBitmap;
1230 
1231  int itl = (int)topLeft.get_i();
1232  int jtl = (int)topLeft.get_j();
1233 
1234  int dest_ibegin = 0;
1235  int dest_jbegin = 0;
1236  int src_ibegin = 0;
1237  int src_jbegin = 0;
1238  int dest_w = (int)this->getWidth();
1239  int dest_h = (int)this->getHeight();
1240  int src_w = (int)src.getWidth();
1241  int src_h = (int)src.getHeight();
1242  int wsize = (int)src.getWidth();
1243  int hsize = (int)src.getHeight();
1244 
1245  if (itl >= dest_h || jtl >= dest_w)
1246  return;
1247 
1248  if (itl < 0)
1249  src_ibegin = -itl;
1250  else
1251  dest_ibegin = itl;
1252 
1253  if (jtl < 0)
1254  src_jbegin = -jtl;
1255  else
1256  dest_jbegin = jtl;
1257 
1258  if (src_w - src_jbegin > dest_w - dest_jbegin)
1259  wsize = dest_w - dest_jbegin;
1260  else
1261  wsize = src_w - src_jbegin;
1262 
1263  if (src_h - src_ibegin > dest_h - dest_ibegin)
1264  hsize = dest_h - dest_ibegin;
1265  else
1266  hsize = src_h - src_ibegin;
1267 
1268  for (int i = 0; i < hsize; i++)
1269  {
1270  srcBitmap = src.bitmap + ((src_ibegin+i)*src_w+src_jbegin);
1271  destBitmap = this->bitmap + ((dest_ibegin+i)*dest_w+dest_jbegin);
1272 
1273  memcpy(destBitmap, srcBitmap, (size_t)wsize*sizeof(Type));
1274  }
1275 }
1276 
1307 template<class Type>
1308 void
1310 {
1311  unsigned int h = height/2;
1312  unsigned int w = width/2;
1313  res.resize(h, w);
1314  for(unsigned int i = 0; i < h; i++)
1315  for(unsigned int j = 0; j < w; j++)
1316  res[i][j] = (*this)[i<<1][j<<1];
1317 }
1318 
1336 template<class Type>
1337 void
1338 vpImage<Type>::subsample(unsigned int v_scale, unsigned int h_scale, vpImage<Type> &sampled) const
1339 {
1340  unsigned int h = height/v_scale;
1341  unsigned int w = width/h_scale;
1342  sampled.resize(h, w);
1343  for(unsigned int i = 0; i < h; i++)
1344  for(unsigned int j = 0; j < w; j++)
1345  sampled[i][j] = (*this)[i*v_scale][j*h_scale];
1346 }
1347 
1372 template<class Type>
1373 void
1375 {
1376  unsigned int h = height/4;
1377  unsigned int w = width/4;
1378  res.resize(h, w);
1379  for(unsigned int i = 0; i < h; i++)
1380  for(unsigned int j = 0; j < w; j++)
1381  res[i][j] = (*this)[i<<2][j<<2];
1382 }
1383 
1417 template<class Type>
1418 void
1420 {
1421  int h = height*2;
1422  int w = width*2;
1423 
1424  res.resize(h, w);
1425 
1426  for(int i = 0; i < h; i++)
1427  for(int j = 0; j < w; j++)
1428  res[i][j] = (*this)[i>>1][j>>1];
1429 
1430  /*
1431  A B C
1432  E F G
1433  H I J
1434  A C H J are pixels from original image
1435  B E G I are interpolated pixels
1436  */
1437 
1438  //interpolate pixels B and I
1439  for(int i = 0; i < h; i += 2)
1440  for(int j = 1; j < w - 1; j += 2)
1441  res[i][j] = (Type)(0.5 * ((*this)[i>>1][j>>1]
1442  + (*this)[i>>1][(j>>1) + 1]));
1443 
1444  //interpolate pixels E and G
1445  for(int i = 1; i < h - 1; i += 2)
1446  for(int j = 0; j < w; j += 2)
1447  res[i][j] = (Type)(0.5 * ((*this)[i>>1][j>>1]
1448  + (*this)[(i>>1)+1][j>>1]));
1449 
1450  //interpolate pixel F
1451  for(int i = 1; i < h - 1; i += 2)
1452  for(int j = 1; j < w - 1; j += 2)
1453  res[i][j] = (Type)(0.25 * ((*this)[i>>1][j>>1]
1454  + (*this)[i>>1][(j>>1)+1]
1455  + (*this)[(i>>1)+1][j>>1]
1456  + (*this)[(i>>1)+1][(j>>1)+1]));
1457 }
1458 
1476 template<class Type>
1477 Type vpImage<Type>::getValue(double i, double j) const
1478 {
1479  unsigned int iround, jround;
1480  double rfrac, cfrac;
1481 
1482  iround = (unsigned int)floor(i);
1483  jround = (unsigned int)floor(j);
1484 
1485  if (iround >= height || jround >= width) {
1486  vpERROR_TRACE("Pixel outside the image") ;
1488  "Pixel outside the image"));
1489  }
1490 
1491  if (i > height - 1)
1492  i = (double)(height - 1);
1493 
1494  if (j > width - 1)
1495  j = (double)(width - 1);
1496 
1497  double rratio = i - (double) iround;
1498  if(rratio < 0)
1499  rratio=-rratio;
1500  double cratio = j - (double) jround;
1501  if(cratio < 0)
1502  cratio=-cratio;
1503 
1504  rfrac = 1.0f - rratio;
1505  cfrac = 1.0f - cratio;
1506 
1507  double value = ((double)row[iround][jround] * rfrac + (double)row[iround+1][jround] * rratio)*cfrac
1508  + ((double)row[iround][jround+1]*rfrac + (double)row[iround+1][jround+1] * rratio)*cratio;
1509  return (Type)vpMath::round(value);
1510 }
1511 
1529 template<>
1530 inline double vpImage<double>::getValue(double i, double j) const
1531 {
1532  unsigned int iround, jround;
1533  double rfrac, cfrac;
1534 
1535  iround = (unsigned int)floor(i);
1536  jround = (unsigned int)floor(j);
1537 
1538  if (iround >= height || jround >= width) {
1539  vpERROR_TRACE("Pixel outside the image") ;
1541  "Pixel outside the image"));
1542  }
1543 
1544  if (i > height - 1)
1545  i = (double)(height - 1);
1546 
1547  if (j > width - 1)
1548  j = (double)(width - 1);
1549 
1550  double rratio = i - (double) iround;
1551  if(rratio < 0)
1552  rratio=-rratio;
1553  double cratio = j - (double) jround;
1554  if(cratio < 0)
1555  cratio=-cratio;
1556 
1557  rfrac = 1.0f - rratio;
1558  cfrac = 1.0f - cratio;
1559 
1560 
1561  double value = ((double)row[iround][jround] * rfrac + (double)row[iround+1][jround] * rratio)*cfrac
1562  + ((double)row[iround][jround+1]*rfrac + (double)row[iround+1][jround+1] * rratio)*cratio;
1563  return value;
1564 }
1565 
1566 template<>
1567 inline vpRGBa vpImage<vpRGBa>::getValue(double i, double j) const
1568 {
1569  unsigned int iround, jround;
1570  double rfrac, cfrac;
1571 
1572  iround = (unsigned int)floor(i);
1573  jround = (unsigned int)floor(j);
1574 
1575  if (iround >= height || jround >= width) {
1576  vpERROR_TRACE("Pixel outside the image") ;
1578  "Pixel outside the image"));
1579  }
1580 
1581  if (i > height - 1)
1582  i = (double)(height - 1);
1583 
1584  if (j > width - 1)
1585  j = (double)(width - 1);
1586 
1587  double rratio = i - (double) iround;
1588  if(rratio < 0)
1589  rratio=-rratio;
1590  double cratio = j - (double) jround;
1591  if(cratio < 0)
1592  cratio=-cratio;
1593 
1594  rfrac = 1.0f - rratio;
1595  cfrac = 1.0f - cratio;
1596 
1597  double valueR = ((double)row[iround][jround].R * rfrac + (double)row[iround+1][jround].R * rratio)*cfrac
1598  + ((double)row[iround][jround+1].R * rfrac + (double)row[iround+1][jround+1].R * rratio)*cratio;
1599  double valueG = ((double)row[iround][jround].G * rfrac + (double)row[iround+1][jround].G * rratio)*cfrac
1600  + ((double)row[iround][jround+1].G* rfrac + (double)row[iround+1][jround+1].G * rratio)*cratio;
1601  double valueB = ((double)row[iround][jround].B * rfrac + (double)row[iround+1][jround].B * rratio)*cfrac
1602  + ((double)row[iround][jround+1].B*rfrac + (double)row[iround+1][jround+1].B * rratio)*cratio;
1603  return vpRGBa((unsigned char)vpMath::round(valueR),(unsigned char)vpMath::round(valueG),(unsigned char)vpMath::round(valueB));
1604 }
1605 
1622 template<class Type>
1624 {
1625  unsigned int iround, jround;
1626  double rfrac, cfrac;
1627 
1628  iround = (unsigned int)floor(ip.get_i());
1629  jround = (unsigned int)floor(ip.get_j());
1630 
1631  if (iround >= height || jround >= width) {
1632  vpERROR_TRACE("Pixel outside the image") ;
1634  "Pixel outside the image"));
1635  }
1636 
1637  if (ip.get_i() > height - 1)
1638  ip.set_i((double)(height - 1));
1639 
1640  if (ip.get_j() > width - 1)
1641  ip.set_j((double)(width - 1));
1642 
1643  double rratio = ip.get_i() - (double) iround;
1644  if(rratio < 0)
1645  rratio=-rratio;
1646  double cratio = ip.get_j() - (double) jround;
1647  if(cratio < 0)
1648  cratio=-cratio;
1649 
1650  rfrac = 1.0f - rratio;
1651  cfrac = 1.0f - cratio;
1652 
1653  double value = ((double)row[iround][jround] * rfrac + (double)row[iround+1][jround] * rratio)*cfrac
1654  + ((double)row[iround][jround+1]*rfrac + (double)row[iround+1][jround+1] * rratio)*cratio;
1655  return (Type)vpMath::round(value);
1656 }
1657 
1658 template<>
1659 inline double vpImage<double>::getValue(vpImagePoint &ip) const
1660 {
1661  unsigned int iround, jround;
1662  double rfrac, cfrac;
1663 
1664  iround = (unsigned int)floor(ip.get_i());
1665  jround = (unsigned int)floor(ip.get_j());
1666 
1667  if (iround >= height || jround >= width) {
1668  vpERROR_TRACE("Pixel outside the image") ;
1670  "Pixel outside the image"));
1671  }
1672 
1673  if (ip.get_i() > height - 1)
1674  ip.set_i((double)(height - 1));
1675 
1676  if (ip.get_j() > width - 1)
1677  ip.set_j((double)(width - 1));
1678 
1679  double rratio = ip.get_i() - (double) iround;
1680  if(rratio < 0)
1681  rratio=-rratio;
1682  double cratio = ip.get_j() - (double) jround;
1683  if(cratio < 0)
1684  cratio=-cratio;
1685 
1686  rfrac = 1.0f - rratio;
1687  cfrac = 1.0f - cratio;
1688 
1689 
1690  double value = ((double)row[iround][jround] * rfrac + (double)row[iround+1][jround] * rratio)*cfrac
1691  + ((double)row[iround][jround+1]*rfrac + (double)row[iround+1][jround+1] * rratio)*cratio;
1692  return value;
1693 }
1694 
1695 template<>
1697 {
1698  unsigned int iround, jround;
1699  double rfrac, cfrac;
1700 
1701  iround = (unsigned int)floor(ip.get_i());
1702  jround = (unsigned int)floor(ip.get_j());
1703 
1704  if (iround >= height || jround >= width) {
1705  vpERROR_TRACE("Pixel outside the image") ;
1707  "Pixel outside the image"));
1708  }
1709 
1710  if (ip.get_i() > height - 1)
1711  ip.set_i((double)(height - 1));
1712 
1713  if (ip.get_j() > width - 1)
1714  ip.set_j((double)(width - 1));
1715 
1716  double rratio = ip.get_i() - (double) iround;
1717  if(rratio < 0)
1718  rratio=-rratio;
1719  double cratio = ip.get_j() - (double) jround;
1720  if(cratio < 0)
1721  cratio=-cratio;
1722 
1723  rfrac = 1.0f - rratio;
1724  cfrac = 1.0f - cratio;
1725 
1726  double valueR = ((double)row[iround][jround].R * rfrac + (double)row[iround+1][jround].R * rratio)*cfrac
1727  + ((double)row[iround][jround+1].R * rfrac + (double)row[iround+1][jround+1].R * rratio)*cratio;
1728  double valueG = ((double)row[iround][jround].G * rfrac + (double)row[iround+1][jround].G * rratio)*cfrac
1729  + ((double)row[iround][jround+1].G* rfrac + (double)row[iround+1][jround+1].G * rratio)*cratio;
1730  double valueB = ((double)row[iround][jround].B * rfrac + (double)row[iround+1][jround].B * rratio)*cfrac
1731  + ((double)row[iround][jround+1].B*rfrac + (double)row[iround+1][jround+1].B * rratio)*cratio;
1732  return vpRGBa((unsigned char)vpMath::round(valueR),(unsigned char)vpMath::round(valueG),(unsigned char)vpMath::round(valueB));
1733 }
1734 
1764 template<class Type>
1766 {
1767 
1768  try
1769  {
1770  if ((this->getHeight() != C.getHeight())
1771  || (this->getWidth() != C.getWidth()))
1772  C.resize(this->getHeight(), this->getWidth());
1773  }
1774  catch(vpException &me)
1775  {
1776  vpERROR_TRACE("Error caught") ;
1777  std::cout << me << std::endl ;
1778  throw ;
1779  }
1780 
1781  if ( (this->getWidth() != B.getWidth())||(this->getHeight() != B.getHeight()))
1782  {
1783  vpERROR_TRACE("\n\t\t vpImage mismatch in vpImage/vpImage substraction") ;
1785  "vpImage mismatch in vpImage/vpImage substraction ")) ;
1786  }
1787 
1788  for (unsigned int i=0;i<this->getWidth()*this->getHeight();i++)
1789  {
1790  *(C.bitmap + i) = *(bitmap + i) - *(B.bitmap + i) ;
1791  }
1792 }
1793 
1805 template<class Type>
1807  vpImage<Type> &C)
1808 {
1809 
1810  try
1811  {
1812  if ((A.getHeight() != C.getHeight())
1813  || (A.getWidth() != C.getWidth()))
1814  C.resize(A.getHeight(), A.getWidth());
1815  }
1816  catch(vpException &me)
1817  {
1818  vpERROR_TRACE("Error caught") ;
1819  std::cout << me << std::endl ;
1820  throw ;
1821  }
1822 
1823  if ( (A.getWidth() != B.getWidth())||(A.getHeight() != B.getHeight()))
1824  {
1825  vpERROR_TRACE("\n\t\t vpImage mismatch in vpImage/vpImage substraction") ;
1827  "vpImage mismatch in vpImage/vpImage substraction ")) ;
1828  }
1829 
1830  for (unsigned int i=0;i<A.getWidth()*A.getHeight();i++)
1831  {
1832  *(C.bitmap + i) = *(A.bitmap + i) - *(B.bitmap + i) ;
1833  }
1834 }
1835 
1845 template<class Type>
1846 void vpImage<Type>::performLut(const Type (&)[256], const unsigned int)
1847 {
1848 // vpTRACE("Not implemented");
1849  std::cerr << "Not implemented !" << std::endl;
1850 }
1851 
1858 template<>
1859 inline void vpImage<unsigned char>::performLut(const unsigned char (&lut)[256], const unsigned int nbThreads) {
1860  unsigned int size = getWidth()*getHeight();
1861  unsigned char *ptrStart = (unsigned char*) bitmap;
1862  unsigned char *ptrEnd = ptrStart + size;
1863  unsigned char *ptrCurrent = ptrStart;
1864 
1865 
1866  bool use_single_thread = (nbThreads == 0 || nbThreads == 1);
1867 #if !defined(VISP_HAVE_PTHREAD) && !defined(_WIN32)
1868  use_single_thread = true;
1869 #endif
1870 
1871  if(!use_single_thread && getSize() <= nbThreads) {
1872  use_single_thread = true;
1873  }
1874 
1875 
1876  if(use_single_thread) {
1877  //Single thread
1878 
1879  while(ptrCurrent != ptrEnd) {
1880  *ptrCurrent = lut[*ptrCurrent];
1881  ++ptrCurrent;
1882  }
1883  } else {
1884 #if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0))
1885  //Multi-threads
1886 
1887  std::vector<vpThread *> threadpool;
1888  std::vector<ImageLut_Param_t *> imageLutParams;
1889 
1890  ImageLut_Param_t *imageLut_param = NULL;
1891  vpThread *imageLut_thread = NULL;
1892 
1893  unsigned int image_size = getSize();
1894  unsigned int step = image_size / nbThreads;
1895  unsigned int last_step = image_size - step * (nbThreads-1);
1896 
1897  for(unsigned int index = 0; index < nbThreads; index++) {
1898  unsigned int start_index = index*step;
1899  unsigned int end_index = (index+1)*step;
1900 
1901  if(index == nbThreads-1) {
1902  end_index = start_index+last_step;
1903  }
1904 
1905  imageLut_param = new ImageLut_Param_t(start_index, end_index, bitmap);
1906  memcpy(imageLut_param->m_lut, lut, 256*sizeof(unsigned char));
1907 
1908  imageLutParams.push_back(imageLut_param);
1909 
1910  // Start the threads
1911  imageLut_thread = new vpThread((vpThread::Fn) performLutThread, (vpThread::Args) imageLut_param);
1912  threadpool.push_back(imageLut_thread);
1913  }
1914 
1915  for(size_t cpt = 0; cpt < threadpool.size(); cpt++) {
1916  // Wait until thread ends up
1917  threadpool[cpt]->join();
1918  }
1919 
1920 
1921  //Delete
1922  for(size_t cpt = 0; cpt < threadpool.size(); cpt++) {
1923  delete threadpool[cpt];
1924  }
1925 
1926  for(size_t cpt = 0; cpt < imageLutParams.size(); cpt++) {
1927  delete imageLutParams[cpt];
1928  }
1929 #endif
1930  }
1931 }
1932 
1939 template<>
1940 inline void vpImage<vpRGBa>::performLut(const vpRGBa (&lut)[256], const unsigned int nbThreads) {
1941  unsigned int size = getWidth()*getHeight();
1942  unsigned char *ptrStart = (unsigned char*) bitmap;
1943  unsigned char *ptrEnd = ptrStart + size*4;
1944  unsigned char *ptrCurrent = ptrStart;
1945 
1946 
1947  bool use_single_thread = (nbThreads == 0 || nbThreads == 1);
1948 #if !defined(VISP_HAVE_PTHREAD) && !defined(_WIN32)
1949  use_single_thread = true;
1950 #endif
1951 
1952  if(!use_single_thread && getSize() <= nbThreads) {
1953  use_single_thread = true;
1954  }
1955 
1956 
1957  if(use_single_thread) {
1958  //Single thread
1959  while(ptrCurrent != ptrEnd) {
1960  *ptrCurrent = lut[*ptrCurrent].R;
1961  ++ptrCurrent;
1962 
1963  *ptrCurrent = lut[*ptrCurrent].G;
1964  ++ptrCurrent;
1965 
1966  *ptrCurrent = lut[*ptrCurrent].B;
1967  ++ptrCurrent;
1968 
1969  *ptrCurrent = lut[*ptrCurrent].A;
1970  ++ptrCurrent;
1971  }
1972  } else {
1973 #if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0))
1974  //Multi-threads
1975  std::vector<vpThread *> threadpool;
1976  std::vector<ImageLutRGBa_Param_t *> imageLutParams;
1977 
1978  ImageLutRGBa_Param_t *imageLut_param = NULL;
1979  vpThread *imageLut_thread = NULL;
1980 
1981  unsigned int image_size = getSize();
1982  unsigned int step = image_size / nbThreads;
1983  unsigned int last_step = image_size - step * (nbThreads-1);
1984 
1985  for(unsigned int index = 0; index < nbThreads; index++) {
1986  unsigned int start_index = index*step;
1987  unsigned int end_index = (index+1)*step;
1988 
1989  if(index == nbThreads-1) {
1990  end_index = start_index+last_step;
1991  }
1992 
1993  imageLut_param = new ImageLutRGBa_Param_t(start_index, end_index, (unsigned char *) bitmap);
1994  memcpy(imageLut_param->m_lut, lut, 256*sizeof(vpRGBa));
1995 
1996  imageLutParams.push_back(imageLut_param);
1997 
1998  // Start the threads
1999  imageLut_thread = new vpThread((vpThread::Fn) performLutRGBaThread, (vpThread::Args) imageLut_param);
2000  threadpool.push_back(imageLut_thread);
2001  }
2002 
2003  for(size_t cpt = 0; cpt < threadpool.size(); cpt++) {
2004  // Wait until thread ends up
2005  threadpool[cpt]->join();
2006  }
2007 
2008 
2009  //Delete
2010  for(size_t cpt = 0; cpt < threadpool.size(); cpt++) {
2011  delete threadpool[cpt];
2012  }
2013 
2014  for(size_t cpt = 0; cpt < imageLutParams.size(); cpt++) {
2015  delete imageLutParams[cpt];
2016  }
2017 #endif
2018  }
2019 }
2020 
2021 #endif
void quarterSizeImage(vpImage< Type > &res) const
Definition: vpImage.h:1374
unsigned int getCols() const
Definition: vpImage.h:166
vpDisplay * display
Definition: vpImage.h:135
void doubleSizeImage(vpImage< Type > &res)
Definition: vpImage.h:1419
Class that defines generic functionnalities for display.
Definition: vpDisplay.h:169
void * Return
Definition: vpThread.h:36
double get_i() const
Definition: vpImagePoint.h:199
unsigned int getWidth() const
Definition: vpImage.h:226
void init(unsigned int height, unsigned int width)
Set the size of the image.
Definition: vpImage.h:664
Type operator()(const unsigned int i, const unsigned int j) const
Definition: vpImage.h:257
void getMinMaxValue(Type &min, Type &max) const
Look for the minimum and the maximum value within the bitmap.
Definition: vpImage.h:1055
Type * bitmap
points toward the bitmap
Definition: vpImage.h:134
#define vpERROR_TRACE
Definition: vpDebug.h:391
Type operator()(const vpImagePoint &ip) const
Definition: vpImage.h:282
error that can be emited by ViSP classes.
Definition: vpException.h:73
Type getValue(double i, double j) const
Definition: vpImage.h:1477
Type getMinValue() const
Return the minimum value within the bitmap.
Definition: vpImage.h:1039
Type * operator[](const unsigned int i)
operator[] allows operation like I[i] = x.
Definition: vpImage.h:243
virtual ~vpImage()
destructor
Definition: vpImage.h:990
void *(* Fn)(Args)
Definition: vpThread.h:37
static int round(const double x)
Definition: vpMath.h:249
double get_j() const
Definition: vpImagePoint.h:210
Definition: vpRGBa.h:66
unsigned int getRows() const
Definition: vpImage.h:204
void set_i(const double ii)
Definition: vpImagePoint.h:163
vpImage< Type > & operator=(const vpImage< Type > &I)
Copy operator.
Definition: vpImage.h:1069
unsigned int getSize() const
Definition: vpImage.h:212
bool operator!=(const vpImage< Type > &I)
Definition: vpImage.h:1167
void * Args
Definition: vpThread.h:35
void operator()(const vpImagePoint &ip, const Type &v)
Definition: vpImage.h:298
Type getMaxValue() const
Return the maximum value within the bitmap.
Definition: vpImage.h:1023
const Type * operator[](int i) const
Definition: vpImage.h:248
unsigned int getNumberOfPixel() const
Definition: vpImage.h:194
void resize(const unsigned int h, const unsigned int w)
resize the image : Image initialization
Definition: vpImage.h:903
void destroy()
Destructor : Memory de-allocation.
Definition: vpImage.h:959
const Type * operator[](unsigned int i) const
operator[] allows operation like x = I[i]
Definition: vpImage.h:247
void set_j(const double jj)
Definition: vpImagePoint.h:174
void subsample(unsigned int v_scale, unsigned int h_scale, vpImage< Type > &sampled) const
Definition: vpImage.h:1338
void halfSizeImage(vpImage< Type > &res) const
Definition: vpImage.h:1309
void insert(const vpImage< Type > &src, const vpImagePoint topLeft)
Definition: vpImage.h:1226
Type * operator[](const int i)
Definition: vpImage.h:244
vpImage< Type > operator-(const vpImage< Type > &B)
Definition: vpImage.h:1209
#define vpDEBUG_TRACE
Definition: vpDebug.h:478
unsigned int getHeight() const
Definition: vpImage.h:175
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88
void operator()(const unsigned int i, const unsigned int j, const Type &v)
Definition: vpImage.h:266
void performLut(const Type(&lut)[256], const unsigned int nbThreads=1)
Definition: vpImage.h:1846
vpImage()
constructor
Definition: vpImage.h:876
Definition of the vpImage class member functions.
Definition: vpImage.h:117
bool operator==(const vpImage< Type > &I)
Definition: vpImage.h:1144
void sub(const vpImage< Type > &B, vpImage< Type > &C)
Definition: vpImage.h:1765