In this post we provide an overview for reading and processing medical images in Grasshopper.
Read an Image
Rhino3DMedical supports reading medical images in many different formats. The currently supported formats are:
- Metaimage (
- NiFTI (
- NRRD (
- DICOM image series
Please note that the reader automatically detects DICOM series in the current folder
In order to read an image from your computer, first create a File Path component, right click and select a file.
Get file path to the file
Now create a ReadFile component and connect the output from the file path to it. If the component shows an error the selected file cannot be read. In that case make sure the file exists and has one of the supported formats.
Create a Mesh
Create a SurfaceFromThreshold component and place it. Then create a numeric input for the threhold you wish to extract and connect it to the Threshold (T) input, and connect the output from the ReadFile component to the Image (I) input.
Create a mesh from a single threshold
This will create an open surface following the threshold you set.
Use Multiple Thresholds
You can either combine multiple thresholds into a single mesh, or create a separate mesh for each threshold.
For this, connect all thresholds to the Threshold (T) input by holding down
[SHIFT] while connecting them. This will automatically group them into a single mesh. In order to export one mesh per threshold, right-click on te Threshold (T) input and select Graft.
Create a Closed Mesh
If you need to create a closed region, connect a boolean input to the CreateSurfaceFromThreshold ‘s Close (C) input and set it to true. If a single threshold is connected, This will cap any holes. If two thresholds are connected this will segment the region enclosed between those two thresholds.
Closed mesh from two thresholds
Visualize the Result
Finally, we can try to make the resolt look nice by assigning it a material. To do this, create a Custom Preview component and, if you wish to change the default material, a Create Material component and connect it to the preview. To set up the material, assign the diffuse, specular and emission colors using color components (like a Color Swatch) and set the transparency (0 = fully visible, 1 = fully transparent) and the shine.
Resultimg mesh with applied material