[vtkusers] Getting region inside contour

pedrommcs pedrommcs at hotmail.com
Tue Mar 1 10:16:12 EST 2016


Hi everyone,

I'm generating a contour in 2D through vtkContourFilter. (see image attached
below) Now I would like to get the region that is inside the contour and
save it as vtkImageData or something similar that would result in an image
just with the data inside the contour. Everything else would be black, just
to have the same dimensions as the slice. (see contour_region.png) 

I don't know how to get the region inside the contour, is there anyway to do
it?

This is what I did so far:

import vtk

reader = vtk.vtkXMLImageDataReader()
reader.SetFileName("sample.vti")
reader.GetOutput().SetUpdateExtentToWholeExtent()
reader.Update()

flipYFilter = vtk.vtkImageFlip()
flipYFilter.SetFilteredAxis(1)
flipYFilter.SetInput(reader.GetOutput())
flipYFilter.Update()

image = flipYFilter.GetOutput()

extractSlice = vtk.vtkExtractVOI()
extractSlice.SetInput(image)
extractSlice.SetVOI(image.GetExtent()[0], image.GetExtent()[1], \
               image.GetExtent()[2], image.GetExtent()[3], \
               5, 5)
extractSlice.SetSampleRate(1, 1, 1)
extractSlice.Update()

contour = vtk.vtkContourFilter()
contour.SetInputConnection(extractSlice.GetOutputPort())
contour.SetValue(1,90)

#How to get the region inside the contour?

Thanks in advance.

<http://vtk.1045678.n5.nabble.com/file/n5736952/contour.png>  
<http://vtk.1045678.n5.nabble.com/file/n5736952/contour_region.png> 



--
View this message in context: http://vtk.1045678.n5.nabble.com/Getting-region-inside-contour-tp5736952.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list