Main MRPT website > C++ reference for MRPT 1.9.9
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-2018, 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/img/CImage.h>
14 
15 namespace mrpt
16 {
17 namespace vision
18 {
19 /** Holds and builds a pyramid of images: starting with an image at full
20  * resolution (octave=1), it builds
21  * a number of half-resolution images: octave=2 at 1/2 , octave=3 at 1/2^2,
22  * octave=N at 1/2^(N-1).
23  *
24  * Color (RGB) or grayscale pyramids can be built from color input images;
25  * only grayscale pyramids can be built from
26  * grayscale images.
27  *
28  * The algorithm to halve the images can be either a 1:2 decimation or a
29  * smooth filter (arithmetic mean of every 4 pixels).
30  *
31  * Pyramids are built by invoking the method \a buildPyramid() or \a
32  * buildPyramidFast()
33  *
34  * Example of usage:
35  * \code
36  * CImagePyramid pyr;
37  *
38  * CImage img = ...
39  *
40  * pyr.buildPyramid(
41  * img,
42  * 4, // num. of octaves
43  * true // smooth
44  * );
45  *
46  * pyr.images[0].saveToFile("pyr0.jpg");
47  * pyr.images[1].saveToFile("pyr1.jpg");
48  * ...
49  * \endcode
50  *
51  * \note Both converting to grayscale and building the octave images have
52  * SSE2-optimized implementations (if available).
53  *
54  * \sa mrpt::img::CImage
55  * \ingroup mrpt_vision_grp
56  */
58 {
59  public:
60  /** Default constructor, does nothing */
61  CImagePyramid();
62  /** Destructor, frees the stored images. */
64 
65  /** Fills the vector \a images with the different octaves built from the
66  * input image.
67  * \param[in] img The input image. Can be either color or grayscale.
68  * \param[in] nOctaves Number of octaves to build. 1 means just the
69  * original image, 2 means the original plus the 1/2 image, etc.
70  * \param[in] smooth_halves If true, use an arithmetic mean of every 2x2
71  * pixel block when downsampling.
72  * \param[in] convert_grayscale If true, the pyramid is built in grayscale
73  * even for color input images.
74  * \sa buildPyramidFast
75  */
76  void buildPyramid(
77  const mrpt::img::CImage& img, const size_t nOctaves,
78  const bool smooth_halves = true, const bool convert_grayscale = false);
79 
80  /** Exactly like \a buildPyramid(), but if the input image has not to be
81  * converted from RGB to grayscale, the image data buffer is *reutilized*
82  * for the 1st octave in \a images[0], emptying the input image.
83  * \sa buildPyramid
84  */
85  void buildPyramidFast(
86  mrpt::img::CImage& img, const size_t nOctaves,
87  const bool smooth_halves = true, const bool convert_grayscale = false);
88 
89  /** The individual images:
90  * - images[0]: 1st octave (full-size)
91  * - images[1]: 2nd octave (1/2 size)
92  * - images[2]: 3rd octave (1/4 size)
93  */
94  std::vector<mrpt::img::CImage> images;
95 };
96 }
97 }
98 
99 #endif
mrpt::vision::CImagePyramid::buildPyramidFast
void buildPyramidFast(mrpt::img::CImage &img, const size_t nOctaves, const bool smooth_halves=true, const bool convert_grayscale=false)
Exactly like buildPyramid(), but if the input image has not to be converted from RGB to grayscale,...
Definition: CImagePyramid.cpp:70
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::vision::CImagePyramid::~CImagePyramid
~CImagePyramid()
Destructor, frees the stored images.
Definition: CImagePyramid.cpp:18
mrpt::vision::CImagePyramid::CImagePyramid
CImagePyramid()
Default constructor, does nothing.
Definition: CImagePyramid.cpp:17
mrpt::vision::CImagePyramid::buildPyramid
void buildPyramid(const mrpt::img::CImage &img, const size_t nOctaves, const bool smooth_halves=true, const bool convert_grayscale=false)
Fills the vector images with the different octaves built from the input image.
Definition: CImagePyramid.cpp:61
mrpt::img::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130
img
GLint GLvoid * img
Definition: glext.h:3763
CImage.h
mrpt::vision::CImagePyramid::images
std::vector< mrpt::img::CImage > images
The individual images:
Definition: CImagePyramid.h:94
mrpt::vision::CImagePyramid
Holds and builds a pyramid of images: starting with an image at full resolution (octave=1),...
Definition: CImagePyramid.h:57



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST