141 std::vector<pcl::PCLPointField> fields;
145 const std::size_t offset = fields[field_idx].offset;
152 img.
width = cloud.width;
153 img.
height = cloud.height;
154 img.
step = img.
width *
sizeof (
unsigned short);
156 unsigned short* data =
reinterpret_cast<unsigned short*
>(&img.
data[0]);
157 for (std::size_t i = 0; i < cloud.size (); ++i)
161 data[i] =
static_cast<unsigned short>(val);
165 case COLORS_RGB_RANDOM:
168 img.
width = cloud.width;
169 img.
height = cloud.height;
170 img.
step = img.
width *
sizeof (
unsigned char) * 3;
173 std::srand(std::time(
nullptr));
174 std::map<std::uint32_t, std::size_t> colormap;
176 for (std::size_t i = 0; i < cloud.size (); ++i)
180 if (colormap.count (val) == 0)
182 colormap[val] = i * 3;
183 img.
data[i * 3 + 0] =
static_cast<std::uint8_t
> ((std::rand () % 256));
184 img.
data[i * 3 + 1] =
static_cast<std::uint8_t
> ((std::rand () % 256));
185 img.
data[i * 3 + 2] =
static_cast<std::uint8_t
> ((std::rand () % 256));
189 memcpy (&img.
data[i * 3], &img.
data[colormap[val]], 3);
194 case COLORS_RGB_GLASBEY:
197 img.
width = cloud.width;
198 img.
height = cloud.height;
199 img.
step = img.
width *
sizeof (
unsigned char) * 3;
202 std::srand(std::time(
nullptr));
203 std::set<std::uint32_t> labels;
204 std::map<std::uint32_t, std::size_t> colormap;
207 for (
const auto& point: cloud)
220 std::size_t color = 0;
221 for (
const std::uint32_t &label : labels)
223 colormap[label] = color % GlasbeyLUT::size ();
228 for (std::size_t i = 0; i < cloud.size (); ++i)
232 memcpy (&img.
data[i * 3], GlasbeyLUT::data () + colormap[val] * 3, 3);
246 std::vector<pcl::PCLPointField> fields;
250 const std::size_t offset = fields[field_idx].offset;
253 img.
width = cloud.width;
254 img.
height = cloud.height;
255 img.
step = img.
width *
sizeof (
unsigned short);
257 unsigned short* data =
reinterpret_cast<unsigned short*
>(&img.
data[0]);
259 float scaling_factor = scaling_factor_;
260 float data_min = 0.0f;
261 if (scaling_method_ == SCALING_FULL_RANGE)
263 float min = std::numeric_limits<float>::infinity();
264 float max = -std::numeric_limits<float>::infinity();
265 for (
const auto& point: cloud)
274 scaling_factor = min == max ? 0 : std::numeric_limits<unsigned short>::max() / (max - min);
278 for (std::size_t i = 0; i < cloud.size (); ++i)
282 if (scaling_method_ == SCALING_NO)
286 else if (scaling_method_ == SCALING_FULL_RANGE)
288 data[i] = (val - data_min) * scaling_factor;
290 else if (scaling_method_ == SCALING_FIXED_FACTOR)
292 data[i] = val * scaling_factor;