Main MRPT website > C++ reference for MRPT 1.9.9
CImagePyramid.cpp
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 #include "vision-precomp.h" // Precompiled headers
12 
13 using namespace mrpt;
14 using namespace mrpt::utils;
15 using namespace mrpt::vision;
16 
17 CImagePyramid::CImagePyramid() {}
18 CImagePyramid::~CImagePyramid()
19 {
20  // Nothing especial to do, mem. is automatically freed.
21 }
22 
23 // Template that generalizes the two user entry-points below:
24 template <bool FASTLOAD>
26  CImagePyramid& obj, mrpt::utils::CImage& img, const size_t nOctaves,
27  const bool smooth_halves, const bool convert_grayscale)
28 {
29  ASSERT_ABOVE_(nOctaves, 0)
30 
31  // TImageSize img_size = img.getSize();
32  obj.images.resize(nOctaves);
33 
34  // First octave: Just copy the image:
35  if (convert_grayscale && img.isColor())
36  {
37  // In this case we have to convert to grayscale, so FASTLOAD doesn't
38  // really matter:
39  img.grayscale(obj.images[0]);
40  }
41  else
42  {
43  // No need to convert to grayscale OR image already is grayscale:
44  if (FASTLOAD)
45  obj.images[0].copyFastFrom(
46  img); // Fast copy -> "move", destroying source.
47  else
48  obj.images[0] = img; // Normal copy
49  }
50 
51  // Rest of octaves, if any:
52  for (size_t o = 1; o < nOctaves; o++)
53  {
54  if (smooth_halves)
55  obj.images[o - 1].scaleHalfSmooth(obj.images[o]);
56  else
57  obj.images[o - 1].scaleHalf(obj.images[o]);
58  }
59 }
60 
61 void CImagePyramid::buildPyramid(
62  const mrpt::utils::CImage& img, const size_t nOctaves,
63  const bool smooth_halves, const bool convert_grayscale)
64 {
65  buildPyramid_templ<false>(
66  *this, *const_cast<mrpt::utils::CImage*>(&img), nOctaves, smooth_halves,
67  convert_grayscale);
68 }
69 
70 void CImagePyramid::buildPyramidFast(
71  mrpt::utils::CImage& img, const size_t nOctaves, const bool smooth_halves,
72  const bool convert_grayscale)
73 {
74  buildPyramid_templ<true>(
75  *this, img, nOctaves, smooth_halves, convert_grayscale);
76 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
#define ASSERT_ABOVE_(__A, __B)
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:118
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
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:57
void buildPyramid_templ(CImagePyramid &obj, mrpt::utils::CImage &img, const size_t nOctaves, const bool smooth_halves, const bool convert_grayscale)
GLint GLvoid * img
Definition: glext.h:3763
Classes for computer vision, detectors, features, etc.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019