Table of Content

In this post we explore combining HumanUI and Rhino3DMedical in Grasshopper to segment medical images.

Download & Install HumanUI

Before we begin we need to make sure HumanUI is installed. Head to the HumanUI page on food4rhino, login and follow the installation steps.

Set up the HumanUI window

Create the window

In order to create a window in HumanUI you only need four components:

  • Launch Window – to display a window
  • Add Elements – to add UI elements to the window
  • A Panel with the name of the window – this name will be shown at the top
  • Boolean Toggle – to show and hide the window

Connect the Boolean Toggle to the Show input and the Panel to the Name input of Launch Window. Then connect the output of that component to Add Elements through the Window input. We will fill in the other input later.

Add the UI Elements

For our simple example we only need four unique elements.

File Picker

Use the Create File Picker component to allow for reading a file through the window directly. This component has a lot of inputs, but for our application the default value is correct, so we do not need any more inputs.


Using the Create Slider component we can add sliders to the interface. These take standard Grasshopper Number Sliders as input, where we need to set a lot of information.

For this, create a slider, double click on the left part and fill in the Name, Accuracy, Numeric domain and Numeric value fields, as the slider in the HumanUI window will use all these values.

Note that the Numeric domain, Numeric value and Accuracy can be set directly when creating the slider with the following syntax :

\text{lower} \lt \text{default} \lt \text{upper}

where the lower and upper values set the Numeric domain and Accuracy, and default sets the Numeric value. For example, to create a slider from 0 to 2 with one digit and default value 0.5 would be created like this:

\text{0.0} \lt \text{0.5} \lt \text{2.0}

This way the only value you need to set is the Name.


Use the Create Checkbox component to do this, passing it the default value and the text that is displayed. We use a Boolean Toggle for the default value, and a Panel for the name.

Color Picker

Lastly, we use a Create Color Picker, which takes a color as input. In our case we use a Colour Swatch to do so.

Add the Value Listeners

Every single UI Element needs a Value Listener so we can pass its output to other grasshopper components, or, in this case, Rhino3DMedical ones. These value listeners sinply take the UI elements as input, and return the value in the corresponding type.

Add the Elements to the window

In order to add the elements to the window, connect them all to the Elements input of the Add Elements component we added previously. Make sure you hold down SHIFT to connect more than one input.

Remember that the order in which the items are connected to the Add Elements component is the order in which they appear in the window, with the first connected element being on top.

Add the Rhino3DMedical components

For this demo we only need tow Rhino3DMedical Components:

Read File

This takes the path to the file as input, which comes from the File Picker.

Surface from Threshold

Which has four inputs, namely the medical image from the read file, a lower and an upper threshold, which are both sliders, and a boolean which comes from a checkbox.

Add a Material to the Preview

Create a Material

To add a custom material we first need a Create Material component.

We pass three colors which represent the Diffuse, Specular and Emission colors of the geometry. The diffuse color is the base color of the geometry, the specular color is the color of the shine, and the emission color allows for the geometry to emit light in a given color. Each one of these is given by a Color Picker.

Then we give the Transparency, which has to be a number between 0 and 1, where 0 means the geometry is fully opaque and 1 means it is fully invisible.

Lastly there is the Shine, which is a number between 0 and 100. 0 means no shine, 100 means the object looks like polished metal.

Apply the Material to the Mesh

Using a Custom Preview component, connect the material we just created and the mesh returned from Surface from Threshold to the Geometry output.

Then right click the Surface From Threshold component and disable the preview so we only see the material.

Putting it all together

Double click the toggle we connected to the Launch Window component earlier and the HumanUI window should appear. Feel free to try and add your own functionality or add other elements.

Download Grasshopper File