PLY file colors not displayed

I have an exported ply file that contains color information that I would like to see and be able to access from python. If I load the file I see the model but I do not see the color. I looked at the header of the file and by the looks of it the color is given per vertex. Is color supported?

[START PLY HEADER]
ply
format binary_little_endian 1.0
comment Exported model
element vertex 238415
property float x
property float y
property float z
property float nx
property float ny
property float nz
property uchar red
property uchar green
property uchar blue
element face 473991
property list uchar int vertex_indices
end_header
[END PLY HEADER]

After reading this: https://discourse.slicer.org/t/displaying-textured-3d-models/2521/9

I think colors per vertex are supported, I tried the Models module and enabled the scalars. I have set it to RGB and can select a colormap, but I get strange colors. do I need a colormap to get the colors from the model to display?

Both vertex and cell scalars can be used for coloring. There were some fixes in color table mapping a 1-2 months ago, so make sure you use a recent nightly version.

Hi Andras, I just tried the nightly build version 4.9.0-2018-09-27 with no luck. Also here no colors (at least not the colors from the file )
STR:

  • I load the ply (it shows in gray)
  • I open the Models module
  • select the scalars tab
  • set the checkbox to: visible
  • select active scalar: rgb

I can play with the colortable to get some colors, but those are not the colors from the file. In MeshLab the colors seem to work fine, so the file is correct.

Update: I got some color of the original colors to display when I tried flipping the rgb values in the data. Not sure how it suddenly happened and I am unable to reproduce it now. Can anybody confirm that vertex colors work with the nightly build?

We usually use single-component scalars + a lookup-table for coloring, as it is much more flexible than burnt-in RGB values (you can threshold, recolor, etc. dynamically) . For displaying an arbitrarily textured model, we typically use .obj file format, because this is how we usually get these models.

Per-verted colored .ply files are not very common, but might be useful to display them directly, so I’ve added a new option “Direct color mapping” to colors module / display / scalars section. You can use this option to use per-vertex 3-component scalar values directly as RGB values (without mapping it through a lookup table). This feature will be available in Slicer nightly version that you download tomorrow or later.

Hi Andras, Thanks for your explanation. I tested the “direct color mapping” feature you added in the nightly build and I would like to confirm that it works perfectly. Thanks for adding the feature on such short notice.

1 Like

Dear Prof Andras

I am having trouble in displaying colours from IOS scans exported as ply or obj. The export files works well in exocad viewer or similar softwares but in 3D Slicer i cannot reproduce the colour. What needs to be done ?


thank you

This can probably be fixed if you share some sample datasets.

1 Like

Dear Steve

Please find the ply and the obj file formats of the same scan from a Intra oral scanner.

thank you for your time and effort.

I don’t think you need the Normals as Active scalars. What else do you have in that drop down?

i tried all available options and combinations but didnt work.

I loaded the ply file in my local build and this is what I got with no changes needed in the models module. It looks right to me.

ohh this looks great . but i dont see get this. i will share my version details as well as try the newest version and see

Dear Steve,

I tried with my 3D Slicer windows and Linux versions 5.7.0 2024.05.30 and ,latest windows version 2024.08.27 and unfortunately for me the no colours are shown .

What could be the issue ?

thank you

It works fine with the preview and stable versions on my Mac. Maybe you have some initialization scripts (.slicerrc.py) or other things? did you try with a vanilla install.

I tried with vanilla installation as well.

just to clarify I am working on the obj file not the ply file. ply file i get the colours in the recent release but not on the obj file.

I only tried the ply file since the obj file link didn’t have the correct permissions. I just requested access to the obj version.

Yeah, I obj doesn’t want to download. If you are trying obj, try with the SlicerMorph install, and when you drag it into Slicer, choose the file description from model to Textured OBJ. That might help.

Hi all

Just to confirm the behaviour in my computer. the obj file does not show colour. I tried importing as obj textured model and it doesnt work either. however the ply works with colors.

In the scalar tab the obj file does not show RGB option like in the ply files.
(i have changed the privacy settings for the obj file if someone wish to try it)


Thank you