title: Python VTK "normalize" a point cloud
body: <p>I have done a lot of searching but have yet to find an answer. I am currently working on some data of a crop field. I have PLY files for multiple fields which I have successfully read into, filtered, and visualised using Python and VTK. My main goal is to eventually segment and run analysis on individual crop plots.</p>
  
  <p>However to make that task easier I first want to "Normalize" my point cloud so that all plots are essentially "on the same level". From the image I have attached you can see that the point clod slopes from one corner to its opposite. So what I want to flatten out the image so the ground points are all on the same plane/ level. And the reset of the points adjusted accordingly.</p>
  
  <p><a href="https://i.stack.imgur.com/TAoTA.jpg" rel="nofollow noreferrer">Point Cloud</a></p>
  
  <p>I've also included my code to show how I got to this point. If anyone has any advice on how I can achieve the normalising to one plane I would be very appreciative. Sadly I cannot include my data as it is work related. </p>
  
  <p>Thanks. 
  Josh</p>
  
  <pre><code>import vtk
  from vtk.util import numpy_support
  import numpy as np
  
  filename = 'File.ply'
  
  # Reader
  r = vtk.vtkPLYReader()
  r.SetFileName(filename)
  
  # Filters
  vgf = vtk.vtkVertexGlyphFilter()
  vgf.SetInputConnection(r.GetOutputPort())
  
  # Elevation
  pc = r.GetOutput()
  bounds = pc.GetBounds()
  #print(bounds)
  minz = bounds[4]
  maxz = bounds[5]
  #print(bounds[4], bounds[5])
  evgf = vtk.vtkElevationFilter()
  evgf.SetInputConnection(vgf.GetOutputPort())
  evgf.SetLowPoint(0, 0, minz)
  evgf.SetHighPoint(0, 0, maxz)
  #pc.GetNumberOfPoints()
  
  # Look up table
  lut = vtk.vtkLookupTable()
  lut.SetHueRange(0.667, 0)
  lut.SetSaturationRange(1, 1)
  lut.SetValueRange(1, 1)
  lut.Build
  
  # Renderer
  mapper = vtk.vtkPolyDataMapper()
  mapper.SetInputConnection(evgf.GetOutputPort())
  mapper.SetLookupTable(lut)
  
  actor = vtk.vtkActor()
  actor.SetMapper(mapper)
  
  renderer = vtk.vtkRenderer()
  renWin = vtk.vtkRenderWindow()
  renWin.AddRenderer(renderer)
  iren = vtk.vtkRenderWindowInteractor()
  iren.SetRenderWindow(renWin)
  
  renderer.AddActor(actor)
  renderer.SetBackground(0, 0, 0) 
  
  renWin.Render()
  iren.Start()
  </code></pre>