00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://www.mrpt.org/ | 00005 | | 00006 | Copyright (C) 2005-2011 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 00029 #ifndef __mrpt_vision_image_pyramid_H 00030 #define __mrpt_vision_image_pyramid_H 00031 00032 #include <mrpt/utils/CImage.h> 00033 00034 #include <mrpt/vision/link_pragmas.h> 00035 00036 namespace mrpt 00037 { 00038 namespace vision 00039 { 00040 /** Holds and builds a pyramid of images: starting with an image at full resolution (octave=1), it builds 00041 * a number of half-resolution images: octave=2 at 1/2 , octave=3 at 1/2^2, octave=N at 1/2^(N-1). 00042 * 00043 * Color (RGB) or grayscale pyramids can be built from color input images; only grayscale pyramids can be built from 00044 * grayscale images. 00045 * 00046 * The algorithm to halve the images can be either a 1:2 decimation or a smooth filter (arithmetic mean of every 4 pixels). 00047 * 00048 * Pyramids are built by invoking the method \a buildPyramid() or \a buildPyramidFast() 00049 * 00050 * Example of usage: 00051 * \code 00052 * CImagePyramid pyr; 00053 * 00054 * CImage img = ... 00055 * 00056 * pyr.buildPyramid( 00057 * img, 00058 * 4, // num. of octaves 00059 * true // smooth 00060 * ); 00061 * 00062 * pyr.images[0].saveToFile("pyr0.jpg"); 00063 * pyr.images[1].saveToFile("pyr1.jpg"); 00064 * ... 00065 * \endcode 00066 * 00067 * \note Both converting to grayscale and building the octave images have SSE2-optimized implementations (if available). 00068 * 00069 * \sa mrpt::utils::CImage 00070 * \ingroup mrpt_vision_grp 00071 */ 00072 class VISION_IMPEXP CImagePyramid 00073 { 00074 public: 00075 CImagePyramid(); //!< Default constructor, does nothing 00076 ~CImagePyramid(); //!< Destructor, frees the stored images. 00077 00078 /** Fills the vector \a images with the different octaves built from the input image. 00079 * \param[in] img The input image. Can be either color or grayscale. 00080 * \param[in] nOctaves Number of octaves to build. 1 means just the original image, 2 means the original plus the 1/2 image, etc. 00081 * \param[in] smooth_halves If true, use an arithmetic mean of every 2x2 pixel block when downsampling. 00082 * \param[in] convert_grayscale If true, the pyramid is built in grayscale even for color input images. 00083 * \sa buildPyramidFast 00084 */ 00085 void buildPyramid(const mrpt::utils::CImage &img, const size_t nOctaves, const bool smooth_halves = true, const bool convert_grayscale = false ); 00086 00087 /** Exactly like \a buildPyramid(), but if the input image has not to be converted from RGB to grayscale, the image data buffer is *reutilized* 00088 * for the 1st octave in \a images[0], emptying the input image. 00089 * \sa buildPyramid 00090 */ 00091 void buildPyramidFast(mrpt::utils::CImage &img, const size_t nOctaves, const bool smooth_halves = true, const bool convert_grayscale = false ); 00092 00093 /** The individual images: 00094 * - images[0]: 1st octave (full-size) 00095 * - images[1]: 2nd octave (1/2 size) 00096 * - images[2]: 3rd octave (1/4 size) 00097 */ 00098 std::vector<mrpt::utils::CImage> images; 00099 }; 00100 00101 } 00102 } 00103 00104 #endif
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |