Local - adaptive Thresolding

Dear all,
I’m using 3D slicer for wooden objects.
I need to extract accurate surfaces, and I did not get good results with global thresolding approaches (I mean the same grey value for all the object).
Spruce wood is very non-homogeneous, showing great variations between late and early wood.
Dedicated packages such as VGStudio perform easily this task, but with a limited control on the algorithm.

Is there any tools in 3Dslicer that allows you to perform an adaptive thresold? This would help me very much.

Many thanks

If you provide a small sample dataset and illustration of the segmentation you wish to achieve we may be able to give better suggestions.

Thanks Steve.
What do you mean by small? A crop of around 50-100 Mb is OK? As an example I think is enough.
Dataset from industrial tomography are on the order of 10 Gb.

Sure, whatever the smallest reasonable size that illustrates the issue would be fine. You can’t attach it directly here, but if you post a link to dropbox/onedrive/googledrive etc here we should be able to give some suggestions. It would also help to see some screenshots of what other applications threshold the data (plus maybe a brief overview of what you are trying to achieve by doing the segmentation).

Thanks Peter,
first of all I uploaded an mhd+raw files: My Files

I would like to extract precise surfaces for reverse. This is not possible with global thresold: wood density varies a lot. You usually have at least a couple of materials peaks in the histogram.
I’m looking for something that consider the local gradient rather than a single ISO50 gray value for all the volume.

VGStudio Max uses its own proprietary algorithm:
12

It takes into account what happens locally, rather than using a global value for thresold:

Slicer’s Segment editor has several effects that determines segment boundary based on local gradient change (grow from seeds, watershed, fast marching).

For example, using Watershed effect (available in Segment editor after yo install SegmentEditorExtraEffects extension):

  • create a segment with threshold range minimum-14000 (surely background region)
  • create a segment with threshold range 25000-maximum (surely object region)
  • select Watershed effect
  • set object scale to 0.5mm (to control size of small blobs that are allowed at the object boundary)
  • click Initialize, then Apply

Seed segments for Watershed effect, created using global thresholding:

image

Segmentation result:

I’ve found that simple global thresholding (e.g., with Otsu threshold preset in recent nightly builds) gives good results, but you may need to manually remove small internal islands or blobs at the boundary:

  • use Logical operators effect to invert the segment
  • optionally use Smoothing effect’s Opening method to remove small extrusions (without changing the geometry at other places)
  • use Islands effect, remove small islands to remove internal blobs
  • use Logical operators effect to invert the segment back to its original form

image

Once you find a good segmentation workflow, you can write a script that performs all steps by a single click.

2 Likes

Great!
Sorry for late reply.
Next week I will gave a try to this approach, it seems promising.
For sure I’ll ask more practical questions, hope this thread is the right place for continuing the discussion.

Andras would you like to make the stl available for comparing it to the results of other approaches?

Thanks again for prompt and high-quality reply.
It’s a pleasure to be here.

1 Like

See scene files and an example export here: https://1drv.ms/f/s!Arm_AFxB9yqHtKxmKF5t18bQ3SfFOw
You can adjust the boundary location by tuning threshold values. I’ve computed the STL file using 14000 and 25000 as described above. There are several other parameters you can adjust, such as Watershed object size, and smoothing factor used for generation of closed surface representation.

2 Likes