Point Cloud Library (PCL)  1.9.1-dev
intensity.hpp
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2012, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * $Id$
38  *
39  */
40 
41 #ifndef PCL_COMMON_INTENSITY_FIELD_ACCESSOR_IMPL_HPP
42 #define PCL_COMMON_INTENSITY_FIELD_ACCESSOR_IMPL_HPP
43 
44 #include <pcl/point_types.h>
45 namespace pcl
46 {
47  namespace common
48  {
49  template<>
51  {
52  inline float
54  {
55  return (p.curvature);
56  }
57 
58  inline void
59  get (const pcl::PointNormal &p, float &intensity) const
60  {
61  intensity = p.curvature;
62  }
63 
64  inline void
65  set (pcl::PointNormal &p, float intensity) const
66  {
67  p.curvature = intensity;
68  }
69 
70  inline void
71  demean (pcl::PointNormal& p, float value) const
72  {
73  p.curvature -= value;
74  }
75 
76  inline void
77  add (pcl::PointNormal& p, float value) const
78  {
79  p.curvature += value;
80  }
81  };
82 
83  template<>
85  {
86  inline float
87  operator () (const pcl::PointXYZ &p) const
88  {
89  return (p.z);
90  }
91 
92  inline void
93  get (const pcl::PointXYZ &p, float &intensity) const
94  {
95  intensity = p.z;
96  }
97 
98  inline void
99  set (pcl::PointXYZ &p, float intensity) const
100  {
101  p.z = intensity;
102  }
103 
104  inline void
105  demean (pcl::PointXYZ& p, float value) const
106  {
107  p.z -= value;
108  }
109 
110  inline void
111  add (pcl::PointXYZ& p, float value) const
112  {
113  p.z += value;
114  }
115  };
116 
117  template<>
119  {
120  inline float
122  {
123  return (static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f);
124  }
125 
126  inline void
127  get (const pcl::PointXYZRGB &p, float& intensity) const
128  {
129  intensity = static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f;
130  }
131 
132  inline void
133  set (pcl::PointXYZRGB &p, float intensity) const
134  {
135  p.r = static_cast<uint8_t> (intensity * 3.34448160535f); // 1000 / 299
136  p.g = static_cast<uint8_t> (intensity * 1.70357751278f); // 1000 / 587
137  p.b = static_cast<uint8_t> (intensity * 8.77192982456f); // 1000 / 114
138  }
139 
140  inline void
141  demean (pcl::PointXYZRGB& p, float value) const
142  {
143  float intensity = this->operator () (p);
144  intensity -= value;
145  set (p, intensity);
146  }
147 
148  inline void
149  add (pcl::PointXYZRGB& p, float value) const
150  {
151  float intensity = this->operator () (p);
152  intensity += value;
153  set (p, intensity);
154  }
155  };
156 
157  template<>
159  {
160  inline float
162  {
163  return (static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f);
164  }
165 
166  inline void
167  get (const pcl::PointXYZRGBA &p, float& intensity) const
168  {
169  intensity = static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f;
170  }
171 
172  inline void
173  set (pcl::PointXYZRGBA &p, float intensity) const
174  {
175  p.r = static_cast<uint8_t> (intensity * 3.34448160535f); // 1000 / 299
176  p.g = static_cast<uint8_t> (intensity * 1.70357751278f); // 1000 / 587
177  p.b = static_cast<uint8_t> (intensity * 8.77192982456f); // 1000 / 114
178  }
179 
180  inline void
181  demean (pcl::PointXYZRGBA& p, float value) const
182  {
183  float intensity = this->operator () (p);
184  intensity -= value;
185  set (p, intensity);
186  }
187 
188  inline void
189  add (pcl::PointXYZRGBA& p, float value) const
190  {
191  float intensity = this->operator () (p);
192  intensity += value;
193  set (p, intensity);
194  }
195  };
196 
197  template<>
199  {
200  inline float
202  {
203  return (static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f);
204  }
205 
206  inline void
207  get (const pcl::PointXYZRGBNormal &p, float& intensity) const
208  {
209  intensity = static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f;
210  }
211 
212  inline void
213  set (pcl::PointXYZRGBNormal &p, float intensity) const
214  {
215  p.r = static_cast<uint8_t> (intensity * 3.34448160535f); // 1000 / 299
216  p.g = static_cast<uint8_t> (intensity * 1.70357751278f); // 1000 / 587
217  p.b = static_cast<uint8_t> (intensity * 8.77192982456f); // 1000 / 114
218  }
219 
220  inline void
221  demean (pcl::PointXYZRGBNormal &p, float value) const
222  {
223  float intensity = this->operator () (p);
224  intensity -= value;
225  set (p, intensity);
226  }
227 
228  inline void
229  add (pcl::PointXYZRGBNormal &p, float value) const
230  {
231  float intensity = this->operator () (p);
232  intensity += value;
233  set (p, intensity);
234  }
235  };
236 
237  template<>
239  {
240  inline float
242  {
243  return (static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f);
244  }
245 
246  inline void
247  get (const pcl::PointXYZRGBL &p, float& intensity) const
248  {
249  intensity = static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f;
250  }
251 
252  inline void
253  set (pcl::PointXYZRGBL &p, float intensity) const
254  {
255  p.r = static_cast<uint8_t> (intensity * 3.34448160535f); // 1000 / 299
256  p.g = static_cast<uint8_t> (intensity * 1.70357751278f); // 1000 / 587
257  p.b = static_cast<uint8_t> (intensity * 8.77192982456f); // 1000 / 114
258  }
259 
260  inline void
261  demean (pcl::PointXYZRGBL& p, float value) const
262  {
263  float intensity = this->operator () (p);
264  intensity -= value;
265  set (p, intensity);
266  }
267 
268  inline void
269  add (pcl::PointXYZRGBL& p, float value) const
270  {
271  float intensity = this->operator () (p);
272  intensity += value;
273  set (p, intensity);
274  }
275  };
276 
277  template<>
279  {
280  inline float
282  {
283  return (p.v);
284  }
285 
286  inline void
287  get (const pcl::PointXYZHSV &p, float &intensity) const
288  {
289  intensity = p.v;
290  }
291 
292  inline void
293  set (pcl::PointXYZHSV &p, float intensity) const
294  {
295  p.v = intensity;
296  p.s = 0.0f;
297  }
298 
299  inline void
300  demean (pcl::PointXYZHSV& p, float value) const
301  {
302  p.v -= value;
303  }
304 
305  inline void
306  add (pcl::PointXYZHSV& p, float value) const
307  {
308  p.v += value;
309  }
310  };
311 
312  template<>
314  {
315  inline float
316  operator () (const pcl::PointXYZL &p) const
317  {
318  return (static_cast<float>(p.label));
319  }
320 
321  inline void
322  get (const pcl::PointXYZL &p, float &intensity) const
323  {
324  intensity = static_cast<float>(p.label);
325  }
326 
327  inline void
328  set (pcl::PointXYZL &p, float intensity) const
329  {
330  p.label = static_cast<uint32_t>(intensity);
331 
332  }
333 
334  inline void
335  demean (pcl::PointXYZL& p, float value) const
336  {
337  p.label -= static_cast<uint32_t>(value);
338  }
339 
340  inline void
341  add (pcl::PointXYZL& p, float value) const
342  {
343  p.label += static_cast<uint32_t>(value);
344  }
345  };
346 
347  template<>
349  {
350  inline float
352  {
353  return (static_cast<float>(p.label));
354  }
355 
356  inline void
357  get (const pcl::PointXYZLNormal &p, float &intensity) const
358  {
359  intensity = static_cast<float>(p.label);
360  }
361 
362  inline void
363  set (pcl::PointXYZLNormal &p, float intensity) const
364  {
365  p.label = static_cast<uint32_t>(intensity);
366 
367  }
368 
369  inline void
370  demean (pcl::PointXYZLNormal& p, float value) const
371  {
372  p.label -= static_cast<uint32_t>(value);
373  }
374 
375  inline void
376  add (pcl::PointXYZLNormal& p, float value) const
377  {
378  p.label += static_cast<uint32_t>(value);
379  }
380  };
381 
382  template<>
384  {
385  inline float
387  {
388  return (p.strength);
389  }
390 
391  inline void
392  get (const pcl::InterestPoint &p, float &intensity) const
393  {
394  intensity = p.strength;
395  }
396 
397  inline void
398  set (pcl::InterestPoint &p, float intensity) const
399  {
400  p.strength = intensity;
401  }
402 
403  inline void
404  demean (pcl::InterestPoint& p, float value) const
405  {
406  p.strength -= value;
407  }
408 
409  inline void
410  add (pcl::InterestPoint& p, float value) const
411  {
412  p.strength += value;
413  }
414  };
415 
416  template<>
418  {
419  inline float
421  {
422  return (p.range);
423  }
424 
425  inline void
426  get (const pcl::PointWithRange &p, float &intensity) const
427  {
428  intensity = p.range;
429  }
430 
431  inline void
432  set (pcl::PointWithRange &p, float intensity) const
433  {
434  p.range = intensity;
435  }
436 
437  inline void
438  demean (pcl::PointWithRange& p, float value) const
439  {
440  p.range -= value;
441  }
442 
443  inline void
444  add (pcl::PointWithRange& p, float value) const
445  {
446  p.range += value;
447  }
448  };
449 
450  template<>
452  {
453  inline float
455  {
456  return (p.scale);
457  }
458 
459  inline void
460  get (const pcl::PointWithScale &p, float &intensity) const
461  {
462  intensity = p.scale;
463  }
464 
465  inline void
466  set (pcl::PointWithScale &p, float intensity) const
467  {
468  p.scale = intensity;
469  }
470 
471  inline void
472  demean (pcl::PointWithScale& p, float value) const
473  {
474  p.scale -= value;
475  }
476 
477  inline void
478  add (pcl::PointWithScale& p, float value) const
479  {
480  p.scale += value;
481  }
482  };
483 
484  template<>
486  {
487  inline float
489  {
490  return (p.z);
491  }
492 
493  inline void
494  get (const pcl::PointWithViewpoint &p, float &intensity) const
495  {
496  intensity = p.z;
497  }
498 
499  inline void
500  set (pcl::PointWithViewpoint &p, float intensity) const
501  {
502  p.z = intensity;
503  }
504 
505  inline void
506  demean (pcl::PointWithViewpoint& p, float value) const
507  {
508  p.z -= value;
509  }
510 
511  inline void
512  add (pcl::PointWithViewpoint& p, float value) const
513  {
514  p.z += value;
515  }
516  };
517 
518  template<>
520  {
521  inline float
523  {
524  return (p.curvature);
525  }
526 
527  inline void
528  get (const pcl::PointSurfel &p, float &intensity) const
529  {
530  intensity = p.curvature;
531  }
532 
533  inline void
534  set (pcl::PointSurfel &p, float intensity) const
535  {
536  p.curvature = intensity;
537  }
538 
539  inline void
540  demean (pcl::PointSurfel& p, float value) const
541  {
542  p.curvature -= value;
543  }
544 
545  inline void
546  add (pcl::PointSurfel& p, float value) const
547  {
548  p.curvature += value;
549  }
550  };
551  }
552 }
553 
554 #endif
void add(pcl::PointXYZ &p, float value) const
Definition: intensity.hpp:111
A point structure representing Euclidean xyz coordinates, a label, together with normal coordinates a...
A point structure representing Euclidean xyz coordinates, padded with an extra range float...
void demean(pcl::PointXYZHSV &p, float value) const
Definition: intensity.hpp:300
float scale
Diameter of the meaningful keypoint neighborhood.
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
void add(pcl::PointXYZLNormal &p, float value) const
Definition: intensity.hpp:376
void add(pcl::PointXYZRGBA &p, float value) const
Definition: intensity.hpp:189
void demean(pcl::PointXYZRGB &p, float value) const
Definition: intensity.hpp:141
void add(pcl::PointXYZRGBL &p, float value) const
Definition: intensity.hpp:269
void demean(pcl::PointNormal &p, float value) const
Definition: intensity.hpp:71
void add(pcl::PointXYZL &p, float value) const
Definition: intensity.hpp:341
void demean(pcl::PointSurfel &p, float value) const
Definition: intensity.hpp:540
void demean(pcl::PointXYZRGBA &p, float value) const
Definition: intensity.hpp:181
A point structure representing Euclidean xyz coordinates, and the RGBA color.
void demean(pcl::PointXYZ &p, float value) const
Definition: intensity.hpp:105
void demean(pcl::PointWithViewpoint &p, float value) const
Definition: intensity.hpp:506
void add(pcl::PointWithViewpoint &p, float value) const
Definition: intensity.hpp:512
void add(pcl::PointWithRange &p, float value) const
Definition: intensity.hpp:444
void add(pcl::PointNormal &p, float value) const
Definition: intensity.hpp:77
void demean(pcl::PointXYZRGBL &p, float value) const
Definition: intensity.hpp:261
void add(pcl::InterestPoint &p, float value) const
Definition: intensity.hpp:410
void add(pcl::PointXYZHSV &p, float value) const
Definition: intensity.hpp:306
Defines all the PCL implemented PointT point type structures.
void add(pcl::PointWithScale &p, float value) const
Definition: intensity.hpp:478
A point structure representing Euclidean xyz coordinates.
A point structure representing an interest point with Euclidean xyz coordinates, and an interest valu...
void demean(pcl::PointWithRange &p, float value) const
Definition: intensity.hpp:438
void add(pcl::PointXYZRGBNormal &p, float value) const
Definition: intensity.hpp:229
A point structure representing Euclidean xyz coordinates, together with normal coordinates and the su...
void demean(pcl::InterestPoint &p, float value) const
Definition: intensity.hpp:404
void add(pcl::PointXYZRGB &p, float value) const
Definition: intensity.hpp:149
float operator()(const PointT &p) const
get intensity field
Definition: intensity.h:57
void demean(pcl::PointXYZLNormal &p, float value) const
Definition: intensity.hpp:370
A point structure representing Euclidean xyz coordinates together with the viewpoint from which it wa...
void add(pcl::PointSurfel &p, float value) const
Definition: intensity.hpp:546
A point structure representing a 3-D position and scale.
A point structure representing Euclidean xyz coordinates, and the RGB color.
void demean(pcl::PointWithScale &p, float value) const
Definition: intensity.hpp:472
A surfel, that is, a point structure representing Euclidean xyz coordinates, together with normal coo...
void demean(pcl::PointXYZL &p, float value) const
Definition: intensity.hpp:335
A point structure representing Euclidean xyz coordinates, and the RGB color, together with normal coo...
void demean(pcl::PointXYZRGBNormal &p, float value) const
Definition: intensity.hpp:221