#include <mrpt/utils/CImage.h>
Public Member Functions | |
void | resize (unsigned int width, unsigned int height, unsigned int nChannels, bool originTopLeft) |
Changes the size of the image, erasing previous contents (does NOT scale its current content, for that, see scaleImage). | |
void | scaleImage (unsigned int width, unsigned int height, TInterpMethod interp=IMG_INTERP_CUBIC) |
Scales the image to a new size, interpolating as needed. | |
void | rotateImage (double angle_radians, unsigned int center_x, unsigned int center_y, double scale=1.0) |
Rotates the image by the given angle around the given center point, with an optional scale factor. | |
void | setPixel (int x, int y, size_t color) |
Changes the value of the pixel (x,y). | |
void | drawCircle (int x, int y, int radius, const mrpt::utils::TColor &color=mrpt::utils::TColor(255, 255, 255), unsigned int width=1) |
Draws a circle of a given radius. | |
CImage () | |
Default constructor:. | |
CImage (unsigned int width, unsigned int height, unsigned int nChannels=3, bool originTopLeft=true) | |
Constructor:. | |
CImage (const CImage &o) | |
Copy constructor:. | |
CImage (const CImageFloat &o) | |
Copy constructor:. | |
CImage & | operator= (const CImage &o) |
Copy operator. | |
CImage & | operator= (const CImageFloat &o) |
Copy operator from a gray-scale, float image:. | |
void | copyFastFrom (CImage &o) |
Moves an image from another object, erasing the origin image in the process (this is much faster than copying). | |
CImage (void *iplImage) | |
Constructor from IplImage. | |
virtual | ~CImage () |
Destructor:. | |
void * | getAsIplImage () const |
Returns a pointer to an "OpenCv" IplImage struct containing the image, which is linked to this class: free neigther that pointer nor this class until they are not required anymore, since this class is in charge of freeing the memory buffers inside of the returned image. | |
unsigned char * | get_unsafe (unsigned int col, unsigned int row, unsigned int channel=0) const |
Access to pixels without checking boundaries - Use normally the () operator better, which checks the coordinates. | |
float | getAsFloat (unsigned int col, unsigned int row, unsigned int channel) const |
Returns the contents of a given pixel at the desired channel, in float format: [0,255]->[0,1] The coordinate origin is pixel(0,0)=top-left corner of the image. | |
float | getAsFloat (unsigned int col, unsigned int row) const |
Returns the contents of a given pixel (for gray-scale images, in color images the gray scale equivalent is computed for the pixel), in float format: [0,255]->[0,1] The coordinate origin is pixel(0,0)=top-left corner of the image. | |
float | getMaxAsFloat () const |
Return the maximum pixel value of the image, as a float value. | |
size_t | getWidth () const |
Returns the width of the image in pixels. | |
size_t | getHeight () const |
Returns the height of the image in pixels. | |
void | getSize (TImageSize &s) const |
Return the size of the image. | |
TImageSize | getSize () const |
Return the size of the image. | |
bool | isColor () const |
Returns true if the image is RGB, false if it is gray scale. | |
bool | isOriginTopLeft () const |
Returns true if the coordinates origin is top-left, or false if it is bottom-left. | |
void | setOriginTopLeft (bool val) |
Changes the property of the image stating if the top-left corner (vs. | |
void | loadFromMemoryBuffer (unsigned int width, unsigned int height, bool color, unsigned char *rawpixels, bool swapRedBlue=false) |
Reads the image from raw pixels buffer in memory. | |
void | loadFromMemoryBuffer (unsigned int width, unsigned int height, unsigned int bytesPerRow, unsigned char *red, unsigned char *green, unsigned char *blue) |
Reads a color image from three raw pixels buffers in memory. | |
void | loadFromIplImage (void *iplImage) |
Reads the image from a OpenCV IplImage object (making a copy). | |
void | setFromIplImage (void *iplImage) |
Reads the image from a OpenCV IplImage object (WITHOUT making a copy). | |
void | setFromIplImageReadOnly (void *iplImage) |
Reads the image from a OpenCV IplImage object (WITHOUT making a copy) and from now on the image cannot be modified, just read. | |
void | setExternalStorage (const std::string &fileName) MRPT_NO_THROWS |
By using this method the image is marked as referenced to an external file, which will be loaded only under demand. | |
bool | isExternallyStored () const MRPT_NO_THROWS |
See setExternalStorage(). | |
std::string | getExternalStorageFile () const MRPT_NO_THROWS |
< Only if isExternallyStored() returns true. | |
void | getExternalStorageFileAbsolutePath (std::string &out_path) const |
Only if isExternallyStored() returns true. | |
void | unload () MRPT_NO_THROWS |
For external storage image objects only, this method unloads the image from memory (or does nothing if already unloaded). | |
void | loadFromStreamAsJPEG (CStream &in) |
Reads the image from a binary stream containing a binary jpeg file. | |
bool | loadFromFile (const std::string &fileName, int isColor=-1) |
Load image from a file, whose format is determined from the extension (internally uses OpenCV). | |
bool | saveToFile (const std::string &fileName) const |
Save the image to a file, whose format is determined from the extension (internally uses OpenCV). | |
void | saveToStreamAsJPEG (CStream &out) const |
Save image to binary stream as a JPEG (.jpg) compresed format. | |
unsigned char * | operator() (unsigned int col, unsigned int row, unsigned int channel=0) const |
Returns a pointer to a given pixel information. | |
CImage | grayscale () const |
Returns a grayscale version of the image, or itself if it is already a grayscale image. | |
void | grayscale (CImage &ret) const |
Returns a grayscale version of the image, or itself if it is already a grayscale image. | |
void | grayscaleInPlace () |
Replaces the image with a grayscale version of it. | |
void | colorImage (CImage &ret) const |
Returns a RGB version of the grayscale image, or itself if it is already a RGB image. | |
void | colorImageInPlace () |
Replaces this grayscale image with a RGB version of it. | |
CImage | scaleHalf () const |
Returns a new image scaled down to half its original size. | |
CImage | scaleDouble () const |
Returns a new image scaled up to double its original size. | |
const char * | getChannelsOrder () const |
Returns a string of the form "BGR" indicating the channels ordering. | |
unsigned int | getChannelCount () const |
Returns the number of channels (typ: 1 or 3). | |
void | extract_patch (CImage &patch, const unsigned int col_=0, const unsigned int row_=0, const unsigned int col_num=1, const unsigned int row_num=1) const |
Extracts a patch of this image into another image. | |
float | correlate (const CImage &img2int, int width_init=0, int height_init=0) const |
Computes the correlation coefficient (returned as val), between two images This function use grayscale images only img1, img2 must be same size (by AJOGD @ DEC-2006). | |
void | cross_correlation (CImage &img2, math::CMatrixFloat &M, const int &u_search_ini, const int &v_search_ini, const int &u_search_size, const int &v_search_size) const |
Computes the cross_correlation between two images and return a matrix of correlation coeficients This function use grayscale images only (by AJOGD @ DEC-2006). | |
void | cross_correlation_FFT (const CImage &in_img, math::CMatrixFloat &out_corr, int u_search_ini=-1, int v_search_ini=-1, int u_search_size=-1, int v_search_size=-1, float biasThisImg=0, float biasInImg=0) const |
Computes the correlation matrix between this image and another one. | |
void | getAsMatrix (mrpt::math::CMatrixFloat &outMatrix, bool doResize=true, int x_min=0, int y_min=0, int x_max=-1, int y_max=-1) const |
Returns the image as a matrix with pixel grayscale values in the range [0,1]. | |
void | setFromMatrix (const mrpt::math::CMatrixFloat &m, bool matrix_is_normalized=true) |
Set the image from a matrix, interpreted as grayscale intensity values, in the range [0,1] (normalized=true) or [0,255] (normalized=false). | |
void | setFromMatrix (const mrpt::math::CMatrixDouble &m, bool matrix_is_normalized=true) |
Set the image from a matrix, interpreted as grayscale intensity values, in the range [0,1] (normalized=true) or [0,255] (normalized=false). | |
void | getAsMatrixTiled (math::CMatrix &outMatrix) const |
Returns the image as a matrix, where the image is "tiled" (repeated) the required number of times to fill the entire size of the matrix on input. | |
void | normalize () |
Optimize de brightness range of a image without using histogram Only for one channel images. | |
void | openCV_cross_correlation (const CImage &patch_img, size_t &u_max, size_t &v_max, double &max_val, int u_search_ini=-1, int v_search_ini=-1, int u_search_size=-1, int v_search_size=-1) const |
Computes the correlation between this image and another one, encapsulating the openCV function cvMatchTemplate This implementation reduced computation time. | |
void | flipVertical (bool also_swapRB=false) |
Flips vertically the image. | |
void | swapRB () |
Swaps red and blue channels. | |
template<class T1 , class T2 > | |
void | rectifyImage (CImage &out_img, const math::CMatrixTemplateNumeric< T1 > &cameraMatrix, const math::CMatrixTemplateNumeric< T2 > &distCoeff) const |
Rectifies the image according to a certain camera matrix and vector of distortion coefficients and returns an output rectified image. | |
template<class T1 , class T2 > | |
void | rectifyImageInPlace (const math::CMatrixTemplateNumeric< T1 > &cameraMatrix, const math::CMatrixTemplateNumeric< T2 > &distCoeff) |
Rectifies the image according to a certain camera matrix and vector of distortion coefficients, replacing "this"· with the rectified image. | |
template<class T1 , class T2 > | |
void | rectifyImage (CImage &out_img, const math::CMatrixTemplateNumeric< T1 > &cameraMatrix, const std::vector< T2 > &distCoeff) const |
Rectifies the image according to a certain camera matrix and vector of distortion coefficients and returns an output rectified image. | |
template<class T1 , class T2 > | |
void | rectifyImageInPlace (const math::CMatrixTemplateNumeric< T1 > &cameraMatrix, const std::vector< T2 > &distCoeff) |
Rectifies the image according to a certain camera matrix and vector of distortion coefficients, replacing "this"· with the rectified image. | |
void | filterMedian (CImage &out_img, int W=3) const |
Filter the image with a Median filter with a window size WxW, returning the filtered image in out_img. | |
void | filterMedianInPlace (int W=3) |
Filter the image with a Median filter with a window size WxH, replacing "this" image by the filtered one. | |
void | filterGaussianInPlace (int W=3, int H=3) |
Filter the image with a Gaussian filter with a window size WxH, returning the filtered image in out_img. | |
void | filterGaussian (CImage &out_img, int W=3, int H=3) const |
Filter the image with a Gaussian filter with a window size WxH, replacing "this" image by the filtered one. | |
bool | findChessboardCorners (std::vector< TPixelCoordf > &cornerCoords, unsigned int check_size_x, unsigned int check_size_y, bool normalize_image=true) const |
Look for the corners of a chessboard in the image. | |
bool | drawChessboardCorners (std::vector< TPixelCoordf > &cornerCoords, unsigned int check_size_x, unsigned int check_size_y) |
Draw onto this image the detected corners of a chessboard. | |
void | joinImagesHorz (const CImage &im1, const CImage &im2) |
Joins two images side-by-side horizontally. | |
Static Public Attributes | |
static bool | DISABLE_ZIP_COMPRESSION |
By default, when storing images through the CSerializable interface, grayscale images will be ZIP compressed if they are larger than 16Kb: this flag can be turn on to disable ZIP compression and gain speed versus occupied space. | |
static std::string | IMAGES_PATH_BASE |
By default, ".". | |
Protected Member Functions | |
void | changeSize (unsigned int width, unsigned int height, unsigned int nChannels, bool originTopLeft) |
Resize the buffers in "img" to accomodate a new image size and/or format. | |
void | releaseIpl (bool thisIsExternalImgUnload=false) MRPT_NO_THROWS |
Release the internal IPL image, if not NULL or read-only. | |
void | makeSureImageIsLoaded () const throw (std::exception,utils::CExceptionExternalImageNotFound ) |
Checks if the image is of type "external storage", and if so and not loaded yet, load it. | |
void | rectifyImage_internal (CImage &out_img, const math::CMatrixDouble &cameraMatrix, const vector_double &distCoeff) const |
void | rectifyImageInPlace_internal (const math::CMatrixDouble &cameraMatrix, const vector_double &distCoeff) |
Protected Attributes | |
void * | img |
Data members. | |
bool | m_imgIsReadOnly |
Set to true only when using setFromIplImageReadOnly. | |
bool | m_imgIsExternalStorage |
Set to true only when using setExternalStorage. | |
std::string | m_externalFile |
The file name of a external storage image. | |
Friends | |
class | CImageFloat |
File I/O is supported in two different ways:
Additional notes:
CImagePtr myImgPtr = CImagePtr( new CImage(...) );
Additional implementated operators:
Definition at line 84 of file CImage.h.
mrpt::utils::CImage::CImage | ( | ) |
Default constructor:.
mrpt::utils::CImage::CImage | ( | unsigned int | width, | |
unsigned int | height, | |||
unsigned int | nChannels = 3 , |
|||
bool | originTopLeft = true | |||
) |
Constructor:.
mrpt::utils::CImage::CImage | ( | const CImage & | o | ) |
Copy constructor:.
mrpt::utils::CImage::CImage | ( | const CImageFloat & | o | ) |
Copy constructor:.
mrpt::utils::CImage::CImage | ( | void * | iplImage | ) |
Constructor from IplImage.
virtual mrpt::utils::CImage::~CImage | ( | ) | [virtual] |
Destructor:.
void mrpt::utils::CImage::changeSize | ( | unsigned int | width, | |
unsigned int | height, | |||
unsigned int | nChannels, | |||
bool | originTopLeft | |||
) | [protected] |
Resize the buffers in "img" to accomodate a new image size and/or format.
void mrpt::utils::CImage::colorImage | ( | CImage & | ret | ) | const |
Returns a RGB version of the grayscale image, or itself if it is already a RGB image.
void mrpt::utils::CImage::colorImageInPlace | ( | ) |
void mrpt::utils::CImage::copyFastFrom | ( | CImage & | o | ) |
Moves an image from another object, erasing the origin image in the process (this is much faster than copying).
float mrpt::utils::CImage::correlate | ( | const CImage & | img2int, | |
int | width_init = 0 , |
|||
int | height_init = 0 | |||
) | const |
Computes the correlation coefficient (returned as val), between two images This function use grayscale images only img1, img2 must be same size (by AJOGD @ DEC-2006).
void mrpt::utils::CImage::cross_correlation | ( | CImage & | img2, | |
math::CMatrixFloat & | M, | |||
const int & | u_search_ini, | |||
const int & | v_search_ini, | |||
const int & | u_search_size, | |||
const int & | v_search_size | |||
) | const |
Computes the cross_correlation between two images and return a matrix of correlation coeficients This function use grayscale images only (by AJOGD @ DEC-2006).
void mrpt::utils::CImage::cross_correlation_FFT | ( | const CImage & | in_img, | |
math::CMatrixFloat & | out_corr, | |||
int | u_search_ini = -1 , |
|||
int | v_search_ini = -1 , |
|||
int | u_search_size = -1 , |
|||
int | v_search_size = -1 , |
|||
float | biasThisImg = 0 , |
|||
float | biasInImg = 0 | |||
) | const |
Computes the correlation matrix between this image and another one.
This implementation uses the 2D FFT for achieving reduced computation time.
in_img | The "patch" image, which must be equal, or smaller than "this" image. This function supports gray-scale (1 channel only) images. | |
u_search_ini | The "x" coordinate of the search window. | |
v_search_ini | The "y" coordinate of the search window. | |
u_search_size | The width of the search window. | |
v_search_size | The height of the search window. | |
out_corr | The output for the correlation matrix, which will be "u_search_size" x "v_search_size" | |
biasThisImg | This optional parameter is a fixed "bias" value to be substracted to the pixels of "this" image before performing correlation. | |
biasInImg | This optional parameter is a fixed "bias" value to be substracted to the pixels of "in_img" image before performing correlation. Note: By default, the search area is the whole (this) image. (by JLBC @ JAN-2006) |
bool mrpt::utils::CImage::drawChessboardCorners | ( | std::vector< TPixelCoordf > & | cornerCoords, | |
unsigned int | check_size_x, | |||
unsigned int | check_size_y | |||
) |
Draw onto this image the detected corners of a chessboard.
The length of cornerCoords must be the product of the two check_sizes.
cornerCoords | [IN] The pixel coordinates of all the corners. | |
check_size_x | [IN] The number of squares, in the X direction | |
check_size_y | [IN] The number of squares, in the Y direction |
void mrpt::utils::CImage::drawCircle | ( | int | x, | |
int | y, | |||
int | radius, | |||
const mrpt::utils::TColor & | color = mrpt::utils::TColor(255, 255, 255) , |
|||
unsigned int | width = 1 | |||
) | [virtual] |
Draws a circle of a given radius.
x | The center - x coordinate in pixels. | |
y | The center - y coordinate in pixels. | |
radius | The radius - in pixels. | |
color | The color of the circle. | |
width | The desired width of the line |
Reimplemented from mrpt::utils::CCanvas.
void mrpt::utils::CImage::extract_patch | ( | CImage & | patch, | |
const unsigned int | col_ = 0 , |
|||
const unsigned int | row_ = 0 , |
|||
const unsigned int | col_num = 1 , |
|||
const unsigned int | row_num = 1 | |||
) | const |
Extracts a patch of this image into another image.
(by AJOGD @ DEC-2006)
Referenced by mrpt::monoslam::CFeaturePatch::set_patch().
void mrpt::utils::CImage::filterGaussian | ( | CImage & | out_img, | |
int | W = 3 , |
|||
int | H = 3 | |||
) | const |
Filter the image with a Gaussian filter with a window size WxH, replacing "this" image by the filtered one.
void mrpt::utils::CImage::filterGaussianInPlace | ( | int | W = 3 , |
|
int | H = 3 | |||
) |
Filter the image with a Gaussian filter with a window size WxH, returning the filtered image in out_img.
void mrpt::utils::CImage::filterMedian | ( | CImage & | out_img, | |
int | W = 3 | |||
) | const |
Filter the image with a Median filter with a window size WxW, returning the filtered image in out_img.
void mrpt::utils::CImage::filterMedianInPlace | ( | int | W = 3 |
) |
Filter the image with a Median filter with a window size WxH, replacing "this" image by the filtered one.
bool mrpt::utils::CImage::findChessboardCorners | ( | std::vector< TPixelCoordf > & | cornerCoords, | |
unsigned int | check_size_x, | |||
unsigned int | check_size_y, | |||
bool | normalize_image = true | |||
) | const |
Look for the corners of a chessboard in the image.
This method uses internally OpenCV functions:
cornerCoords | [OUT] The pixel coordinates of all the corners. | |
check_size_x | [IN] The number of squares, in the X direction | |
check_size_y | [IN] The number of squares, in the Y direction | |
normalize_image | [IN] Whether to normalize the image before detection |
void mrpt::utils::CImage::flipVertical | ( | bool | also_swapRB = false |
) |
unsigned char* mrpt::utils::CImage::get_unsafe | ( | unsigned int | col, | |
unsigned int | row, | |||
unsigned int | channel = 0 | |||
) | const |
Access to pixels without checking boundaries - Use normally the () operator better, which checks the coordinates.
float mrpt::utils::CImage::getAsFloat | ( | unsigned int | col, | |
unsigned int | row | |||
) | const |
Returns the contents of a given pixel (for gray-scale images, in color images the gray scale equivalent is computed for the pixel), in float format: [0,255]->[0,1] The coordinate origin is pixel(0,0)=top-left corner of the image.
std::exception | On pixel coordinates out of bounds |
float mrpt::utils::CImage::getAsFloat | ( | unsigned int | col, | |
unsigned int | row, | |||
unsigned int | channel | |||
) | const |
Returns the contents of a given pixel at the desired channel, in float format: [0,255]->[0,1] The coordinate origin is pixel(0,0)=top-left corner of the image.
std::exception | On pixel coordinates out of bounds |
void* mrpt::utils::CImage::getAsIplImage | ( | ) | const |
Returns a pointer to an "OpenCv" IplImage struct containing the image, which is linked to this class: free neigther that pointer nor this class until they are not required anymore, since this class is in charge of freeing the memory buffers inside of the returned image.
void mrpt::utils::CImage::getAsMatrix | ( | mrpt::math::CMatrixFloat & | outMatrix, | |
bool | doResize = true , |
|||
int | x_min = 0 , |
|||
int | y_min = 0 , |
|||
int | x_max = -1 , |
|||
int | y_max = -1 | |||
) | const |
Returns the image as a matrix with pixel grayscale values in the range [0,1].
doResize | If set to true (default), the output matrix will be always the size of the image at output. If set to false, the matrix will be enlarged to the size of the image, but it will not be cropped if it has room enough (useful for FFT2D,...) | |
x_min | The starting "x" coordinate to extract (default=0=the first column) | |
y_min | The starting "y" coordinate to extract (default=0=the first row) | |
x_max | The final "x" coordinate (inclusive) to extract (default=-1=the last column) | |
y_max | The final "y" coordinate (inclusive) to extract (default=-1=the last row) (by JLBC @ JAN-2006) |
void mrpt::utils::CImage::getAsMatrixTiled | ( | math::CMatrix & | outMatrix | ) | const |
Returns the image as a matrix, where the image is "tiled" (repeated) the required number of times to fill the entire size of the matrix on input.
(by JLBC @ JAN-2006)
unsigned int mrpt::utils::CImage::getChannelCount | ( | ) | const |
const char* mrpt::utils::CImage::getChannelsOrder | ( | ) | const |
Returns a string of the form "BGR" indicating the channels ordering.
std::string mrpt::utils::CImage::getExternalStorageFile | ( | ) | const [inline] |
void mrpt::utils::CImage::getExternalStorageFileAbsolutePath | ( | std::string & | out_path | ) | const |
size_t mrpt::utils::CImage::getHeight | ( | ) | const [virtual] |
Returns the height of the image in pixels.
Implements mrpt::utils::CCanvas.
Referenced by mrpt::monoslam::CFeaturePatch::CFeaturePatch(), and mrpt::monoslam::CFeaturePatch::set_patch().
float mrpt::utils::CImage::getMaxAsFloat | ( | ) | const |
TImageSize mrpt::utils::CImage::getSize | ( | ) | const [inline] |
void mrpt::utils::CImage::getSize | ( | TImageSize & | s | ) | const |
size_t mrpt::utils::CImage::getWidth | ( | ) | const [virtual] |
Returns the width of the image in pixels.
Implements mrpt::utils::CCanvas.
Referenced by mrpt::monoslam::CFeaturePatch::CFeaturePatch(), and mrpt::monoslam::CFeaturePatch::set_patch().
void mrpt::utils::CImage::grayscale | ( | CImage & | ret | ) | const |
Returns a grayscale version of the image, or itself if it is already a grayscale image.
CImage mrpt::utils::CImage::grayscale | ( | ) | const |
Returns a grayscale version of the image, or itself if it is already a grayscale image.
void mrpt::utils::CImage::grayscaleInPlace | ( | ) |
bool mrpt::utils::CImage::isColor | ( | ) | const |
Returns true if the image is RGB, false if it is gray scale.
bool mrpt::utils::CImage::isExternallyStored | ( | ) | const [inline] |
bool mrpt::utils::CImage::isOriginTopLeft | ( | ) | const |
Returns true if the coordinates origin is top-left, or false if it is bottom-left.
Joins two images side-by-side horizontally.
Both images must have the same number of rows and be of the same type (i.e. depth and color mode)
im1 | [IN] The first image. | |
im2 | [IN] The other image. |
bool mrpt::utils::CImage::loadFromFile | ( | const std::string & | fileName, | |
int | isColor = -1 | |||
) |
Load image from a file, whose format is determined from the extension (internally uses OpenCV).
fileName | The file to read from. | |
isColor | Specifies colorness of the loaded image:
|
void mrpt::utils::CImage::loadFromIplImage | ( | void * | iplImage | ) |
Reads the image from a OpenCV IplImage object (making a copy).
void mrpt::utils::CImage::loadFromMemoryBuffer | ( | unsigned int | width, | |
unsigned int | height, | |||
unsigned int | bytesPerRow, | |||
unsigned char * | red, | |||
unsigned char * | green, | |||
unsigned char * | blue | |||
) |
Reads a color image from three raw pixels buffers in memory.
bytesPerRow is the number of bytes per row per channel, i.e. the row increment.
void mrpt::utils::CImage::loadFromMemoryBuffer | ( | unsigned int | width, | |
unsigned int | height, | |||
bool | color, | |||
unsigned char * | rawpixels, | |||
bool | swapRedBlue = false | |||
) |
Reads the image from raw pixels buffer in memory.
void mrpt::utils::CImage::loadFromStreamAsJPEG | ( | CStream & | in | ) |
Reads the image from a binary stream containing a binary jpeg file.
std::exception | On pixel coordinates out of bounds |
void mrpt::utils::CImage::makeSureImageIsLoaded | ( | ) | const throw (std::exception,utils::CExceptionExternalImageNotFound ) [protected] |
Checks if the image is of type "external storage", and if so and not loaded yet, load it.
void mrpt::utils::CImage::normalize | ( | ) |
Optimize de brightness range of a image without using histogram Only for one channel images.
(by AJOGD @ JAN-2007)
void mrpt::utils::CImage::openCV_cross_correlation | ( | const CImage & | patch_img, | |
size_t & | u_max, | |||
size_t & | v_max, | |||
double & | max_val, | |||
int | u_search_ini = -1 , |
|||
int | v_search_ini = -1 , |
|||
int | u_search_size = -1 , |
|||
int | v_search_size = -1 | |||
) | const |
Computes the correlation between this image and another one, encapsulating the openCV function cvMatchTemplate This implementation reduced computation time.
patch_img | The "patch" image, which must be equal, or smaller than "this" image. This function supports gray-scale (1 channel only) images. | |
u_search_ini | The "x" coordinate of the search window. | |
v_search_ini | The "y" coordinate of the search window. | |
u_search_size | The width of the search window. | |
v_search_size | The height of the search window. | |
u_max | The u coordinate where find the maximun cross correlation value. | |
v_max | The v coordinate where find the maximun cross correlation value | |
max_val | The maximun value of cross correlation which we can find Note: By default, the search area is the whole (this) image. (by AJOGD @ MAR-2007) |
unsigned char* mrpt::utils::CImage::operator() | ( | unsigned int | col, | |
unsigned int | row, | |||
unsigned int | channel = 0 | |||
) | const |
Returns a pointer to a given pixel information.
The coordinate origin is pixel(0,0)=top-left corner of the image.
std::exception | On pixel coordinates out of bounds |
CImage& mrpt::utils::CImage::operator= | ( | const CImageFloat & | o | ) |
void mrpt::utils::CImage::rectifyImage | ( | CImage & | out_img, | |
const math::CMatrixTemplateNumeric< T1 > & | cameraMatrix, | |||
const std::vector< T2 > & | distCoeff | |||
) | const [inline] |
Rectifies the image according to a certain camera matrix and vector of distortion coefficients and returns an output rectified image.
out_img | The output rectified image | |
cameraMatrix | The input camera matrix (containing the intrinsic parameters of the camera): [fx 0 cx; 0 fy cy; 0 0 1]: (fx,fy) focal length and (cx,cy) principal point coordinates | |
distCoeff | The (input) distortion coefficients: [k1, k2, p1, p2]: k1 and k2 (radial) and p1 and p2 (tangential) |
void mrpt::utils::CImage::rectifyImage | ( | CImage & | out_img, | |
const math::CMatrixTemplateNumeric< T1 > & | cameraMatrix, | |||
const math::CMatrixTemplateNumeric< T2 > & | distCoeff | |||
) | const [inline] |
Rectifies the image according to a certain camera matrix and vector of distortion coefficients and returns an output rectified image.
out_img | The output rectified image | |
cameraMatrix | The input camera matrix (containing the intrinsic parameters of the camera): [fx 0 cx; 0 fy cy; 0 0 1]: (fx,fy) focal length and (cx,cy) principal point coordinates | |
distCoeff | The (input) distortion coefficients: [k1, k2, p1, p2]: k1 and k2 (radial) and p1 and p2 (tangential) |
void mrpt::utils::CImage::rectifyImage_internal | ( | CImage & | out_img, | |
const math::CMatrixDouble & | cameraMatrix, | |||
const vector_double & | distCoeff | |||
) | const [protected] |
void mrpt::utils::CImage::rectifyImageInPlace | ( | const math::CMatrixTemplateNumeric< T1 > & | cameraMatrix, | |
const std::vector< T2 > & | distCoeff | |||
) | [inline] |
Rectifies the image according to a certain camera matrix and vector of distortion coefficients, replacing "this"· with the rectified image.
cameraMatrix | The input camera matrix (containing the intrinsic parameters of the camera): [fx 0 cx; 0 fy cy; 0 0 1]: (fx,fy) focal length and (cx,cy) principal point coordinates | |
distCoeff | The (input) distortion coefficients: [k1, k2, p1, p2]: k1 and k2 (radial) and p1 and p2 (tangential) |
void mrpt::utils::CImage::rectifyImageInPlace | ( | const math::CMatrixTemplateNumeric< T1 > & | cameraMatrix, | |
const math::CMatrixTemplateNumeric< T2 > & | distCoeff | |||
) | [inline] |
Rectifies the image according to a certain camera matrix and vector of distortion coefficients, replacing "this"· with the rectified image.
cameraMatrix | The input camera matrix (containing the intrinsic parameters of the camera): [fx 0 cx; 0 fy cy; 0 0 1]: (fx,fy) focal length and (cx,cy) principal point coordinates | |
distCoeff | The (input) distortion coefficients: [k1, k2, p1, p2]: k1 and k2 (radial) and p1 and p2 (tangential) |
Definition at line 593 of file CImage.h.
References mrpt::math::CMatrixTemplate< T >::extractRow().
void mrpt::utils::CImage::rectifyImageInPlace_internal | ( | const math::CMatrixDouble & | cameraMatrix, | |
const vector_double & | distCoeff | |||
) | [protected] |
void mrpt::utils::CImage::releaseIpl | ( | bool | thisIsExternalImgUnload = false |
) | [protected] |
Release the internal IPL image, if not NULL or read-only.
void mrpt::utils::CImage::resize | ( | unsigned int | width, | |
unsigned int | height, | |||
unsigned int | nChannels, | |||
bool | originTopLeft | |||
) | [inline] |
Changes the size of the image, erasing previous contents (does NOT scale its current content, for that, see scaleImage).
Definition at line 135 of file CImage.h.
References ASSERT_.
void mrpt::utils::CImage::rotateImage | ( | double | angle_radians, | |
unsigned int | center_x, | |||
unsigned int | center_y, | |||
double | scale = 1.0 | |||
) |
Rotates the image by the given angle around the given center point, with an optional scale factor.
bool mrpt::utils::CImage::saveToFile | ( | const std::string & | fileName | ) | const |
Save the image to a file, whose format is determined from the extension (internally uses OpenCV).
fileName | The file to write to. |
void mrpt::utils::CImage::saveToStreamAsJPEG | ( | CStream & | out | ) | const |
Save image to binary stream as a JPEG (.jpg) compresed format.
std::exception | On number of rows or cols equal to zero, or other errors. |
CImage mrpt::utils::CImage::scaleDouble | ( | ) | const |
Returns a new image scaled up to double its original size.
std::exception | On odd size |
CImage mrpt::utils::CImage::scaleHalf | ( | ) | const |
Returns a new image scaled down to half its original size.
std::exception | On odd size |
void mrpt::utils::CImage::scaleImage | ( | unsigned int | width, | |
unsigned int | height, | |||
TInterpMethod | interp = IMG_INTERP_CUBIC | |||
) |
void mrpt::utils::CImage::setExternalStorage | ( | const std::string & | fileName | ) |
By using this method the image is marked as referenced to an external file, which will be loaded only under demand.
A CImage with external storage does not consume memory until some method trying to access the image is invoked (e.g. getWidth(), isColor(),...) At any moment, the image can be unloaded from memory again by invoking unload. An image becomes of type "external storage" only through calling setExternalStorage. This property remains after serializing the object. File names can be absolute, or relative to the CImage::IMAGES_PATH_BASE directory. Filenames staring with "X:\" or "/" are considered absolute paths. By calling this method the current contents of the image are NOT saved to that file, because this method can be also called to let the object know where to load the image in case its contents are required. Thus, for saving images in this format (not when loading) the proper order of commands should be:
This feature has been added in MRPT 0.5.5.
void mrpt::utils::CImage::setFromIplImage | ( | void * | iplImage | ) |
Reads the image from a OpenCV IplImage object (WITHOUT making a copy).
This method provides a fast method to grab images from a camera without making a copy of every frame.
void mrpt::utils::CImage::setFromIplImageReadOnly | ( | void * | iplImage | ) |
Reads the image from a OpenCV IplImage object (WITHOUT making a copy) and from now on the image cannot be modified, just read.
This method provides a fast method to grab images from a camera without making a copy of every frame.
void mrpt::utils::CImage::setFromMatrix | ( | const mrpt::math::CMatrixDouble & | m, | |
bool | matrix_is_normalized = true | |||
) |
Set the image from a matrix, interpreted as grayscale intensity values, in the range [0,1] (normalized=true) or [0,255] (normalized=false).
void mrpt::utils::CImage::setFromMatrix | ( | const mrpt::math::CMatrixFloat & | m, | |
bool | matrix_is_normalized = true | |||
) |
Set the image from a matrix, interpreted as grayscale intensity values, in the range [0,1] (normalized=true) or [0,255] (normalized=false).
void mrpt::utils::CImage::setOriginTopLeft | ( | bool | val | ) |
Changes the property of the image stating if the top-left corner (vs.
bottom-left) is the coordinate reference.
void mrpt::utils::CImage::setPixel | ( | int | x, | |
int | y, | |||
size_t | color | |||
) | [virtual] |
Changes the value of the pixel (x,y).
Pixel coordinates starts at the left-top corner of the image, and start in (0,0). The meaning of the parameter "color" depends on the implementation: it will usually be a 24bit RGB value (0x00RRGGBB), but it can also be just a 8bit gray level. This method must support (x,y) values OUT of the actual image size without neither raising exceptions, nor leading to memory access errors.
Implements mrpt::utils::CCanvas.
void mrpt::utils::CImage::swapRB | ( | ) |
void mrpt::utils::CImage::unload | ( | ) |
For external storage image objects only, this method unloads the image from memory (or does nothing if already unloaded).
It does not need to be called explicitly, unless the user wants to save memory for images that will not be used often. If called for an image without the flag "external storage", it is simply ignored.
friend class CImageFloat [friend] |
bool mrpt::utils::CImage::DISABLE_ZIP_COMPRESSION [static] |
By default, when storing images through the CSerializable interface, grayscale images will be ZIP compressed if they are larger than 16Kb: this flag can be turn on to disable ZIP compression and gain speed versus occupied space.
The default value of this variable is "false".
std::string mrpt::utils::CImage::IMAGES_PATH_BASE [static] |
void* mrpt::utils::CImage::img [protected] |
std::string mrpt::utils::CImage::m_externalFile [mutable, protected] |
bool mrpt::utils::CImage::m_imgIsExternalStorage [mutable, protected] |
bool mrpt::utils::CImage::m_imgIsReadOnly [protected] |
Page generated by Doxygen 1.5.9 for MRPT 0.7.1 SVN: at Mon Aug 17 22:20:53 EDT 2009 |