Version : 4.11.0 windows 10
imported obj files are stripped of their color and all shown gray, im i doing something wrong or is there a way to do it via scripts?
Thanks
Version : 4.11.0 windows 10
imported obj files are stripped of their color and all shown gray, im i doing something wrong or is there a way to do it via scripts?
Thanks
What does the .obj file contain?
If the file is from a surface scanner and you want to display texture then you can follow these instructions: Displaying textured 3D models
If exported segmentation to .obj and trying to load that then you can restore the original segment colors but it requires manual steps, as .obj is primarily used as an export format in Slicer. When you read a .obj file then object IDs are stored in the model nodes as scalars. You can use these scalars to set different color for each segment (Models module / Scalars section). If you use the colormap of the original segmentation then you’ll get back those colors.
Thanks for your answer.
The .obj only has diffuse color information given by slicer while exporting (in its .mtl i assume). I could not get it to work from scalars section no matter what i color table i used
Material file is not used when an .obj file is read. You can create a color table file from the material file if you want to use the material colors.
There are many ways to approach import colored models into Slicer. If you give a bit more information about what kind of meshes you work with, what software generates them, and what you want to do with them in Slicer then we can give more specific advice.
My obj files are generated from slicer (goal = export model and import into another scene using .obj)
and from blender (initially exported from slicer) (goal = give back models to slicer scene after modifications)
the colors are originally set from slicer segment editor and models module
As a counter-measure i tried to iterate over model nodes and set new colors by name but i could not iterate over the model nodes visible in Models module only (class vtkMRMLModelNode contains slice intersections and ROIs too)
If you set master representation to closed surface and save the segmentation then not just color, but all metadata are preserved. Each segment is saved as a mesh file in VTK .vtp that you can freely modify and then reload without losing metadata. I’m not sure if there are Blender plugins to provide .vtp file reading/writing, but if there is none then you can convert using a short Python script or using Slicer GUI.
What operation do you perform in Blender that is not available already in Slicer?
FYI, you can import Blender into Slicer as described here if you want to use Blender data processing features in Slicer.
Blender has a more intuitive GUI for working with models such as sculpting and mesh optimisation (decimation, remove doubles etc), also useful to merge multiple files into one .obj for some 3d viewers that only accept that format, already tried slicer’s surface toolbox module but it was not as complete.
Yes .vtp writing in blender could do the trick, i will look into that direction, still, directly taking .mtl’s in account could be a plus in slicer.
Importing blender into slicer looks very promising to run scripted tasks.
Slicer is intended to create models of an underlying image and not free sculpting, so if you need that then definitely go with Blender instead.
These should be all already available in Slicer. Is there any specific that you cannot find?
We created “Export to files” feature for exactly this reason. If you choose OBJ file format then all segments are saved into a single .obj file.
Here are some limitations that i encountered with slicer’s surface toolbox:
Other than those limitations the effect’s algorythms themselves are good in slicer, but it can be hard to dynamically find the best combination for a multitude of models.
However, blender’s algorythms produce cleaner results, as in this 90% decimation of the same model (left is slicer):
Export to files works well for segments but that implies they don’t have any post-processing.
Another problem from slicer’s obj write is exported colors get darker, for example R 255 G100 B 30 will become R85 G 33 B 10 (All values gets divided by 3), i had to script blender to revert it
Currently, this requires two steps. 1. Use shift+mousemove in the 3D view to find a segment in 2D views. 2. Hover over the crosshair position in slice views to see which segment it is (easier to see if you enable crosshair on the toolbar and set jump mode to centered).
We will make this more convenient in the near future. If you give more details about how and when you would use it then we can take it into account when we design how the model picking feature will work.
Slicer assumes you have a background volume to work with. You can create a blank volume to enable editing (click on the button next to the master volume selector then choose to specify segmentation geometry based on the current segmentation), but it is kind of pointless because it would mean that you are not segmenting anymore just doing freehand sculpting (that modeling tools such as Blender are better suited for).
You can undo any modifications in Segment editor.
You have real-time preview of some effects in Segment Editor. It would be also very easy to implement auto-update on slider change in Surface toolbox. Results of what operations you would like to preview in real-time?
Segmentation conversion parameters, such as smoothing and decimation can be reversed/tuned individually in Segment Editor. Parameters you set in the Surface toolbox can be also reversed/changed individually.
I agree that vtkDecimatePro filter in VTK does not produce very good quality meshes. It would be quite easy to integrate other remeshers (such as the VTK-based ACVD) or run Blender’s remesher in Slicer if there is a strong need for it. However, there has not been too many requests for improving remeshing in Slicer, because editing happens in labelmap domain and full-resolution meshes can be displayed and exported without problems.
Thanks for your answer,
It can be useful for picking segments on the go (on slice viewers/3D view), to pick a segment and continue painting on it for example, when Segment editor is the active module then segments would be pickable using the (none) cursor or a shortcut (Alt? ) + click
and when surface toolbox/models modules are active the models would be pickable ( but until surface toolbox is enhanced i hardly see a usage for models)
I was talking about 3D Models, not segments, some imported model nodes were not compatible with surface tool box and effects did not work
Also talking about Effects applied to model nodes, once applied they are not reversible (Ctrl Z is not working to Surface toolbox applied effects)
As a basic addition, just a “show preview” check box that allows previewing the end result would be enough : for decimation its very useful (used with solid view and wireframe, it can allow quick optimisation of the decimate ratio to perform max reduction without altering the mesh quality)
ideally this would be integrated in the surface toolbox along with the interactive model picker:
I rarely use slicer’s surface toolbox even though i do extensive mesh processing and never asked for improvements because there are programs like blender that do it natively and i leave slicer for the segmentation work (and i believe more people are in the same situation)
i don’t apply much effects at the Labelmap/segments step because the resolution is limited by the Master Geometry of the background volume and smoothing effects in segment editor can perform poorly for fine structures that get close to the vertex size (discontinuity made in a fine vessel for example). so i just export models once segmentation is done and that allows more freedom for post-processing the structures