MRPT  1.9.9
CImagePyramid.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "vision-precomp.h" // Precompiled headers
11 
13 
14 using namespace mrpt;
15 using namespace mrpt::vision;
16 using namespace mrpt::img;
17 
18 // Template that generalizes the two user entry-points below:
19 template <bool FASTLOAD>
21  CImagePyramid& obj, mrpt::img::CImage& img, const size_t nOctaves,
22  const bool smooth_halves, const bool convert_grayscale)
23 {
24  ASSERT_ABOVE_(nOctaves, 0);
25 
26  // TImageSize img_size = img.getSize();
27  obj.images.resize(nOctaves);
28 
29  // First octave: Just copy the image:
30  if (convert_grayscale && img.isColor())
31  {
32  // In this case we have to convert to grayscale, so FASTLOAD doesn't
33  // really matter:
34  img.grayscale(obj.images[0]);
35  }
36  else
37  {
38  // No need to convert to grayscale OR image already is grayscale:
39  // Fast copy -> "move", destroying source.
40  if (FASTLOAD)
41  obj.images[0] = std::move(img);
42  else
43  obj.images[0] = img; // Normal copy
44  }
45 
46  // Rest of octaves, if any:
47  bool all_used_sse2 = true;
48  for (size_t o = 1; o < nOctaves; o++)
49  {
50  bool ret = obj.images[o - 1].scaleHalf(
51  obj.images[o], smooth_halves ? IMG_INTERP_LINEAR : IMG_INTERP_NN);
52  all_used_sse2 = all_used_sse2 && ret;
53  }
54  return all_used_sse2;
55 }
56 
58  const mrpt::img::CImage& img, const size_t nOctaves,
59  const bool smooth_halves, const bool convert_grayscale)
60 {
61  return buildPyramid_templ<false>(
62  *this, *const_cast<mrpt::img::CImage*>(&img), nOctaves, smooth_halves,
63  convert_grayscale);
64 }
65 
67  mrpt::img::CImage& img, const size_t nOctaves, const bool smooth_halves,
68  const bool convert_grayscale)
69 {
70  return buildPyramid_templ<true>(
71  *this, img, nOctaves, smooth_halves, convert_grayscale);
72 }
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:54
std::vector< mrpt::img::CImage > images
The individual images:
Definition: CImagePyramid.h:93
bool buildPyramid_templ(CImagePyramid &obj, mrpt::img::CImage &img, const size_t nOctaves, const bool smooth_halves, const bool convert_grayscale)
Classes for computer vision, detectors, features, etc.
Definition: CDifodo.h:17
CImage grayscale() const
Returns a grayscale version of the image, or a shallow copy of itself if it is already a grayscale im...
Definition: CImage.cpp:933
bool 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...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool isColor() const
Returns true if the image is RGB, false if it is grayscale.
Definition: CImage.cpp:859
#define ASSERT_ABOVE_(__A, __B)
Definition: exceptions.h:155
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:148
bool 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.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020