Main MRPT website > C++ reference for MRPT 1.5.7
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 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
#define ASSERT_ABOVE_(__A, __B)
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
GLsizei GLsizei GLuint * obj
Definition: glext.h:3902
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
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:3645
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.5.7 Git: 8277875f6 Mon Jun 11 02:47:32 2018 +0200 at lun oct 28 01:50:49 CET 2019