43 #include <pcl/point_cloud.h>
46 #include <pcl/common/colors.h>
63 out.x = in.x; out.y = in.y; out.z = in.z;
64 out.
intensity = 0.299f *
static_cast <float> (in.r) + 0.587f *
static_cast <float> (in.g) + 0.114f *
static_cast <float> (in.b);
75 out.intensity = 0.299f *
static_cast <float> (in.r) + 0.587f *
static_cast <float> (in.g) + 0.114f *
static_cast <float> (in.b);
86 out.intensity =
static_cast<std::uint8_t
>(0.299f *
static_cast <float> (in.r)
87 + 0.587f *
static_cast <float> (in.g) + 0.114f *
static_cast <float> (in.b));
98 out.intensity =
static_cast<std::uint32_t
>(0.299f *
static_cast <float> (in.r)
99 + 0.587f *
static_cast <float> (in.g) + 0.114f *
static_cast <float> (in.b));
110 const unsigned char max = std::max (in.r, std::max (in.g, in.b));
111 const unsigned char min = std::min (in.r, std::min (in.g, in.b));
113 out.x = in.x; out.y = in.y; out.z = in.z;
114 out.
v =
static_cast <float> (max) / 255.f;
123 const float diff =
static_cast <float> (max - min);
124 out.
s = diff /
static_cast <float> (max);
132 if (max == in.r) out.
h = 60.f * (
static_cast <float> (in.g - in.b) / diff);
133 else if (max == in.g) out.
h = 60.f * (2.f +
static_cast <float> (in.b - in.r) / diff);
134 else out.
h = 60.f * (4.f +
static_cast <float> (in.r - in.g) / diff);
136 if (out.
h < 0.f) out.
h += 360.f;
143 template <
typename Po
intT, traits::HasColor<Po
intT> = true>
158 const auto& sRGB_LUT = RGB2sRGB_LUT<double, 8>();
160 const double R = sRGB_LUT[in.r];
161 const double G = sRGB_LUT[in.g];
162 const double B = sRGB_LUT[in.b];
165 const double X = R * 0.4124 + G * 0.3576 +
B * 0.1805;
166 const double Y = R * 0.2126 + G * 0.7152 +
B * 0.0722;
167 const double Z = R * 0.0193 + G * 0.1192 +
B * 0.9505;
170 float f[3] = {
static_cast<float>(X),
static_cast<float>(Y),
static_cast<float>(Z)};
176 for (
float & xyz : f) {
177 if (xyz > 0.008856) {
178 xyz = std::pow(xyz, 1.0 / 3.0);
181 xyz = 7.787 * xyz + 16.0 / 116.0;
185 out.
L = 116.0f * f[1] - 16.0f;
186 out.
a = 500.0f * (f[0] - f[1]);
187 out.
b = 200.0f * (f[1] - f[2]);
199 const unsigned char max = std::max (in.r, std::max (in.g, in.b));
200 const unsigned char min = std::min (in.r, std::min (in.g, in.b));
202 out.x = in.x; out.y = in.y; out.z = in.z;
203 out.
v =
static_cast <float> (max) / 255.f;
212 const float diff =
static_cast <float> (max - min);
213 out.
s = diff /
static_cast <float> (max);
221 if (max == in.r) out.
h = 60.f * (
static_cast <float> (in.g - in.b) / diff);
222 else if (max == in.g) out.
h = 60.f * (2.f +
static_cast <float> (in.b - in.r) / diff);
223 else out.
h = 60.f * (4.f +
static_cast <float> (in.r - in.g) / diff);
225 if (out.
h < 0.f) out.
h += 360.f;
236 out.x = in.x; out.y = in.y; out.z = in.z;
239 out.r = out.g = out.b =
static_cast<std::uint8_t
> (255 * in.
v);
243 int i =
static_cast<int> (std::floor (a));
244 float f = a -
static_cast<float> (i);
245 float p = in.
v * (1 - in.
s);
246 float q = in.
v * (1 - in.
s * f);
247 float t = in.
v * (1 - in.
s * (1 - f));
253 out.r =
static_cast<std::uint8_t
> (255 * in.
v);
254 out.g =
static_cast<std::uint8_t
> (255 * t);
255 out.b =
static_cast<std::uint8_t
> (255 * p);
260 out.r =
static_cast<std::uint8_t
> (255 * q);
261 out.g =
static_cast<std::uint8_t
> (255 * in.
v);
262 out.b =
static_cast<std::uint8_t
> (255 * p);
267 out.r =
static_cast<std::uint8_t
> (255 * p);
268 out.g =
static_cast<std::uint8_t
> (255 * in.
v);
269 out.b =
static_cast<std::uint8_t
> (255 * t);
274 out.r =
static_cast<std::uint8_t
> (255 * p);
275 out.g =
static_cast<std::uint8_t
> (255 * q);
276 out.b =
static_cast<std::uint8_t
> (255 * in.
v);
281 out.r =
static_cast<std::uint8_t
> (255 * t);
282 out.g =
static_cast<std::uint8_t
> (255 * p);
283 out.b =
static_cast<std::uint8_t
> (255 * in.
v);
288 out.r =
static_cast<std::uint8_t
> (255 * in.
v);
289 out.g =
static_cast<std::uint8_t
> (255 * p);
290 out.b =
static_cast<std::uint8_t
> (255 * q);
306 for (
const auto &point : in)
324 for (
const auto &point : in)
342 for (
const auto &point : in)
360 for (
const auto &point : in)
378 for (
const auto &point : in)
396 for (
const auto &point : in)
414 for (
const auto &point : in)
434 float bad_point = std::numeric_limits<float>::quiet_NaN();
435 std::size_t width_ = depth.
width;
436 std::size_t height_ = depth.
height;
437 float constant_ = 1.0f / focal;
439 for (std::size_t v = 0; v < height_; v++)
441 for (std::size_t u = 0; u < width_; u++)
444 float depth_ = depth.
at (u, v).intensity;
448 pt.x = pt.y = pt.z = bad_point;
452 pt.z = depth_ * 0.001f;
453 pt.x =
static_cast<float> (u) * pt.z * constant_;
454 pt.y =
static_cast<float> (v) * pt.z * constant_;
456 pt.r = image.
at (u, v).r;
457 pt.g = image.
at (u, v).g;
458 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.