133 CImage(
unsigned int width,
136 bool originTopLeft = true
140 CImage( const CImage &o );
165 else this->setFromImageReadOnly(other_img);
176 template <
typename Derived>
177 explicit inline CImage(
const Eigen::MatrixBase<Derived> &m,
bool matrix_is_normalized)
179 this->setFromMatrix(m,matrix_is_normalized);
221 changeSize(width,height,nChannels,originTopLeft);
237 void rotateImage(
double angle_radians,
unsigned int center_x,
unsigned int center_y,
double scale = 1.0 );
246 void setPixel(
int x,
int y,
size_t color);
250 void setOriginTopLeft(
bool val);
267 unsigned int width = 1,
268 TPenStyle penStyle = psSolid);
282 unsigned int width = 1);
284 void equalizeHistInPlace();
285 void equalizeHist(
CImage &outImg )
const;
294 this->scaleHalf(ret);
299 void scaleHalf(
CImage &out_image)
const;
309 this->scaleHalfSmooth(ret);
314 void scaleHalfSmooth(
CImage &out_image)
const;
324 this->scaleDouble(ret);
329 void scaleDouble(
CImage &out_image)
const;
338 void update_patch(
const CImage &patch,
339 const unsigned int col,
340 const unsigned int row);
348 const unsigned int col=0,
349 const unsigned int row=0,
350 const unsigned int width=1,
351 const unsigned int height=1 )
const;
358 float correlate(
const CImage &img2int,
int width_init=0,
int height_init=0 )
const;
374 void cross_correlation(
381 int u_search_size=-1,
382 int v_search_size=-1,
383 CImage *out_corr_image = NULL
405 int u_search_size=-1,
406 int v_search_size=-1,
407 float biasThisImg = 0,
421 void flipVertical(
bool also_swapRB =
false);
446 rectifyImage(out_img,cam);
465 rectifyImageInPlace(cam);
472 void rectifyImageInPlace(
void *mapX,
void *mapY );
475 void filterMedian(
CImage &out_img,
int W=3 )
const;
478 void filterMedianInPlace(
int W=3 );
481 void filterGaussianInPlace(
int W = 3,
int H = 3 );
484 void filterGaussian(
CImage &out_img,
int W = 3,
int H = 3)
const;
496 bool drawChessboardCorners(
497 std::vector<TPixelCoordf> &cornerCoords,
498 unsigned int check_size_x,
499 unsigned int check_size_y );
515 const unsigned int x,
516 const unsigned int y,
517 const unsigned int half_window_size )
const;
537 void copyFromForceLoad(
const CImage &o);
542 void copyFastFrom(
CImage &o );
555 template <
typename T>
inline const T*
getAs()
const {
556 makeSureImageIsLoaded();
557 return static_cast<const T*
>(img);
560 template <
typename T>
inline T*
getAs(){
561 makeSureImageIsLoaded();
562 return static_cast<T*
>(img);
571 inline void* getAsIplImage()
const )
573 makeSureImageIsLoaded();
583 unsigned int channel=0)
const;
590 float getAsFloat(
unsigned int col,
unsigned int row,
unsigned int channel)
const;
597 float getAsFloat(
unsigned int col,
unsigned int row)
const;
603 unsigned char* operator()(
unsigned int col,
unsigned int row,
unsigned int channel = 0)
const;
617 size_t getWidth()
const;
622 size_t getHeight()
const;
641 size_t getRowStride()
const;
646 float getMaxAsFloat()
const;
649 bool isColor()
const;
652 bool isOriginTopLeft()
const;
655 const char * getChannelsOrder()
const;
658 void setChannelsOrder_RGB();
660 void setChannelsOrder_BGR();
677 bool doResize =
true,
712 void setExternalStorage(
const std::string &fileName )
MRPT_NO_THROWS;
719 inline std::string getExternalStorageFile() const MRPT_NO_THROWS
721 return m_externalFile;
725 void getExternalStorageFileAbsolutePath(std::string &out_path)
const;
730 getExternalStorageFileAbsolutePath(tmp);
744 void unload() MRPT_NO_THROWS;
756 void loadFromMemoryBuffer(
unsigned int width,
unsigned int height,
bool color,
unsigned char *rawpixels,
bool swapRedBlue = false );
761 void loadFromMemoryBuffer(
unsigned int width,
unsigned int height,
unsigned int bytesPerRow,
unsigned char *red,
unsigned char *green,
unsigned char *blue );
765 void loadFromIplImage(
void* iplImage );
772 void setFromIplImage(
void* iplImage );
779 void setFromIplImageReadOnly(
void* iplImage );
785 inline
void setFromImageReadOnly( const
CImage &other_img ) { setFromIplImageReadOnly(const_cast<void*>(other_img.getAs<
void>()) ); }
790 template <
typename Derived>
791 void setFromMatrix(
const Eigen::MatrixBase<Derived> &m,
bool matrix_is_normalized=
true)
794 makeSureImageIsLoaded();
796 const unsigned int lx = m.cols();
797 const unsigned int ly = m.rows();
798 this->changeSize(lx,ly,1,
true);
799 if (matrix_is_normalized) {
800 for (
unsigned int y=0;y<ly;y++) {
801 unsigned char *pixels = this->
get_unsafe(0,y,0);
802 for (
unsigned int x=0;x<lx;x++)
803 (*pixels++) =
static_cast<unsigned char>( m.get_unsafe(y,x) * 255 );
807 for (
unsigned int y=0;y<ly;y++) {
808 unsigned char *pixels = this->
get_unsafe(0,y,0);
809 for (
unsigned int x=0;x<lx;x++)
810 (*pixels++) =
static_cast<unsigned char>( m.get_unsafe(y,x) );
819 void loadFromStreamAsJPEG(
CStream &in );
839 bool loadFromFile(
const std::string& fileName,
int isColor = -1 );
858 bool saveToFile(
const std::string& fileName,
int jpeg_quality = 95 )
const;
864 void saveToStreamAsJPEG(
CStream &out,
const int jpeg_quality = 95 )
const;
881 void grayscale(
CImage &ret )
const;
886 void colorImage(
CImage &ret )
const;
891 void colorImageInPlace();
897 void grayscaleInPlace();
926 bool originTopLeft );
929 void releaseIpl(
bool thisIsExternalImgUnload =
false) MRPT_NO_THROWS;