43 #include <pcl/field_traits.h>
44 #include <pcl/point_cloud.h>
47 #include <pcl/common/colors.h>
64 out.x = in.x; out.y = in.y; out.z = in.z;
65 out.
intensity = 0.299f *
static_cast <float> (in.r) + 0.587f *
static_cast <float> (in.g) + 0.114f *
static_cast <float> (in.b);
76 out.intensity = 0.299f *
static_cast <float> (in.r) + 0.587f *
static_cast <float> (in.g) + 0.114f *
static_cast <float> (in.b);
87 out.intensity =
static_cast<std::uint8_t
>(0.299f *
static_cast <float> (in.r)
88 + 0.587f *
static_cast <float> (in.g) + 0.114f *
static_cast <float> (in.b));
99 out.intensity =
static_cast<std::uint32_t
>(0.299f *
static_cast <float> (in.r)
100 + 0.587f *
static_cast <float> (in.g) + 0.114f *
static_cast <float> (in.b));
111 const unsigned char max = std::max (in.r, std::max (in.g, in.b));
112 const unsigned char min = std::min (in.r, std::min (in.g, in.b));
114 out.x = in.x; out.y = in.y; out.z = in.z;
115 out.
v =
static_cast <float> (max) / 255.f;
124 const float diff =
static_cast <float> (max - min);
125 out.
s = diff /
static_cast <float> (max);
133 if (max == in.r) out.
h = 60.f * (
static_cast <float> (in.g - in.b) / diff);
134 else if (max == in.g) out.
h = 60.f * (2.f +
static_cast <float> (in.b - in.r) / diff);
135 else out.
h = 60.f * (4.f +
static_cast <float> (in.r - in.g) / diff);
137 if (out.
h < 0.f) out.
h += 360.f;
144 template <
typename Po
intT, traits::HasColor<Po
intT> = true>
159 const auto& sRGB_LUT = RGB2sRGB_LUT<double, 8>();
161 const double R = sRGB_LUT[in.r];
162 const double G = sRGB_LUT[in.g];
163 const double B = sRGB_LUT[in.b];
166 const double X = R * 0.4124 + G * 0.3576 +
B * 0.1805;
167 const double Y = R * 0.2126 + G * 0.7152 +
B * 0.0722;
168 const double Z = R * 0.0193 + G * 0.1192 +
B * 0.9505;
171 float f[3] = {
static_cast<float>(X),
static_cast<float>(Y),
static_cast<float>(Z)};
177 for (
float & xyz : f) {
178 if (xyz > 0.008856) {
179 xyz = std::pow(xyz, 1.0 / 3.0);
182 xyz = 7.787 * xyz + 16.0 / 116.0;
186 out.
L = 116.0f * f[1] - 16.0f;
187 out.
a = 500.0f * (f[0] - f[1]);
188 out.
b = 200.0f * (f[1] - f[2]);
200 const unsigned char max = std::max (in.r, std::max (in.g, in.b));
201 const unsigned char min = std::min (in.r, std::min (in.g, in.b));
203 out.x = in.x; out.y = in.y; out.z = in.z;
204 out.
v =
static_cast <float> (max) / 255.f;
213 const float diff =
static_cast <float> (max - min);
214 out.
s = diff /
static_cast <float> (max);
222 if (max == in.r) out.
h = 60.f * (
static_cast <float> (in.g - in.b) / diff);
223 else if (max == in.g) out.
h = 60.f * (2.f +
static_cast <float> (in.b - in.r) / diff);
224 else out.
h = 60.f * (4.f +
static_cast <float> (in.r - in.g) / diff);
226 if (out.
h < 0.f) out.
h += 360.f;
237 out.x = in.x; out.y = in.y; out.z = in.z;
240 out.r = out.g = out.b =
static_cast<std::uint8_t
> (255 * in.
v);
244 int i =
static_cast<int> (std::floor (a));
245 float f = a -
static_cast<float> (i);
246 float p = in.
v * (1 - in.
s);
247 float q = in.
v * (1 - in.
s * f);
248 float t = in.
v * (1 - in.
s * (1 - f));
254 out.r =
static_cast<std::uint8_t
> (255 * in.
v);
255 out.g =
static_cast<std::uint8_t
> (255 * t);
256 out.b =
static_cast<std::uint8_t
> (255 * p);
261 out.r =
static_cast<std::uint8_t
> (255 * q);
262 out.g =
static_cast<std::uint8_t
> (255 * in.
v);
263 out.b =
static_cast<std::uint8_t
> (255 * p);
268 out.r =
static_cast<std::uint8_t
> (255 * p);
269 out.g =
static_cast<std::uint8_t
> (255 * in.
v);
270 out.b =
static_cast<std::uint8_t
> (255 * t);
275 out.r =
static_cast<std::uint8_t
> (255 * p);
276 out.g =
static_cast<std::uint8_t
> (255 * q);
277 out.b =
static_cast<std::uint8_t
> (255 * in.
v);
282 out.r =
static_cast<std::uint8_t
> (255 * t);
283 out.g =
static_cast<std::uint8_t
> (255 * p);
284 out.b =
static_cast<std::uint8_t
> (255 * in.
v);
289 out.r =
static_cast<std::uint8_t
> (255 * in.
v);
290 out.g =
static_cast<std::uint8_t
> (255 * p);
291 out.b =
static_cast<std::uint8_t
> (255 * q);
307 for (
const auto &point : in)
325 for (
const auto &point : in)
343 for (
const auto &point : in)
361 for (
const auto &point : in)
379 for (
const auto &point : in)
397 for (
const auto &point : in)
415 for (
const auto &point : in)
435 float bad_point = std::numeric_limits<float>::quiet_NaN();
436 std::size_t width_ = depth.
width;
437 std::size_t height_ = depth.
height;
438 float constant_ = 1.0f / focal;
440 for (std::size_t v = 0; v < height_; v++)
442 for (std::size_t u = 0; u < width_; u++)
445 float depth_ = depth.
at (u, v).intensity;
449 pt.x = pt.y = pt.z = bad_point;
453 pt.z = depth_ * 0.001f;
454 pt.x =
static_cast<float> (u) * pt.z * constant_;
455 pt.y =
static_cast<float> (v) * pt.z * constant_;
457 pt.r = image.
at (u, v).r;
458 pt.g = image.
at (u, v).g;
459 pt.b = image.
at (u, v).b;
void push_back(const PointT &pt)
Insert a new point in the cloud, at the end of the container.
const PointT & at(int column, int row) const
Obtain the point given by the (column, row) coordinates.
std::uint32_t width
The point cloud width (if organized as an image-structure).
std::uint32_t height
The point cloud height (if organized as an image-structure).
Defines all the PCL implemented PointT point type structures.
void PointXYZRGBtoXYZLAB(const PointT &in, PointXYZLAB &out)
Convert a XYZRGB-based point type to a XYZLAB.
void PointCloudXYZHSVtoXYZRGB(const PointCloud< PointXYZHSV > &in, PointCloud< PointXYZRGB > &out)
Convert a XYZHSV point cloud to a XYZRGB.
void PointCloudRGBtoI(const PointCloud< RGB > &in, PointCloud< Intensity > &out)
Convert a RGB point cloud to an Intensity.
void PointCloudXYZRGBAtoXYZHSV(const PointCloud< PointXYZRGBA > &in, PointCloud< PointXYZHSV > &out)
Convert a XYZRGB point cloud to a XYZHSV.
void PointXYZRGBtoXYZHSV(const PointXYZRGB &in, PointXYZHSV &out)
Convert a XYZRGB point type to a XYZHSV.
void PointXYZHSVtoXYZRGB(const PointXYZHSV &in, PointXYZRGB &out)
void PointXYZRGBAtoXYZHSV(const PointXYZRGBA &in, PointXYZHSV &out)
Convert a XYZRGBA point type to a XYZHSV.
void PointRGBtoI(const RGB &in, Intensity &out)
Convert a RGB point type to a I.
void PointCloudDepthAndRGBtoXYZRGBA(const PointCloud< Intensity > &depth, const PointCloud< RGB > &image, const float &focal, PointCloud< PointXYZRGBA > &out)
Convert registered Depth image and RGB image to PointCloudXYZRGBA.
void PointXYZRGBtoXYZI(const PointXYZRGB &in, PointXYZI &out)
Convert a XYZRGB point type to a XYZI.
void PointCloudXYZRGBtoXYZHSV(const PointCloud< PointXYZRGB > &in, PointCloud< PointXYZHSV > &out)
Convert a XYZRGB point cloud to a XYZHSV.
void PointCloudXYZRGBtoXYZI(const PointCloud< PointXYZRGB > &in, PointCloud< PointXYZI > &out)
Convert a XYZRGB point cloud to a XYZI.
A point structure representing the grayscale intensity in single-channel images.
A point structure representing the grayscale intensity in single-channel images.
A point structure representing the grayscale intensity in single-channel images.
A point structure representing Euclidean xyz coordinates, and the CIELAB color.
A point structure representing Euclidean xyz coordinates, and the RGBA color.
A point structure representing Euclidean xyz coordinates, and the RGB color.
A structure representing RGB color information.