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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020