[WIP] Set default alpha value to 255#1141
[WIP] Set default alpha value to 255#1141VictorLamoine wants to merge 1 commit intoPointCloudLibrary:masterfrom VictorLamoine:vtk
Conversation
|
Yes, it is logical. I wondered why it was not done before and found the following two commits in the history. The first one defaulted alpha to 255 everywhere, and the second one reverted it. I am not sure why the float <-> integer cast mentioned in the commit comment is important and how exactly it affects user code. Perhaps @rbrusu could elaborate on that... |
|
Afair the problem was really the "float<->integer RGB casts precision" as Radu wrote in the commit message. The best thing would be to save RGB as three int... |
|
Hello there, I just came across this issue, since some of my saved point clouds strangely contain huge amounts of red points. I dug around a bit and here's what I found out so far:
This leads to the problem that a whole bunch of values are being mapped to NaNs, namely fully opaque and half opaque values with red bigger than or equal to128 ( Cheers, PS.: Here are some tests on the issue: #include <iostream>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
using namespace std;
using namespace pcl;
int main (int argc, char* argv[])
{
// Use PointXYZRGB because all of its fields are written as floats by default by PCDWriter
PointCloud<PointXYZRGB> cloud;
cloud.resize(9);
cloud.points[0].rgba = 0x00FF0000; // finite value
cloud.points[1].rgba = 0x0000FF00; // finite value
cloud.points[2].rgba = 0x000000FF; // finite value
cloud.points[3].rgba = 0xFF800000; // 255, 128, 0, 0 → -inf
cloud.points[4].rgba = 0xFF80F0F0; // 255, 128, 240, 240 → nan
cloud.points[5].rgba = 0xFFC00000; // 255, 192, 0, 0 → nan
cloud.points[6].rgba = 0xFFC0F0F0; // 255, 192, 240, 240 → nan
cloud.points[7].rgba = 0x7F800000; // 127, 128, 0, 0 → +inf
cloud.points[8].rgba = 0x7F80F0F0; // 127, 128, 240, 240 → nan
PCDWriter writer;
writer.writeASCII("xyzrgb.pcd", cloud);
return 0;
}The saved xyzrgb.pcd file: |
|
Oooor, one could initialize the alpha with 255 in every class/struct and write RGB(A) only data as The feature of reading RGB(A) data as floats should be kept for backward compatibility. What do you think? Cheers, |
|
Stefan, nice analysis. I prefer the first option, it's a bit hacky, but elegant. |
|
@jspricke ... and here. Thanks! |
|
I would love to see the second option implemented. @stefanbuettner if you have time to do that, it would be really great. Otherwise, I'm ok with the first option as well. @VictorLamoine do you want to update this pull request, or should we do it in a new one? |
|
Stefan should open a new pull request: it's his work, not mine! |
|
Okay, I'll try. |
I think we should set the alpha value to 255 in the pcl::RGB struct.
This fixes the second test case of #1040.