vtkImageConnectivityFilter seeds


I am writing a function to segmentate some parts of a vtkImageData using vtkImageConnectivityFilter.
Please bear in mind I am new to vtk.

I have had relatively good results with the filter just by setting the right bounds and scalar range of thresholding, but can not get the seeds to work properly.

By default, this algorithm filters by checking the scalar data of the image within a stencil, when no seeds are given, or the seeds don’t have scalar data.

I’ve tried setting the seeds (ijk coordinates of the points) as vtkPointSets but then the filter extracts no regions. My only suspicion is that the algorithm is expecting scalars and since the seeds have none, then no region is extracted.


vtk_points = self.__get_seeds_as_vtkPoints()
        seeds = vtk.vtkUnstructuredGrid() #or vtk.vtkStructuredGrid

How can I do to input seeds (with or without scalars) into this filter?

Thanks in advance.

Hi Valentin,

The seeds use physical (x,y,z) coordinates, not index (i,j,k) coordinates.

The seeds do not need scalars unless you use SetLabelModeToSeedScalars(). I recommend using SetLabelModeToConstantValue() as a starting point, and only try other modes after you get the seeds working.


1 Like

Thanks again David