# Filter for deleting isolated voxels

**URL:** https://discourse.vtk.org/t/filter-for-deleting-isolated-voxels/7328
**Category:** Support
**Created:** [December 3, 2021, 2:09pm UTC](https://discourse.vtk.org/t/filter-for-deleting-isolated-voxels/7328 "2021-12-03T14:09:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![gaston-perret](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gaston-perret/32/3488_2.png) [@gaston-perret](https://discourse.vtk.org/u/gaston-perret)
#### Post date: [December 3, 2021, 2:09pm UTC](https://discourse.vtk.org/t/filter-for-deleting-isolated-voxels/7328/1 "2021-12-03T14:09:29Z")

</div>

Hello.  
I have a voxel representation of a volume (mask) and I need to clean all the voxels that are not connected to the main volume.  
I was wondering if there is an existing filter that could help me identify isolated voxels in mask vti or vtp data.  
Is there anything that could help me with this? Preferably in VTK JS but C++ would work too.  
Thanks.

---

<div class="post-metadata">

### Author: ![Christos\_Tsolakis](https://discourse.vtk.org/user_avatar/discourse.vtk.org/christos_tsolakis/32/2076_2.png) [@Christos\_Tsolakis](https://discourse.vtk.org/u/Christos_Tsolakis)
#### Post date: [December 3, 2021, 10:12pm UTC](https://discourse.vtk.org/t/filter-for-deleting-isolated-voxels/7328/2 "2021-12-03T22:12:18Z")

</div>

A connectivity filter ( like [vtkImageConnectivityFilter](https://vtk.org/doc/nightly/html/classvtkImageConnectivityFilter.html#details)) is close to what you describe. It will assign distinct labels to connected regions of the image. You can then pick the ones you want. Make sure to also check `vtkImageConnectivityFilter::SetExtractionModeToLargestRegion()` as well as [earlier posts](https://discourse.vtk.org/t/how-to-use-vtkimageconnectivityfilter/3142) on discourse . I haven’t checked with vtk.js but I expect this filters to be available.
