2D segmentation in vtk.js

Good day!

Right now I’m exploring the functionality of OHIF’s ‘Segmentation’ and I’m curious if there are any tools in vtk.js for reproducing this functionality?

In general it should look like this:

I’m aware that in vtk.js there are tools like paintWidget and others, which allow you to “draw” on a 2D image. Even though this example resembles the logic found in OHIF’s ‘Segmentation’. But if we focus on the basic functionality, I’d like to ask how I can implement something like to an eraser in the vtk.js example from the provided link?

It is also important to note that in the case of OHIF, it is not just drawing, if you make certain adjustments, namely:

whatever that means, then the drawn figures begin to go around some zones of the 2D image and in this case, fill only the black ones:

(The large circle in the top right corner serves as the cursor)

Is it possible to do this in vtk.js and if so, with what tools?

You can look at the PaintWidget example. It relies on Webworker, so you can also tweak the code to support “thresholding”.

Volview (a VueJS web app based on VTK.js) relies on those painting widget behaviors.

1 Like

Now I have a slightly different question. Is it possible to automatically change the color of certain zones in a 2D image (using resliceCursorWidget) in the same way as in the very first image in this topic.

For example, relying on a certain mask with values received from the backend. This mask will have values from 0 (no color is applied), and to, for example, 20 (as in the example above from OHIF), where
1 – white color, responsible for the “Cerebral White Matter” segment;
2 – red color, responsible for “Cerebral Gray Matter”;
3 – purple color, responsible for “Brain ventricle” and so on.

And depending on which zone these values cover in the mask, this zone will be painted in the appropriate color.

The question is, is it possible to somehow implement this mask into a resliceCursorWidget and how these specific zones should be automatically highlighted in color, so to get a result similar to an OHIF. Or are there other approaches and tools to achieve such a result, if possible, of course.

@finetjul, could you please express your thoughts regarding my question in the previous message?

Yes, you can do what you are asking.

A simple approach is to have a unique resliceCursorWidget for the MRI volume.
The labelmap (with colored segments and transparent everywere else) is not part of the reslice cursor widget but it has an image mapper that takes as input a vtkImageReslice that is configured the same way than for the MRI volume (done by the reslice cursor widget). You then need to make the labelmap image mapper show up slightly in front of the MRI image mapper using coincident topology.
I can’t go in more details without spending more significant amount of time (please consider taking some support contract).