Dilate/Erode in 2d

Hi,

I would like to dilate a labelmap only in 2d. The option dilate four/eight unfortunately also take the upper and lower slice into account. Is there any possibility to do this. Thanks for the answer.

Try the new Segment Editor in the latest nightly version. It has sophisticated margin growing/eroding and masking options that should help to segment anything you need. If you describe what your endgoal is then we can give you specific advice which effects to use and in what combination.

HI,

Thank you very much for your quick answer. Basically I segmented the lateral ventricles using a threshold and would like now to examine the 1 or 2 milimeters next to the ventricle. I tried this with “dilate” however this also segments the pixel on the upper and lower slices which falsifies the result . I will try with the new segement editor.

What do you mean by examine? Measure the surface or volume?

Ventricles are 3d structures, so you should be able to properly segment them in 3D quite easily, for example, using the Grow from seeds effect.

If you need to smooth the segment, then use Smoothing effect. If you need to expand the segment then use the Margin effect. To restrict editing to a single slice, fill a single slice (using Paint or Scissors effect) and use that as a mask.

Hey again,

Unfortunately it didn’t work as I hopped with the segment editor.
By examine I mean segment. Maybe I reexpose my problem:
I segmented the ventricles only in the Axial view. Now, from this segmentation (in the axial view), I would like to expand it by 2 - 4 pixels outwards. As the dilate option also takes into account the upper and lower pixel, this could falsify the result, as I only segmented the ventricles in axial view.
Is there a possibility (as I think there used to be in the older Slicer Versions) to dilate my axial segmentation only in the 2d plane.
Thanks again

Segmenting strictly in 2D does not seem more useful then real 3D segmentation. What is the reason why you don’t want to take into account the inferior-superior direction?

Other than that, you can define a mask segment. You can create large blocks using scissors for example, then set it as a mask when you do the dilation.
I just noticed @lassoan wrote the same. However, it is still the easiest way.

1 Like

Hi @cpinter ! The segmentation strictly in 2D is important when you want to simulate two different segmentation of the same volume to evaluate the inter-observer variability and reproducibility. In that case, taking into account the inferior-superior direction could create new areas segmented in the inferior/superior slices that could be out of the tumour, then they cause errors.

Is possible to do the dilation 2D now? @cpinter @lassoan

It is still not possible, because there were no driving use cases. If you have at least a little Python and VTK experience, you could try to copy and modify the current dilation tool to perform it slice by slice.

If you want to simulate random displacements then you can do that already. For example, export the segment to another segmentation, apply a transform with random displacement, and then import the moved segment back into the original segmentation. You can repeat that as many times as needed to simulate any probability distribution.

You can also very easily shift, copy, combine slices or regions within slices of segments using numpy indexing. See example in the script repository.