Main MRPT website > C++ reference for MRPT 1.5.6
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 {
19 }
20 
21 CImagePyramid::~CImagePyramid()
22 {
23  // Nothing especial to do, mem. is automatically freed.
24 }
25 
26 // Template that generalizes the two user entry-points below:
27 template <bool FASTLOAD>
31  const size_t nOctaves,
32  const bool smooth_halves,
33  const bool convert_grayscale)
34 {
35  ASSERT_ABOVE_(nOctaves,0)
36 
37  //TImageSize img_size = img.getSize();
38  obj.images.resize(nOctaves);
39 
40  // First octave: Just copy the image:
41  if (convert_grayscale && img.isColor())
42  {
43  // In this case we have to convert to grayscale, so FASTLOAD doesn't really matter:
44  img.grayscale(obj.images[0]);
45  }
46  else
47  {
48  // No need to convert to grayscale OR image already is grayscale:
49  if (FASTLOAD)
50  obj.images[0].copyFastFrom(img); // Fast copy -> "move", destroying source.
51  else obj.images[0] = img; // Normal copy
52  }
53 
54  // Rest of octaves, if any:
55  for (size_t o=1;o<nOctaves;o++)
56  {
57  if (smooth_halves)
58  obj.images[o-1].scaleHalfSmooth(obj.images[o]);
59  else obj.images[o-1].scaleHalf(obj.images[o]);
60  }
61 }
62 
63 void CImagePyramid::buildPyramid(
64  const mrpt::utils::CImage &img,
65  const size_t nOctaves,
66  const bool smooth_halves,
67  const bool convert_grayscale)
68 {
69  buildPyramid_templ<false>(*this,*const_cast<mrpt::utils::CImage*>(&img), nOctaves,smooth_halves,convert_grayscale);
70 }
71 
72 void CImagePyramid::buildPyramidFast(
74  const size_t nOctaves,
75  const bool smooth_halves,
76  const bool convert_grayscale)
77 {
78  buildPyramid_templ<true>(*this,img,nOctaves,smooth_halves,convert_grayscale);
79 }
#define ASSERT_ABOVE_(__A, __B)
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
bool isColor() const
Returns true if the image is RGB, false if it is grayscale.
Definition: CImage.cpp:898
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:53
GLint GLvoid * img
Definition: glew.h:1290
void buildPyramid_templ(CImagePyramid &obj, mrpt::utils::CImage &img, const size_t nOctaves, const bool smooth_halves, const bool convert_grayscale)
GLhandleARB obj
Definition: glew.h:3276
CImage grayscale() const
Returns a grayscale version of the image, or itself if it is already a grayscale image.
Definition: CImage.cpp:992
std::vector< mrpt::utils::CImage > images
The individual images:
Definition: CImagePyramid.h:79



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018