Edit this page

NA-MIC Project Weeks

Back to Projects List

Automated map texture when importing the OBJ file into Slicer

Key Investigators

Project Description

Automatedly map the associated texture image to the obj file when importing it into Slicer without a creating a volume node for the texture image. This can facilitate importing textured model acquired by photogrammetry into Slicer. The ultimate goal is to be able to access OpenDronMap(ODM) photogrammetric package via Slicer to facilitate the use of photogrammetry.


When the obj file is imported into Slicer, Slicer will automatically call the Texture Model module from SlicerIGT to map the texture on the obj file without the need to import the texture image as a volumetric node and manually map it to the model using this module.

Approach and Plan

  1. Register a hook for the obj file type in the data import dialog (a similar approch suggested by Steve Pieper for loading nii file as either volume or segmentation (NIFTI file reader from SlicerDMRI extension: (https://github.com/pieper/SlicerDMRI/blob/nifiio/Modules/Scripted/NIfTIFile/NIfTIFile.py)
  2. When the ‘obj’ option is selected in the data importing dialog, the ‘Texture Model’ functions will be called to automatically map texture to the model (The TextureModel module of SlicerIGT: https://github.com/SlicerIGT/SlicerIGT/tree/master/TextureModel
  3. Here is an example file https://drive.google.com/file/d/1ZxJcx2nM-fgywA8KMm6JO0t7QJIcQR7O/view?usp=sharing)

Progress and Next Steps

  1. The goal is basically reached, thanks for the help from Steve Pieper. The script OBJFile.py is incorporated in the forked SlicerMorph repository: https://github.com/chz31/SlicerMorph. Git clone the repository and use the Extension Wizard to install the SlicerMorph extension.

  2. After that, the OBJ textured model option would be registered in the data dialog. Drag the OBJ into Slicer and select the OBJ textured model option.

<img src="https://user-images.githubusercontent.com/80793828/216435141-80300f14-aa08-4c51-9d05-85d3086f11c7.png", width = 700>

3. The mtl file (in the same directory) will then be automatically parsed to retrieve the texture image name. image 4. The `ImageStacks` functions from SlicerMorph will then be called to import texture as a vector volumetric node and map to the model using `SetTextureImageDataConnection`. The texture node will then be deleted.

image image

# Illustrations # Background and References Chi Zhang is working on a photogrammetry pipeline based on the open source package OpenDroneMap (ODM). Ultimately, the goal is being able to push and pull data between Slicer and ODM. A sample obj file with associated texture can be downloaded here: https://drive.google.com/file/d/1ZxJcx2nM-fgywA8KMm6JO0t7QJIcQR7O/view?usp=sharing