Main MRPT website > C++ reference for MRPT 1.5.6
CImagePyramid.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #ifndef __mrpt_vision_image_pyramid_H
11 #define __mrpt_vision_image_pyramid_H
12 
13 #include <mrpt/utils/CImage.h>
14 
16 
17 namespace mrpt
18 {
19  namespace vision
20  {
21  /** Holds and builds a pyramid of images: starting with an image at full resolution (octave=1), it builds
22  * a number of half-resolution images: octave=2 at 1/2 , octave=3 at 1/2^2, octave=N at 1/2^(N-1).
23  *
24  * Color (RGB) or grayscale pyramids can be built from color input images; only grayscale pyramids can be built from
25  * grayscale images.
26  *
27  * The algorithm to halve the images can be either a 1:2 decimation or a smooth filter (arithmetic mean of every 4 pixels).
28  *
29  * Pyramids are built by invoking the method \a buildPyramid() or \a buildPyramidFast()
30  *
31  * Example of usage:
32  * \code
33  * CImagePyramid pyr;
34  *
35  * CImage img = ...
36  *
37  * pyr.buildPyramid(
38  * img,
39  * 4, // num. of octaves
40  * true // smooth
41  * );
42  *
43  * pyr.images[0].saveToFile("pyr0.jpg");
44  * pyr.images[1].saveToFile("pyr1.jpg");
45  * ...
46  * \endcode
47  *
48  * \note Both converting to grayscale and building the octave images have SSE2-optimized implementations (if available).
49  *
50  * \sa mrpt::utils::CImage
51  * \ingroup mrpt_vision_grp
52  */
54  {
55  public:
56  CImagePyramid(); //!< Default constructor, does nothing
57  ~CImagePyramid(); //!< Destructor, frees the stored images.
58 
59  /** Fills the vector \a images with the different octaves built from the input image.
60  * \param[in] img The input image. Can be either color or grayscale.
61  * \param[in] nOctaves Number of octaves to build. 1 means just the original image, 2 means the original plus the 1/2 image, etc.
62  * \param[in] smooth_halves If true, use an arithmetic mean of every 2x2 pixel block when downsampling.
63  * \param[in] convert_grayscale If true, the pyramid is built in grayscale even for color input images.
64  * \sa buildPyramidFast
65  */
66  void buildPyramid(const mrpt::utils::CImage &img, const size_t nOctaves, const bool smooth_halves = true, const bool convert_grayscale = false );
67 
68  /** Exactly like \a buildPyramid(), but if the input image has not to be converted from RGB to grayscale, the image data buffer is *reutilized*
69  * for the 1st octave in \a images[0], emptying the input image.
70  * \sa buildPyramid
71  */
72  void buildPyramidFast(mrpt::utils::CImage &img, const size_t nOctaves, const bool smooth_halves = true, const bool convert_grayscale = false );
73 
74  /** The individual images:
75  * - images[0]: 1st octave (full-size)
76  * - images[1]: 2nd octave (1/2 size)
77  * - images[2]: 3rd octave (1/4 size)
78  */
79  std::vector<mrpt::utils::CImage> images;
80  };
81 
82  }
83 }
84 
85 #endif
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
Holds and builds a pyramid of images: starting with an image at full resolution (octave=1), it builds a number of half-resolution images: octave=2 at 1/2 , octave=3 at 1/2^2, octave=N at 1/2^(N-1).
Definition: CImagePyramid.h:53
GLint GLvoid * img
Definition: glext.h:3645
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::vector< mrpt::utils::CImage > images
The individual images:
Definition: CImagePyramid.h:79



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019