Main MRPT website
>
C++ reference
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
mrpt
vision
CImagePyramid.h
Go to the documentation of this file.
1
/* +---------------------------------------------------------------------------+
2
| The Mobile Robot Programming Toolkit (MRPT) C++ library |
3
| |
4
| http://www.mrpt.org/ |
5
| |
6
| Copyright (C) 2005-2012 University of Malaga |
7
| |
8
| This software was written by the Machine Perception and Intelligent |
9
| Robotics Lab, University of Malaga (Spain). |
10
| Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11
| |
12
| This file is part of the MRPT project. |
13
| |
14
| MRPT is free software: you can redistribute it and/or modify |
15
| it under the terms of the GNU General Public License as published by |
16
| the Free Software Foundation, either version 3 of the License, or |
17
| (at your option) any later version. |
18
| |
19
| MRPT is distributed in the hope that it will be useful, |
20
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
21
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22
| GNU General Public License for more details. |
23
| |
24
| You should have received a copy of the GNU General Public License |
25
| along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26
| |
27
+---------------------------------------------------------------------------+ */
28
29
#ifndef __mrpt_vision_image_pyramid_H
30
#define __mrpt_vision_image_pyramid_H
31
32
#include <
mrpt/utils/CImage.h
>
33
34
#include <
mrpt/vision/link_pragmas.h
>
35
36
namespace
mrpt
37
{
38
namespace
vision
39
{
40
/** Holds and builds a pyramid of images: starting with an image at full resolution (octave=1), it builds
41
* a number of half-resolution images: octave=2 at 1/2 , octave=3 at 1/2^2, octave=N at 1/2^(N-1).
42
*
43
* Color (RGB) or grayscale pyramids can be built from color input images; only grayscale pyramids can be built from
44
* grayscale images.
45
*
46
* The algorithm to halve the images can be either a 1:2 decimation or a smooth filter (arithmetic mean of every 4 pixels).
47
*
48
* Pyramids are built by invoking the method \a buildPyramid() or \a buildPyramidFast()
49
*
50
* Example of usage:
51
* \code
52
* CImagePyramid pyr;
53
*
54
* CImage img = ...
55
*
56
* pyr.buildPyramid(
57
* img,
58
* 4, // num. of octaves
59
* true // smooth
60
* );
61
*
62
* pyr.images[0].saveToFile("pyr0.jpg");
63
* pyr.images[1].saveToFile("pyr1.jpg");
64
* ...
65
* \endcode
66
*
67
* \note Both converting to grayscale and building the octave images have SSE2-optimized implementations (if available).
68
*
69
* \sa mrpt::utils::CImage
70
* \ingroup mrpt_vision_grp
71
*/
72
class
VISION_IMPEXP
CImagePyramid
73
{
74
public
:
75
CImagePyramid
();
//!< Default constructor, does nothing
76
~
CImagePyramid
();
//!< Destructor, frees the stored images.
77
78
/** Fills the vector \a images with the different octaves built from the input image.
79
* \param[in] img The input image. Can be either color or grayscale.
80
* \param[in] nOctaves Number of octaves to build. 1 means just the original image, 2 means the original plus the 1/2 image, etc.
81
* \param[in] smooth_halves If true, use an arithmetic mean of every 2x2 pixel block when downsampling.
82
* \param[in] convert_grayscale If true, the pyramid is built in grayscale even for color input images.
83
* \sa buildPyramidFast
84
*/
85
void
buildPyramid(
const
mrpt::utils::CImage
&img,
const
size_t
nOctaves,
const
bool
smooth_halves =
true
,
const
bool
convert_grayscale =
false
);
86
87
/** Exactly like \a buildPyramid(), but if the input image has not to be converted from RGB to grayscale, the image data buffer is *reutilized*
88
* for the 1st octave in \a images[0], emptying the input image.
89
* \sa buildPyramid
90
*/
91
void
buildPyramidFast(
mrpt::utils::CImage
&img,
const
size_t
nOctaves,
const
bool
smooth_halves =
true
,
const
bool
convert_grayscale =
false
);
92
93
/** The individual images:
94
* - images[0]: 1st octave (full-size)
95
* - images[1]: 2nd octave (1/2 size)
96
* - images[2]: 3rd octave (1/4 size)
97
*/
98
std::vector<mrpt::utils::CImage>
images
;
99
};
100
101
}
102
}
103
104
#endif
Page generated by
Doxygen 1.8.3
for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013