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]
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.
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 ?
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 .
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.
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.
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)