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