MRPT  2.0.0
CImagePyramid.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 #include <mrpt/img/CImage.h>
13 
14 namespace mrpt::vision
15 {
16 /** Holds and builds a pyramid of images: starting with an image at full
17  * resolution (octave=1), it builds
18  * a number of half-resolution images: octave=2 at 1/2 , octave=3 at 1/2^2,
19  * octave=N at 1/2^(N-1).
20  *
21  * Color (RGB) or grayscale pyramids can be built from color input images;
22  * only grayscale pyramids can be built from
23  * grayscale images.
24  *
25  * The algorithm to halve the images can be either a 1:2 decimation or a
26  * smooth filter (arithmetic mean of every 4 pixels).
27  *
28  * Pyramids are built by invoking the method \a buildPyramid() or \a
29  * 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
49  * SSE2-optimized implementations (if available).
50  *
51  * \sa mrpt::img::CImage
52  * \ingroup mrpt_vision_grp
53  */
55 {
56  public:
57  CImagePyramid() = default;
58  ~CImagePyramid() = default;
59 
60  /** Fills the vector \a images with the different octaves built from the
61  * input image.
62  * \param[in] img The input image. Can be either color or grayscale.
63  * \param[in] nOctaves Number of octaves to build. 1 means just the
64  * original image, 2 means the original plus the 1/2 image, etc.
65  * \param[in] smooth_halves If true, use an arithmetic mean of every 2x2
66  * pixel block when downsampling.
67  * \param[in] convert_grayscale If true, the pyramid is built in grayscale
68  * even for color input images.
69  * \return true if SSE2-optimized versions of CImage::scaleHalf() was used
70  * to build **all** the scales in the pyramid.
71  * \sa buildPyramidFast
72  */
73  bool buildPyramid(
74  const mrpt::img::CImage& img, const size_t nOctaves,
75  const bool smooth_halves = true, const bool convert_grayscale = false);
76 
77  /** Exactly like \a buildPyramid(), but if the input image has not to be
78  * converted from RGB to grayscale, the image data buffer is *reutilized*
79  * for the 1st octave in \a images[0], emptying the input image.
80  * \sa buildPyramid
81  */
82  bool buildPyramidFast(
83  mrpt::img::CImage& img, const size_t nOctaves,
84  const bool smooth_halves = true, const bool convert_grayscale = false);
85 
86  /** The individual images:
87  * - images[0]: 1st octave (full-size)
88  * - images[1]: 2nd octave (1/2 size)
89  * - images[2]: 3rd octave (1/4 size)
90  * - ...
91  * - images[i]: (i+1)-th octave (1/2^i size)
92  */
93  std::vector<mrpt::img::CImage> images;
94 };
95 } // namespace mrpt::vision
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:54
std::vector< mrpt::img::CImage > images
The individual images:
Definition: CImagePyramid.h:93
Classes for computer vision, detectors, features, etc.
Definition: CDifodo.h:17
bool 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...
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:148
bool 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.



Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020