pcl icon indicating copy to clipboard operation
pcl copied to clipboard

pcl::PassThrough<pcl::PointXYZRGB> for the rgb field should filter on the rgb intensity/grayscale value

Open 1ros0 opened this issue 3 years ago • 5 comments

Hi,

Applying the pcl::PassThrough to a pcl::PointXYZRGB on the "rgb" field results in unintuitive/meaningless behavior. The filter checks against the float representation of the rgb field which isn't a meaningful number when considering a min and max filter range.

Here is the float representation: std::uint8_t r = 255, g = 0, b = 0; // Example: Red color std::uint32_t rgb = ((std::uint32_t)r << 16 | (std::uint32_t)g << 8 | (std::uint32_t)b); p.rgb = *reinterpret_cast<float*>(&rgb); Comparing against this representation doesn't result in filtering values, in the manner the caller would expect. For instance, the above red color example results in a really large negative number when represented as a float.

Todo: The passthrough filter for the "rgb" field should convert the rgb value into a intensity/grayscale value and then filter min and max based on that grayscale value.

Thank you

1ros0 avatar Jul 15 '22 05:07 1ros0

The passthrough filter for the "rgb" field should convert the rgb value into a intensity/grayscale value and then filter min and max based on that grayscale value

IMO, if it did that automatically, that wouldn't be so intuitive either. You can of course convert your cloud to a cloud of pcl::PointXYZI and pass that to the filter. I'm not really sure what you expect when you tell the filter to keep all points where the "rgb" value is in a certain range, when you know those are actually three values packed into a float? The PassThrough isn't really meant to dealt with more complex situations like this, see here for more suggestions what you can do: https://stackoverflow.com/questions/72878613/passing-unit8-to-pclpassthrough

mvieth avatar Jul 15 '22 07:07 mvieth

Hmm so maybe if filtering on the RGB field is requested the filter function should return an error?

On a slightly different note, based on the page you linked, if the pass through filter is requested on non-float fields that might exist in other point types, then too, it should return an error. The answer on the page you linked shows that current functionality only works for float fields.

On Fri, Jul 15, 2022, 3:33 AM Markus Vieth @.***> wrote:

The passthrough filter for the "rgb" field should convert the rgb value into a intensity/grayscale value and then filter min and max based on that grayscale value

IMO, if it did that automatically, that wouldn't be so intuitive either. You can of course convert your cloud to a cloud of pcl::PointXYZI and pass that to the filter. I'm not really sure what you expect when you tell the filter to keep all points where the "rgb" value is in a certain range, when you know those are actually three values packed into a float? The PassThrough isn't really meant to dealt with more complex situations like this, see here for more suggestions what you can do: https://stackoverflow.com/questions/72878613/passing-unit8-to-pclpassthrough

— Reply to this email directly, view it on GitHub https://github.com/PointCloudLibrary/pcl/issues/5328#issuecomment-1185263787, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASLGV5BJGZGXZGXC2NQK5O3VUEH4TANCNFSM53UL3VTQ . You are receiving this because you authored the thread.Message ID: @.***>

1ros0 avatar Jul 15 '22 08:07 1ros0

@1ros0 That sounds like a good idea (maybe only a warning for rgb, error for non-float fields). Would you be interested in opening a pull request for this?

mvieth avatar Jul 15 '22 11:07 mvieth

Yeah, I could code something up

1ros0 avatar Jul 15 '22 18:07 1ros0

@1ros0 Are you still planning to open a pull request?

mvieth avatar Aug 11 '22 07:08 mvieth