141 std::vector<pcl::PCLPointField> fields;
145 const std::size_t offset = fields[
field_idx].offset;
151 img.encoding =
"mono16";
152 img.width = cloud.width;
153 img.height = cloud.height;
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:
167 img.encoding =
"rgb8";
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)
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));
194 case COLORS_RGB_GLASBEY:
196 img.encoding =
"rgb8";
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)
228 for (std::size_t i = 0; i < cloud.size (); ++i)
246 std::vector<pcl::PCLPointField> fields;
250 const std::size_t offset = fields[
field_idx].offset;
252 img.encoding =
"mono16";
253 img.width = cloud.width;
254 img.height = cloud.height;
257 unsigned short* data =
reinterpret_cast<unsigned short*
>(&
img.data[0]);
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)
290 else if (scaling_method_ == SCALING_FIXED_FACTOR)