title: Getting region inside contour in VTK
body: <p>I'm generating a contour in 2D through <code>vtkContourFilter</code>. (see image attached below) Now I would like to get the region that is inside the contour and save it as <code>vtkImageData</code> 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.</p>
  
  <p><a href="https://i.stack.imgur.com/cZpBd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cZpBd.png" alt="enter image description here"></a> 
  <a href="https://i.stack.imgur.com/GGVKR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GGVKR.png" alt="enter image description here"></a></p>
  
  <p>I don't know how to get the region inside the contour, is there anyway to do it? </p>
  
  <p>This is what I did so far: </p>
  
  <pre><code>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?
  </code></pre>
  
  <p>Thanks in advance. </p>