60 template<
typename Po
intT>
75 output_ (), colorBitReduction_ (0)
92 colorBitReduction_ =
static_cast<unsigned char> (8 - bitDepth_arg);
101 return (
static_cast<unsigned char> (8 - colorBitReduction_));
110 pointAvgColorDataVector_.reserve (voxelCount_arg * 3);
120 pointDiffColorDataVector_.reserve (pointCount_arg * 3);
128 pointAvgColorDataVector_.clear ();
130 pointDiffColorDataVector_.clear ();
138 pointAvgColorDataVector_Iterator_ = pointAvgColorDataVector_.begin ();
140 pointDiffColorDataVector_Iterator_ = pointDiffColorDataVector_.begin ();
148 return pointAvgColorDataVector_;
156 return pointDiffColorDataVector_;
165 encodeAverageOfPoints (
const typename std::vector<int>& indexVector_arg,
unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg)
167 unsigned int avgRed = 0;
168 unsigned int avgGreen = 0;
169 unsigned int avgBlue = 0;
172 std::size_t len = indexVector_arg.size ();
173 for (std::size_t i = 0; i < len; i++)
176 const int& idx = indexVector_arg[i];
177 const char* idxPointPtr =
reinterpret_cast<const char*
> (&inputCloud_arg->points[idx]);
178 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
181 avgRed += (colorInt >> 0) & 0xFF;
182 avgGreen += (colorInt >> 8) & 0xFF;
183 avgBlue += (colorInt >> 16) & 0xFF;
190 avgRed /=
static_cast<unsigned int> (len);
191 avgGreen /=
static_cast<unsigned int> (len);
192 avgBlue /=
static_cast<unsigned int> (len);
196 avgRed >>= colorBitReduction_;
197 avgGreen >>= colorBitReduction_;
198 avgBlue >>= colorBitReduction_;
201 pointAvgColorDataVector_.push_back (
static_cast<char> (avgRed));
202 pointAvgColorDataVector_.push_back (
static_cast<char> (avgGreen));
203 pointAvgColorDataVector_.push_back (
static_cast<char> (avgBlue));
212 encodePoints (
const typename std::vector<int>& indexVector_arg,
unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg)
215 unsigned int avgGreen;
216 unsigned int avgBlue;
219 avgRed = avgGreen = avgBlue = 0;
222 std::size_t len = indexVector_arg.size ();
223 for (std::size_t i = 0; i < len; i++)
226 const int& idx = indexVector_arg[i];
227 const char* idxPointPtr =
reinterpret_cast<const char*
> (&inputCloud_arg->points[idx]);
228 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
231 avgRed += (colorInt >> 0) & 0xFF;
232 avgGreen += (colorInt >> 8) & 0xFF;
233 avgBlue += (colorInt >> 16) & 0xFF;
239 unsigned char diffRed;
240 unsigned char diffGreen;
241 unsigned char diffBlue;
244 avgRed /=
static_cast<unsigned int> (len);
245 avgGreen /=
static_cast<unsigned int> (len);
246 avgBlue /=
static_cast<unsigned int> (len);
249 for (std::size_t i = 0; i < len; i++)
251 const int& idx = indexVector_arg[i];
252 const char* idxPointPtr =
reinterpret_cast<const char*
> (&inputCloud_arg->points[idx]);
253 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
256 diffRed = (
static_cast<unsigned char> (avgRed)) ^
static_cast<unsigned char> (((colorInt >> 0) & 0xFF));
257 diffGreen = (
static_cast<unsigned char> (avgGreen)) ^
static_cast<unsigned char> (((colorInt >> 8) & 0xFF));
258 diffBlue = (
static_cast<unsigned char> (avgBlue)) ^
static_cast<unsigned char> (((colorInt >> 16) & 0xFF));
261 diffRed =
static_cast<unsigned char> (diffRed >> colorBitReduction_);
262 diffGreen =
static_cast<unsigned char> (diffGreen >> colorBitReduction_);
263 diffBlue =
static_cast<unsigned char> (diffBlue >> colorBitReduction_);
266 pointDiffColorDataVector_.push_back (
static_cast<char> (diffRed));
267 pointDiffColorDataVector_.push_back (
static_cast<char> (diffGreen));
268 pointDiffColorDataVector_.push_back (
static_cast<char> (diffBlue));
273 avgRed >>= colorBitReduction_;
274 avgGreen >>= colorBitReduction_;
275 avgBlue >>= colorBitReduction_;
278 pointAvgColorDataVector_.push_back (
static_cast<char> (avgRed));
279 pointAvgColorDataVector_.push_back (
static_cast<char> (avgGreen));
280 pointAvgColorDataVector_.push_back (
static_cast<char> (avgBlue));
291 decodePoints (PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg,
unsigned char rgba_offset_arg)
293 assert (beginIdx_arg <= endIdx_arg);
296 unsigned int pointCount =
static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
299 unsigned char avgRed = *(pointAvgColorDataVector_Iterator_++);
300 unsigned char avgGreen = *(pointAvgColorDataVector_Iterator_++);
301 unsigned char avgBlue = *(pointAvgColorDataVector_Iterator_++);
304 avgRed =
static_cast<unsigned char> (avgRed << colorBitReduction_);
305 avgGreen =
static_cast<unsigned char> (avgGreen << colorBitReduction_);
306 avgBlue =
static_cast<unsigned char> (avgBlue << colorBitReduction_);
309 for (std::size_t i = 0; i < pointCount; i++)
311 unsigned int colorInt;
315 unsigned char diffRed =
static_cast<unsigned char> (*(pointDiffColorDataVector_Iterator_++));
316 unsigned char diffGreen =
static_cast<unsigned char> (*(pointDiffColorDataVector_Iterator_++));
317 unsigned char diffBlue =
static_cast<unsigned char> (*(pointDiffColorDataVector_Iterator_++));
320 diffRed =
static_cast<unsigned char> (diffRed << colorBitReduction_);
321 diffGreen =
static_cast<unsigned char> (diffGreen << colorBitReduction_);
322 diffBlue =
static_cast<unsigned char> (diffBlue << colorBitReduction_);
325 colorInt = ((avgRed ^ diffRed) << 0) |
326 ((avgGreen ^ diffGreen) << 8) |
327 ((avgBlue ^ diffBlue) << 16);
332 colorInt = (avgRed << 0) | (avgGreen << 8) | (avgBlue << 16);
335 char* idxPointPtr =
reinterpret_cast<char*
> (&outputCloud_arg->points[beginIdx_arg + i]);
336 int& pointColor = *
reinterpret_cast<int*
> (idxPointPtr+rgba_offset_arg);
349 setDefaultColor (PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg,
unsigned char rgba_offset_arg)
351 assert (beginIdx_arg <= endIdx_arg);
354 unsigned int pointCount =
static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
357 for (std::size_t i = 0; i < pointCount; i++)
359 char* idxPointPtr =
reinterpret_cast<char*
> (&outputCloud_arg->points[beginIdx_arg + i]);
360 int& pointColor = *
reinterpret_cast<int*
> (idxPointPtr+rgba_offset_arg);
362 pointColor = defaultColor_;
393 template<
typename Po
intT>
401 #define PCL_INSTANTIATE_ColorCoding(T) template class PCL_EXPORTS pcl::octree::ColorCoding<T>;