CloudCompare icon indicating copy to clipboard operation
CloudCompare copied to clipboard

Integer scalar fields are exported as float (ply)

Open karlHolmquist opened this issue 3 years ago • 3 comments

When creating a scalar field for classification, e.g. using the segmentation tool. The values are represented as integers in cloudcompare (as expected). However, when exporting the classified point cloud to .ply, the field is converted to float.

Steps to reproduce the behaviour:

  1. Open a pointcloud
  2. Use the segmentation tool to create a new classification field and segment part of the cloud in any class
  3. Save the classified pointcloud as .ply through the save menu
  4. See that all scalar fields are converted to float in the header of the generated ply-file

Expected behaviour Integer scalar fields such as classification should be exported as such and not converted to float. While the classification field and point cloud index (after a merge) is easy to infer as integer fields, it's not obvious in general, so adding an export menu where the type of each scalar field can be manually defined would probably be the best solution.

Additional context This problem could possibly also be occurring for other export formats

Your environment CloudCompare v2.12.4 (Kyiv) Windows

karlHolmquist avatar Jan 02 '23 13:01 karlHolmquist

Internally, CloudCompare uses float for scalar fields. So it cannot make the difference between a generic scalar field and an integer-only scalar field at save time...

dgirardeau avatar Jan 02 '23 14:01 dgirardeau

Ok, thanks

Another question that popped up, what is the expected behaviour when merging two pointclouds where one of them has an extra scalar field compared to the other? I noticed that cloudcompare seem to assign 0 as default value for the points that does not have that scalar field when visualizing, however, when exporting it is assigned as NaN.

Is this guaranteed to be the case or does it depend on the output format or other factors?

karlHolmquist avatar Jan 03 '23 10:01 karlHolmquist

Normally, CC should assign the NaN values when merging (the points of the cloud which did not have the scalar field should appear in grey).

dgirardeau avatar Jan 03 '23 12:01 dgirardeau