Watershed, Fast marching, and Flood filling effects in Segment editor

Three semi-automatic segmentation effects have added to the Segment editor. They are available in the latest nightly build, by installing the new SegmentEditorExtraEffects extension:

They are all semi-automatic methods, which grow segmentation from seeds/points defined by the user.

Watershed: similar to grow from seeds. Advantage: smoothness of the segments can be enforced. Disadvantage: much slower.

Input:

Preview:

Final result:

Fast marching: expands the current segment to regions with similar intensity.
Input:

Output:

Flood filling: clicking in the image adds points around the click position to the current segment. Intensity tolerance is adjustable. Neighborhood size parameter can be used to prevent leakage.

9 Likes

That’s exciting, thank you @lassoan! Looking forward to testing those.

1 Like

2 posts were split to a new topic: Flood filling segment editor effect does not fill the image

Hi, Perhaps I have some contributions to boost the processing times very much.

I researched about flood-fill recently and implemented an algorythm that was 10^1000000 times more efficient on memory instructions, using 3-4 of them, and multiple times faster than all previous versions that I found described on the web in codes whilst also being able to add codes from them too, and that could be speeded up by the 3D processes of the ones I found on the web. I wrote an account here: http://unity3dmc.blogspot.fr/2017/02/ultimate-3d-floodfill-scanline.html

@monstercolorfun_co Thanks for sharing this.

For us, the main challenge is not computation time, as typically medical images that we work with consists of 100-200 million voxels, but a segmented structure is rarely bigger than a few 10 million voxels. Flood filling time is not noticeable.

Our problem is leaking: we often want to prevent flood filling to propagate through narrow bridges. VTK’s flood fill filter has an option for defining neighborhood size and minimum fill rate, but it’s not perfect, as it also removes small details from the filled region. Maybe it could be fixed easily (e.g., by expanding the final flood fill result by neighborhood size), but maybe a completely different approach would be needed.

If you were interested in exploring flood filling algorithms that don’t leak, and contribute an implementation using BSD-type license, then we would be happy to try it.

I’d love to use these new tools but I can’t get the extension to work. I installed the SegmentEditorExtraEffects extension in the 4/9/2018 nightly build, did the restart, and the icons aren’t available. I uninstalled and reinstalled also, and gave it permission to install the MarkupsToModel dependency. Working in Windows 10. Thanks for any advice.

Use the latest stable or the latest nightly. If you still have problems then send the application log (menu: Help / Report a bug).

I’m using the build from 5/20. Here’s my error logs:

After install, before restart:

“Retrieving extension metadata [ extensionId: 225963]”
“Downloading extension [ itemId: 360938]”
“Retrieving extension metadata [ extensionId: 225914]”
“Downloading extension [ itemId: 360889]”
“Installed extension SegmentEditorExtraEffects (225963) revision b6cdcaa”
“Installed extension MarkupsToModel (225914) revision a63c166”
QPixmap::scaled: Pixmap is a null pixmap

After restart:

Session start time …: 2018-06-01 14:56:08
Slicer version …: 4.9.0-2018-05-20 (revision 27197) win-amd64 - installed release
Operating system …: Windows / Professional / (Build 9200) - 64-bit
Memory …: 16309 MB physical, 19253 MB virtual
CPU …: GenuineIntel , 4 cores, 4 logical processors
VTK configuration …: OpenGL2 rendering, TBB threading
Developer mode enabled …: no
Prefer executable CLI …: yes
Additional module paths …: C:/Users/Justin Cramer/AppData/Roaming/NA-MIC/Extensions-27197/SegmentEditorExtraEffects/lib/Slicer-4.9/qt-scripted-modules, C:/Users/Justin Cramer/AppData/Roaming/NA-MIC/Extensions-27197/MarkupsToModel/lib/Slicer-4.9/qt-loadable-modules
Popen(%s, cwd=%s, universal_newlines=%s, shell=%s)
Popen(%s, cwd=%s, universal_newlines=%s, shell=%s)
libpng warning: iCCP: known incorrect sRGB profile
Scripted subject hierarchy plugin registered: Annotations
Scripted subject hierarchy plugin registered: SegmentEditor
Scripted subject hierarchy plugin registered: SegmentStatistics
Switch to module: “SegmentEditor”
An OpenGL Core Profile was requested, but it is not supported on the current platform. Falling back to a non-Core profile. Note that this might cause rendering issues.
QPixmap::scaled: Pixmap is a null pixmap

This version is not the latest nightly or latest stable version. Could you please test with both of these versions and let us know if they work?

Ok, I tried it on latest stable (4.8.1) and nightly build from 6/1 with same result. I’ve pasted log from 4.8.1 attempt below. Have tried on 3 different Windows 10 machines with no difference. I don’t have access to OSX or Linux right now. Thanks again for your help.

[DEBUG][Qt] 02.06.2018 18:08:55 [] (unknown:0) - Session start time .......: 2018-06-02 18:08:55
[DEBUG][Qt] 02.06.2018 18:08:55 [] (unknown:0) - Slicer version ...........: 4.8.1 (revision 26813) win-amd64 - installed
[DEBUG][Qt] 02.06.2018 18:08:56 [] (unknown:0) - Operating system .........: Windows /  Professional /  (Build 9200) - 64-bit
[DEBUG][Qt] 02.06.2018 18:08:56 [] (unknown:0) - Memory ...................: 16322 MB physical, 19266 MB virtual
[DEBUG][Qt] 02.06.2018 18:08:56 [] (unknown:0) - CPU ......................: GenuineIntel , 12 cores, 16 logical processors
[DEBUG][Qt] 02.06.2018 18:08:56 [] (unknown:0) - Developer mode enabled ...: no
[DEBUG][Qt] 02.06.2018 18:08:56 [] (unknown:0) - Prefer executable CLI ....: yes
[DEBUG][Qt] 02.06.2018 18:08:56 [] (unknown:0) - Additional module paths ..: C:/Users/neurorad/AppData/Roaming/NA-MIC/Extensions-26813/SegmentEditorExtraEffects/lib/Slicer-4.8/qt-scripted-modules, C:/Users/neurorad/AppData/Roaming/NA-MIC/Extensions-26813/MarkupsToModel/lib/Slicer-4.8/qt-loadable-modules
[DEBUG][Python] 02.06.2018 18:08:56 [Python] (C:\Program Files\Slicer 4.8.1\lib\Python\Lib\site-packages\git\cmd.py:719) - Popen(%s, cwd=%s, universal_newlines=%s, shell=%s)
[DEBUG][Python] 02.06.2018 18:08:56 [Python] (C:\Program Files\Slicer 4.8.1\lib\Python\Lib\site-packages\git\cmd.py:719) - Popen(%s, cwd=%s, universal_newlines=%s, shell=%s)
[DEBUG][Python] 02.06.2018 18:08:57 [Python] (C:\Program Files\Slicer 4.8.1\lib\Slicer-4.8\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: Annotations
[DEBUG][Python] 02.06.2018 18:08:57 [Python] (C:\Program Files\Slicer 4.8.1\lib\Slicer-4.8\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: SegmentEditor
[DEBUG][Python] 02.06.2018 18:08:57 [Python] (C:\Program Files\Slicer 4.8.1\lib\Slicer-4.8\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: SegmentStatistics
[DEBUG][Qt] 02.06.2018 18:08:56 [] (unknown:0) - Number of registered modules: 141
[DEBUG][Qt] 02.06.2018 18:08:56 [] (unknown:0) - Number of instantiated modules: 141
[DEBUG][Qt] 02.06.2018 18:08:57 [] (unknown:0) - Number of loaded modules: 141
[DEBUG][Qt] 02.06.2018 18:08:57 [] (unknown:0) - Switch to module:  "SegmentEditor"

I’ve just tried the nightly build on a Windows machine and the effects showed up correctly. Could you please post a screenshot of your screen when you switch to the Segment Editor module?

Yeah I’m sure it’s something simple I’m overlooking but can’t figure it out. I rebooted…latest updates installed to Windows 10, otherwise fresh install of Slicer. It’s my impression that the extra tools show up as additional icons in the Segement Editor… Here are screenshots of Segment Editor and my Extensions manager:

Yes, the extra icons should show up in the Segment Editor module, but they don’t. Could you try to uninstall the extension, restart Slicer, and reinstall. When you reinstall, wait 1 minute before restarting Slicer, to make sure the extension is fully downloaded and installed.

If it still does not work then we can set up a meeting with remote desktop sharing during the coming week (just Send me a few timeslots that would work for you in a private message).

Mystery solved: SegmentEditor module was set as startup module, so it was initialized immediately when Slicer started - before SegmentEditorExtraEffects extensions had a chance to register the additional effects.

I’ll push a fix for this soon, but until then the workaround is not to set SegmentEditor as startup module.

2 Likes

Segment Editor initialization has been fixed (r27233), in nightly versions downloaded tomorrow or later, all effects will show up correctly in Segment Editor, even if it is used as startup module.

Yaay for using Segment Editor as startup module :slight_smile:

Hi these effects are so nice , and gives best output.
i like to use python coding.
Can i call/use this effects from Slicer python interactor?

Yes I’m also interested to use this by python code.

All Slicer features are available from Python scripting. See examples for using Segment Editor effects from Python in the script repository: Documentation/Nightly/ScriptRepository - Slicer Wiki

A post was split to a new topic: Algorithm used in Watershed effect in Segment Editor