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-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 #include "vision-precomp.h" // Precompiled headers
12 
13 using namespace mrpt;
14 using namespace mrpt::vision;
15 using namespace mrpt::img;
16 
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::img::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 
62  const mrpt::img::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::img::CImage*>(&img), nOctaves, smooth_halves,
67  convert_grayscale);
68 }
69 
71  mrpt::img::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 }
buildPyramid_templ
void buildPyramid_templ(CImagePyramid &obj, mrpt::img::CImage &img, const size_t nOctaves, const bool smooth_halves, const bool convert_grayscale)
Definition: CImagePyramid.cpp:25
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
ASSERT_ABOVE_
#define ASSERT_ABOVE_(__A, __B)
Definition: exceptions.h:171
CImagePyramid.h
mrpt::vision
Classes for computer vision, detectors, features, etc.
Definition: CCamModel.h:20
obj
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
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
vision-precomp.h
mrpt::vision::CImagePyramid::CImagePyramid
CImagePyramid()
Default constructor, does nothing.
Definition: CImagePyramid.cpp:17
mrpt::img
Definition: CCanvas.h: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
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