Point Cloud Library (PCL)  1.14.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 #pragma once
42 
43 #include <pcl/common/intensity.h>
44 #include <pcl/point_types.h>
45 
46 
47 namespace pcl
48 {
49  namespace common
50  {
51  template<>
53  {
54  inline float
56  {
57  return (p.curvature);
58  }
59 
60  inline void
61  get (const pcl::PointNormal &p, float &intensity) const
62  {
63  intensity = p.curvature;
64  }
65 
66  inline void
67  set (pcl::PointNormal &p, float intensity) const
68  {
69  p.curvature = intensity;
70  }
71 
72  inline void
73  demean (pcl::PointNormal& p, float value) const
74  {
75  p.curvature -= value;
76  }
77 
78  inline void
79  add (pcl::PointNormal& p, float value) const
80  {
81  p.curvature += value;
82  }
83  };
84 
85  template<>
87  {
88  inline float
89  operator () (const pcl::PointXYZ &p) const
90  {
91  return (p.z);
92  }
93 
94  inline void
95  get (const pcl::PointXYZ &p, float &intensity) const
96  {
97  intensity = p.z;
98  }
99 
100  inline void
101  set (pcl::PointXYZ &p, float intensity) const
102  {
103  p.z = intensity;
104  }
105 
106  inline void
107  demean (pcl::PointXYZ& p, float value) const
108  {
109  p.z -= value;
110  }
111 
112  inline void
113  add (pcl::PointXYZ& p, float value) const
114  {
115  p.z += value;
116  }
117  };
118 
119  template<>
121  {
122  inline float
124  {
125  return (static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f);
126  }
127 
128  inline void
129  get (const pcl::PointXYZRGB &p, float& intensity) const
130  {
131  intensity = static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f;
132  }
133 
134  inline void
135  set (pcl::PointXYZRGB &p, float intensity) const
136  {
137  p.r = static_cast<std::uint8_t> (intensity * 3.34448160535f); // 1000 / 299
138  p.g = static_cast<std::uint8_t> (intensity * 1.70357751278f); // 1000 / 587
139  p.b = static_cast<std::uint8_t> (intensity * 8.77192982456f); // 1000 / 114
140  }
141 
142  inline void
143  demean (pcl::PointXYZRGB& p, float value) const
144  {
145  float intensity = this->operator () (p);
146  intensity -= value;
147  set (p, intensity);
148  }
149 
150  inline void
151  add (pcl::PointXYZRGB& p, float value) const
152  {
153  float intensity = this->operator () (p);
154  intensity += value;
155  set (p, intensity);
156  }
157  };
158 
159  template<>
161  {
162  inline float
164  {
165  return (static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f);
166  }
167 
168  inline void
169  get (const pcl::PointXYZRGBA &p, float& intensity) const
170  {
171  intensity = static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f;
172  }
173 
174  inline void
175  set (pcl::PointXYZRGBA &p, float intensity) const
176  {
177  p.r = static_cast<std::uint8_t> (intensity * 3.34448160535f); // 1000 / 299
178  p.g = static_cast<std::uint8_t> (intensity * 1.70357751278f); // 1000 / 587
179  p.b = static_cast<std::uint8_t> (intensity * 8.77192982456f); // 1000 / 114
180  }
181 
182  inline void
183  demean (pcl::PointXYZRGBA& p, float value) const
184  {
185  float intensity = this->operator () (p);
186  intensity -= value;
187  set (p, intensity);
188  }
189 
190  inline void
191  add (pcl::PointXYZRGBA& p, float value) const
192  {
193  float intensity = this->operator () (p);
194  intensity += value;
195  set (p, intensity);
196  }
197  };
198 
199  template<>
201  {
202  inline float
204  {
205  return (static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f);
206  }
207 
208  inline void
209  get (const pcl::PointXYZRGBNormal &p, float& intensity) const
210  {
211  intensity = static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f;
212  }
213 
214  inline void
215  set (pcl::PointXYZRGBNormal &p, float intensity) const
216  {
217  p.r = static_cast<std::uint8_t> (intensity * 3.34448160535f); // 1000 / 299
218  p.g = static_cast<std::uint8_t> (intensity * 1.70357751278f); // 1000 / 587
219  p.b = static_cast<std::uint8_t> (intensity * 8.77192982456f); // 1000 / 114
220  }
221 
222  inline void
223  demean (pcl::PointXYZRGBNormal &p, float value) const
224  {
225  float intensity = this->operator () (p);
226  intensity -= value;
227  set (p, intensity);
228  }
229 
230  inline void
231  add (pcl::PointXYZRGBNormal &p, float value) const
232  {
233  float intensity = this->operator () (p);
234  intensity += value;
235  set (p, intensity);
236  }
237  };
238 
239  template<>
241  {
242  inline float
244  {
245  return (static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f);
246  }
247 
248  inline void
249  get (const pcl::PointXYZRGBL &p, float& intensity) const
250  {
251  intensity = static_cast<float> (299*p.r + 587*p.g + 114*p.b) * 0.001f;
252  }
253 
254  inline void
255  set (pcl::PointXYZRGBL &p, float intensity) const
256  {
257  p.r = static_cast<std::uint8_t> (intensity * 3.34448160535f); // 1000 / 299
258  p.g = static_cast<std::uint8_t> (intensity * 1.70357751278f); // 1000 / 587
259  p.b = static_cast<std::uint8_t> (intensity * 8.77192982456f); // 1000 / 114
260  }
261 
262  inline void
263  demean (pcl::PointXYZRGBL& p, float value) const
264  {
265  float intensity = this->operator () (p);
266  intensity -= value;
267  set (p, intensity);
268  }
269 
270  inline void
271  add (pcl::PointXYZRGBL& p, float value) const
272  {
273  float intensity = this->operator () (p);
274  intensity += value;
275  set (p, intensity);
276  }
277  };
278 
279  template<>
281  {
282  inline float
284  {
285  return (p.L);
286  }
287 
288  inline void
289  get (const pcl::PointXYZLAB &p, float &intensity) const
290  {
291  intensity = p.L;
292  }
293 
294  inline void
295  set (pcl::PointXYZLAB &p, float intensity) const
296  {
297  p.L = intensity;
298  }
299 
300  inline void
301  demean (pcl::PointXYZLAB& p, float value) const
302  {
303  p.L -= value;
304  }
305 
306  inline void
307  add (pcl::PointXYZLAB& p, float value) const
308  {
309  p.L += value;
310  }
311  };
312 
313  template<>
315  {
316  inline float
318  {
319  return (p.v);
320  }
321 
322  inline void
323  get (const pcl::PointXYZHSV &p, float &intensity) const
324  {
325  intensity = p.v;
326  }
327 
328  inline void
329  set (pcl::PointXYZHSV &p, float intensity) const
330  {
331  p.v = intensity;
332  p.s = 0.0f;
333  }
334 
335  inline void
336  demean (pcl::PointXYZHSV& p, float value) const
337  {
338  p.v -= value;
339  }
340 
341  inline void
342  add (pcl::PointXYZHSV& p, float value) const
343  {
344  p.v += value;
345  }
346  };
347 
348  template<>
350  {
351  inline float
352  operator () (const pcl::PointXYZL &p) const
353  {
354  return (static_cast<float>(p.label));
355  }
356 
357  inline void
358  get (const pcl::PointXYZL &p, float &intensity) const
359  {
360  intensity = static_cast<float>(p.label);
361  }
362 
363  inline void
364  set (pcl::PointXYZL &p, float intensity) const
365  {
366  p.label = static_cast<std::uint32_t>(intensity);
367 
368  }
369 
370  inline void
371  demean (pcl::PointXYZL& p, float value) const
372  {
373  p.label -= static_cast<std::uint32_t>(value);
374  }
375 
376  inline void
377  add (pcl::PointXYZL& p, float value) const
378  {
379  p.label += static_cast<std::uint32_t>(value);
380  }
381  };
382 
383  template<>
385  {
386  inline float
388  {
389  return (static_cast<float>(p.label));
390  }
391 
392  inline void
393  get (const pcl::PointXYZLNormal &p, float &intensity) const
394  {
395  intensity = static_cast<float>(p.label);
396  }
397 
398  inline void
399  set (pcl::PointXYZLNormal &p, float intensity) const
400  {
401  p.label = static_cast<std::uint32_t>(intensity);
402 
403  }
404 
405  inline void
406  demean (pcl::PointXYZLNormal& p, float value) const
407  {
408  p.label -= static_cast<std::uint32_t>(value);
409  }
410 
411  inline void
412  add (pcl::PointXYZLNormal& p, float value) const
413  {
414  p.label += static_cast<std::uint32_t>(value);
415  }
416  };
417 
418  template<>
420  {
421  inline float
423  {
424  return (p.strength);
425  }
426 
427  inline void
428  get (const pcl::InterestPoint &p, float &intensity) const
429  {
430  intensity = p.strength;
431  }
432 
433  inline void
434  set (pcl::InterestPoint &p, float intensity) const
435  {
436  p.strength = intensity;
437  }
438 
439  inline void
440  demean (pcl::InterestPoint& p, float value) const
441  {
442  p.strength -= value;
443  }
444 
445  inline void
446  add (pcl::InterestPoint& p, float value) const
447  {
448  p.strength += value;
449  }
450  };
451 
452  template<>
454  {
455  inline float
457  {
458  return (p.range);
459  }
460 
461  inline void
462  get (const pcl::PointWithRange &p, float &intensity) const
463  {
464  intensity = p.range;
465  }
466 
467  inline void
468  set (pcl::PointWithRange &p, float intensity) const
469  {
470  p.range = intensity;
471  }
472 
473  inline void
474  demean (pcl::PointWithRange& p, float value) const
475  {
476  p.range -= value;
477  }
478 
479  inline void
480  add (pcl::PointWithRange& p, float value) const
481  {
482  p.range += value;
483  }
484  };
485 
486  template<>
488  {
489  inline float
491  {
492  return (p.scale);
493  }
494 
495  inline void
496  get (const pcl::PointWithScale &p, float &intensity) const
497  {
498  intensity = p.scale;
499  }
500 
501  inline void
502  set (pcl::PointWithScale &p, float intensity) const
503  {
504  p.scale = intensity;
505  }
506 
507  inline void
508  demean (pcl::PointWithScale& p, float value) const
509  {
510  p.scale -= value;
511  }
512 
513  inline void
514  add (pcl::PointWithScale& p, float value) const
515  {
516  p.scale += value;
517  }
518  };
519 
520  template<>
522  {
523  inline float
525  {
526  return (p.z);
527  }
528 
529  inline void
530  get (const pcl::PointWithViewpoint &p, float &intensity) const
531  {
532  intensity = p.z;
533  }
534 
535  inline void
536  set (pcl::PointWithViewpoint &p, float intensity) const
537  {
538  p.z = intensity;
539  }
540 
541  inline void
542  demean (pcl::PointWithViewpoint& p, float value) const
543  {
544  p.z -= value;
545  }
546 
547  inline void
548  add (pcl::PointWithViewpoint& p, float value) const
549  {
550  p.z += value;
551  }
552  };
553 
554  template<>
556  {
557  inline float
559  {
560  return (p.curvature);
561  }
562 
563  inline void
564  get (const pcl::PointSurfel &p, float &intensity) const
565  {
566  intensity = p.curvature;
567  }
568 
569  inline void
570  set (pcl::PointSurfel &p, float intensity) const
571  {
572  p.curvature = intensity;
573  }
574 
575  inline void
576  demean (pcl::PointSurfel& p, float value) const
577  {
578  p.curvature -= value;
579  }
580 
581  inline void
582  add (pcl::PointSurfel& p, float value) const
583  {
584  p.curvature += value;
585  }
586  };
587  }
588 }
589 
Defines all the PCL implemented PointT point type structures.
float scale
Diameter of the meaningful keypoint neighborhood.
PCL_ADD_POINT4D std::uint32_t label
A point structure representing an interest point with Euclidean xyz coordinates, and an interest valu...
A point structure representing Euclidean xyz coordinates, together with normal coordinates and the su...
A surfel, that is, a point structure representing Euclidean xyz coordinates, together with normal coo...
A point structure representing Euclidean xyz coordinates, padded with an extra range float.
A point structure representing a 3-D position and scale.
A point structure representing Euclidean xyz coordinates together with the viewpoint from which it wa...
A point structure representing Euclidean xyz coordinates.
A point structure representing Euclidean xyz coordinates, and the CIELAB color.
A point structure representing Euclidean xyz coordinates, a label, together with normal coordinates a...
A point structure representing Euclidean xyz coordinates, and the RGBA color.
A point structure representing Euclidean xyz coordinates, and the RGB color.
A point structure representing Euclidean xyz coordinates, and the RGB color, together with normal coo...
void get(const pcl::InterestPoint &p, float &intensity) const
Definition: intensity.hpp:428
void demean(pcl::InterestPoint &p, float value) const
Definition: intensity.hpp:440
void set(pcl::InterestPoint &p, float intensity) const
Definition: intensity.hpp:434
void add(pcl::InterestPoint &p, float value) const
Definition: intensity.hpp:446
void add(pcl::PointNormal &p, float value) const
Definition: intensity.hpp:79
void demean(pcl::PointNormal &p, float value) const
Definition: intensity.hpp:73
void set(pcl::PointNormal &p, float intensity) const
Definition: intensity.hpp:67
void get(const pcl::PointNormal &p, float &intensity) const
Definition: intensity.hpp:61
void set(pcl::PointSurfel &p, float intensity) const
Definition: intensity.hpp:570
void get(const pcl::PointSurfel &p, float &intensity) const
Definition: intensity.hpp:564
void demean(pcl::PointSurfel &p, float value) const
Definition: intensity.hpp:576
void add(pcl::PointSurfel &p, float value) const
Definition: intensity.hpp:582
void demean(pcl::PointWithRange &p, float value) const
Definition: intensity.hpp:474
void add(pcl::PointWithRange &p, float value) const
Definition: intensity.hpp:480
void get(const pcl::PointWithRange &p, float &intensity) const
Definition: intensity.hpp:462
void set(pcl::PointWithRange &p, float intensity) const
Definition: intensity.hpp:468
void get(const pcl::PointWithScale &p, float &intensity) const
Definition: intensity.hpp:496
void demean(pcl::PointWithScale &p, float value) const
Definition: intensity.hpp:508
void add(pcl::PointWithScale &p, float value) const
Definition: intensity.hpp:514
void set(pcl::PointWithScale &p, float intensity) const
Definition: intensity.hpp:502
void add(pcl::PointWithViewpoint &p, float value) const
Definition: intensity.hpp:548
void demean(pcl::PointWithViewpoint &p, float value) const
Definition: intensity.hpp:542
void set(pcl::PointWithViewpoint &p, float intensity) const
Definition: intensity.hpp:536
void get(const pcl::PointWithViewpoint &p, float &intensity) const
Definition: intensity.hpp:530
void demean(pcl::PointXYZ &p, float value) const
Definition: intensity.hpp:107
void set(pcl::PointXYZ &p, float intensity) const
Definition: intensity.hpp:101
void get(const pcl::PointXYZ &p, float &intensity) const
Definition: intensity.hpp:95
void add(pcl::PointXYZ &p, float value) const
Definition: intensity.hpp:113
void get(const pcl::PointXYZHSV &p, float &intensity) const
Definition: intensity.hpp:323
void set(pcl::PointXYZHSV &p, float intensity) const
Definition: intensity.hpp:329
void demean(pcl::PointXYZHSV &p, float value) const
Definition: intensity.hpp:336
void add(pcl::PointXYZHSV &p, float value) const
Definition: intensity.hpp:342
void get(const pcl::PointXYZL &p, float &intensity) const
Definition: intensity.hpp:358
void demean(pcl::PointXYZL &p, float value) const
Definition: intensity.hpp:371
void set(pcl::PointXYZL &p, float intensity) const
Definition: intensity.hpp:364
void add(pcl::PointXYZL &p, float value) const
Definition: intensity.hpp:377
void get(const pcl::PointXYZLAB &p, float &intensity) const
Definition: intensity.hpp:289
void add(pcl::PointXYZLAB &p, float value) const
Definition: intensity.hpp:307
void set(pcl::PointXYZLAB &p, float intensity) const
Definition: intensity.hpp:295
void demean(pcl::PointXYZLAB &p, float value) const
Definition: intensity.hpp:301
void get(const pcl::PointXYZLNormal &p, float &intensity) const
Definition: intensity.hpp:393
void demean(pcl::PointXYZLNormal &p, float value) const
Definition: intensity.hpp:406
void set(pcl::PointXYZLNormal &p, float intensity) const
Definition: intensity.hpp:399
void add(pcl::PointXYZLNormal &p, float value) const
Definition: intensity.hpp:412
void demean(pcl::PointXYZRGB &p, float value) const
Definition: intensity.hpp:143
void set(pcl::PointXYZRGB &p, float intensity) const
Definition: intensity.hpp:135
void add(pcl::PointXYZRGB &p, float value) const
Definition: intensity.hpp:151
void get(const pcl::PointXYZRGB &p, float &intensity) const
Definition: intensity.hpp:129
void add(pcl::PointXYZRGBA &p, float value) const
Definition: intensity.hpp:191
void set(pcl::PointXYZRGBA &p, float intensity) const
Definition: intensity.hpp:175
void get(const pcl::PointXYZRGBA &p, float &intensity) const
Definition: intensity.hpp:169
void demean(pcl::PointXYZRGBA &p, float value) const
Definition: intensity.hpp:183
void get(const pcl::PointXYZRGBL &p, float &intensity) const
Definition: intensity.hpp:249
void add(pcl::PointXYZRGBL &p, float value) const
Definition: intensity.hpp:271
void demean(pcl::PointXYZRGBL &p, float value) const
Definition: intensity.hpp:263
void set(pcl::PointXYZRGBL &p, float intensity) const
Definition: intensity.hpp:255
void get(const pcl::PointXYZRGBNormal &p, float &intensity) const
Definition: intensity.hpp:209
void set(pcl::PointXYZRGBNormal &p, float intensity) const
Definition: intensity.hpp:215
void add(pcl::PointXYZRGBNormal &p, float value) const
Definition: intensity.hpp:231
void demean(pcl::PointXYZRGBNormal &p, float value) const
Definition: intensity.hpp:223
float operator()(const PointT &p) const
get intensity field
Definition: intensity.h:57
void set(PointT &p, float intensity) const
sets the intensity value of a point
Definition: intensity.h:75