# Interpolate between slices or remove segmentation outlier

**URL:** https://discourse.itk.org/t/interpolate-between-slices-or-remove-segmentation-outlier/3666
**Category:** Beginner Questions
**Created:** [November 30, 2020, 1:01pm UTC](https://discourse.itk.org/t/interpolate-between-slices-or-remove-segmentation-outlier/3666 "2020-11-30T13:01:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![farhan\_009](https://discourse.itk.org/user_avatar/discourse.itk.org/farhan_009/32/1945_2.png) [@farhan\_009](https://discourse.itk.org/u/farhan_009)
#### Post date: [November 30, 2020, 1:01pm UTC](https://discourse.itk.org/t/interpolate-between-slices-or-remove-segmentation-outlier/3666/1 "2020-11-30T13:01:49Z")

</div>

Hello Everyone,  
I have the following output from the prediction of the deep learning model. Is there any function that interpolates the segmented result of I have to remove the dots?  
I have tried to use the LinearInterpolateImage filter but doesn’t work for me.  
@dzenanz @Stephen_Aylward is there tool in TubeTK or Itk?  
Or any tool in itksnap?

 ![patient 1](https://discourse.itk.org/uploads/default/original/2X/f/f4ee12036cd7316cdf4a4b91aa44c3f0b5ef4b54.png) ![patient2](https://discourse.itk.org/uploads/default/original/2X/b/b4f527cc86c35fa291e2591c142f07eaff2dda05.png)

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [November 30, 2020, 5:22pm UTC](https://discourse.itk.org/t/interpolate-between-slices-or-remove-segmentation-outlier/3666/2 "2020-11-30T17:22:11Z")

</div>

You could use the NN output before binarization by a simple threshold, and do a hysteresis thresholding similar to [Canny](https://www.wikiwand.com/en/Canny_edge_detector) edge detector ([ITK implementation](https://github.com/InsightSoftwareConsortium/ITK/blob/aa4e759f660ea7dc495d17a526165011ed90252a/Modules/Filtering/ImageFeature/include/itkCannyEdgeDetectionImageFilter.hxx#L273-L313)). Otherwise you have a pairwise matching problem (which ends of lines to connect together?) which is combinatorial in nature.

---

<div class="post-metadata">

### Author: ![farhan\_009](https://discourse.itk.org/user_avatar/discourse.itk.org/farhan_009/32/1945_2.png) [@farhan\_009](https://discourse.itk.org/u/farhan_009)
#### Post date: [December 1, 2020, 4:09am UTC](https://discourse.itk.org/t/interpolate-between-slices-or-remove-segmentation-outlier/3666/3 "2020-12-01T04:09:29Z")

</div>

I couldn’t understand it properly.  
What if I want to remove the dots only and not interpolating them?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [December 1, 2020, 2:22pm UTC](https://discourse.itk.org/t/interpolate-between-slices-or-remove-segmentation-outlier/3666/4 "2020-12-01T14:22:04Z")

</div>

Use [connected component](https://itk.org/Doxygen/html/classitk_1_1ConnectedComponentImageFilter.html) analysis, keeping only the largest component. [Example](https://itk.org/ITKExamples/src/Segmentation/ConnectedComponents/ExtraLargestConnectComponentFromBinaryImage/Documentation.html).
