Point Cloud Library (PCL)  1.9.1-dev
mask_map.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Willow Garage, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #pragma once
39 
40 #include <vector>
41 #include <pcl/pcl_macros.h>
42 #include <cstring>
43 
44 namespace pcl
45 {
46  class PCL_EXPORTS MaskMap
47  {
48  public:
49  MaskMap ();
50  MaskMap (size_t width, size_t height);
51  virtual ~MaskMap ();
52 
53  void
54  resize (size_t width, size_t height);
55 
56  inline size_t
57  getWidth () const { return (width_); }
58 
59  inline size_t
60  getHeight () const { return (height_); }
61 
62  inline unsigned char*
63  getData () { return (&data_[0]); }
64 
65  inline const unsigned char*
66  getData () const { return (&data_[0]); }
67 
68  static void
69  getDifferenceMask (const MaskMap & mask0,
70  const MaskMap & mask1,
71  MaskMap & diff_mask);
72 
73  inline void
74  set (const size_t x, const size_t y)
75  {
76  data_[y*width_+x] = 255;
77  }
78 
79  inline void
80  unset (const size_t x, const size_t y)
81  {
82  data_[y*width_+x] = 0;
83  }
84 
85  inline bool
86  isSet (const size_t x, const size_t y) const
87  {
88  return (data_[y*width_+x] != 0);
89  }
90 
91  inline void
92  reset ()
93  {
94  memset (&data_[0], 0, width_*height_);
95  }
96 
97  inline unsigned char &
98  operator() (const size_t x, const size_t y)
99  {
100  return (data_[y*width_+x]);
101  }
102 
103  inline const unsigned char &
104  operator() (const size_t x, const size_t y) const
105  {
106  return (data_[y*width_+x]);
107  }
108 
109  void
110  erode (MaskMap & eroded_mask) const;
111 
112  private:
113  //unsigned char * data_;
114  std::vector<unsigned char> data_;
115  size_t width_;
116  size_t height_;
117  };
118 
119 }
const unsigned char * getData() const
Definition: mask_map.h:66
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:44
void reset()
Definition: mask_map.h:92
unsigned char * getData()
Definition: mask_map.h:63
bool isSet(const size_t x, const size_t y) const
Definition: mask_map.h:86
size_t getWidth() const
Definition: mask_map.h:57
size_t getHeight() const
Definition: mask_map.h:60
void unset(const size_t x, const size_t y)
Definition: mask_map.h:80