Skip to content

Commit

Permalink
Removed randomized color behavior, switched to modulo GLASBEY_LUT_SIZ…
Browse files Browse the repository at this point in the history
…E as discussed in #849
  • Loading branch information
jpapon committed Oct 2, 2014
1 parent 3f0d3b1 commit 4e2238d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 40 deletions.
3 changes: 0 additions & 3 deletions common/include/pcl/common/colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ namespace pcl
RGB
getGlasbeyColor (unsigned int color_id);

RGB
getRandomColor (double min = 0.2, double max = 2.8);

}

#endif /* PCL_COMMON_COLORS_H */
Expand Down
23 changes: 0 additions & 23 deletions common/src/colors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,26 +315,3 @@ pcl::getGlasbeyColor (unsigned int color_id)
color.b = GLASBEY_LUT[color_id * 3 + 2];
return (color);
}

pcl::RGB
pcl::getRandomColor (double min, double max)
{
double sum;
static unsigned stepRGBA = 100;
double r, g, b;
do
{
sum = 0;
r = (rand () % stepRGBA) / static_cast<double> (stepRGBA);
while ((g = (rand () % stepRGBA) / static_cast<double> (stepRGBA)) == r) {}
while (((b = (rand () % stepRGBA) / static_cast<double> (stepRGBA)) == r) && (b == g)) {}
sum = r + g + b;
}
while (sum <= min || sum >= max);
pcl::RGB color;
color.r = uint8_t (r * 255.0);
color.g = uint8_t (g * 255.0);
color.b = uint8_t (b * 255.0);
return (color);
}

Original file line number Diff line number Diff line change
Expand Up @@ -531,13 +531,8 @@ pcl::visualization::PointCloudColorHandlerLabelField<PointT>::getColor (vtkSmart

// Assign Glasbey colors in ascending order of labels
size_t color = 0;
for (std::set<uint32_t>::iterator iter = labels.begin (); iter != labels.end (); ++iter)
{
if (color < GLASBEY_LUT_SIZE)
colormap[*iter] = getGlasbeyColor (color++);
else
colormap[*iter] = getRandomColor ();
}
for (std::set<uint32_t>::iterator iter = labels.begin (); iter != labels.end (); ++iter, ++color)
colormap[*iter] = getGlasbeyColor (color % GLASBEY_LUT_SIZE);

int j = 0;
for (vtkIdType cp = 0; cp < nr_points; ++cp)
Expand Down
9 changes: 2 additions & 7 deletions visualization/src/point_cloud_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,13 +628,8 @@ pcl::visualization::PointCloudColorHandlerLabelField<pcl::PCLPointCloud2>::getCo

// Assign Glasbey colors in ascending order of labels
size_t color = 0;
for (std::set<uint32_t>::iterator iter = labels.begin (); iter != labels.end (); ++iter)
{
if (color < GLASBEY_LUT_SIZE)
colormap[*iter] = getGlasbeyColor (color++);
else
colormap[*iter] = getRandomColor ();
}
for (std::set<uint32_t>::iterator iter = labels.begin (); iter != labels.end (); ++iter, ++color)
colormap[*iter] = getGlasbeyColor (color % GLASBEY_LUT_SIZE);

// If XYZ present, check if the points are invalid
int x_idx = pcl::getFieldIndex (*cloud_, "x");
Expand Down

0 comments on commit 4e2238d

Please sign in to comment.