I have a question regarding the “fill between slices” operation. When I perform this operation, I don’t see a smooth surface in the 3D view when clicking “show 3D.” It appears that the preview model has a lot of irregularities in the surface. Please find the attached screen capture and video that demonstrate how I generated the preview.
Additionally, in the preview, the top and bottom slices are not as smooth as when using a round paintbrush. It’s noticeable that there are many triangles in the top and bottom slices surface, and the fill between slices appears to have a somewhat rectangular surface.
So, my question is: why doesn’t it have a smooth slope?
Try resampling the data to isotropic resolution using the CropVolume before you start the segmentation. In the video you skipped that step (MRHead has anisotropic voxel spacing, 1x1x1.3mm). That should help.
You can also increase the resolution of the segmentation using the Segment Geometry option, and oversample.
Thank you for the suggestion. I’ve implemented your proposed solution and noticed a significant reduction in the number of triangles and the steps on the surface.
I have one more question. As you can see in the following images, the FIRST and LAST slices are circular then I’ve applied the multiple slice edit in the output, intermediate interpolated slices appear to have a square shape.
The diamond-shaped cross-section is just a result of how distance is estimated by a series of morphological operations (one voxel dilation in diagonal direction is 1.44x longer than in sideways, therefore repeated dilations result in a diamond shape). You can find more detailed description of the algorithm at https://insight-journal.org/browse/publication/977
You can switch to a distance transform based dilation instead of repeated morphological dilations, which will provide more rounded cross-sections. For this, you just need to add a single line to SegmentEditorFillBetweenSlicesEffect.py:
Before SetInputData(...) line, add this line:
interpolator.SetUseDistanceTransform(True)
However, in general these small details should not matter: wherever you don’t find the interpolated contour to be accurate enough, you can segment an additional slice there (and the 3D interpolation result will be updated automatically).
If you want to reconstruct a surface from extremely sparse contours using linear interpolation then you can use SlicerRT module’s planar contour to closed surface converter rule. This is used when importing DICOM RT structure sets, or when converting OsiriX ROIs to segmentations.
If you want to reconstruct a tubular surface then the easiest may be to use vtkTubeFilter.
What is your use case? Why do you attempt to reconstruct a 3D surface from cross-sections that are so extremely far from each other?
I tried distance transform-based dilation, but I don’t see much difference in the voxel dilations as shown in the above images. Yes, if we look from the top view of the model, we see somewhat rounded cross-sections better than compared to the previous approach.
Yes, I want to reconstruct tubular surfaces but with varying radii. For example, consider the sideway figures below. Imagine the white lines as the diameter of a round brush. What I want is to reconstruct a tubular-like surface between these slices.
For the resulting model to be accurate when using a round paint brush, the filled area between the slices, specifically the surface, should have a rounded cross-section.
Probably adding interpolator.SetUseBallStructuringElement(True) will provide the result you expect. We may make it the default, as it indeed a more natural-looking interpolation when segmented slices are very far from each other.
However, if we look into the sagittal view, you will notice the surface looks like something Concave. Also, in the top view of 3D, it seems like the filled area is squeezed from anterior and posterior (which I believe results in the Concave-like surface).
I wonder if there is any underlying parameter affecting the surface, or if the algorithm itself produces this type of surface?
This output looks very good. The smoothness is intentional (you don’t want linear interpolation, as it would result in discontinuity in surface normal directions).
The cross-section is slightly oval because of the distance map is computed without taking spacing into account. Normally this is not visible because segmented slices are at a reasonable distance, while in your case it is extreme (it is almost impossible that an interpolation algorithm would correctly guess a 3D shape from such extremely sparse data) and you interpolate on axial slices and the spacing is uniform within a slice (but MRHead is an unusual image where the image spacing is slightly larger along the LR axis).
I would recommend to add contours more closer to each other and consider resampling your image to isotropic spacing (which is useful for 3D segmentation anyway).
While in practice ignoring the image spacing for the distance transform should not be a problem, you can still request a fix here and see what the developers say.