Plane Fitting with vtk


I want to implement Plane Fitting using vtk.
Can I get some information for your reference?

I’m always getting your help.
Thank you.


There are many ways to fit a plane (least squares, RANSAC, …). Can you write more about your requirements?

Do you build VTK from source or you use it from Python?

Here is one available method: vtkPlane::ComputeBestFittingPlane

1 Like

I am using vtk and I am in Visual Studio 2015 C++ environment.

Thank you for answer.
I’ll try searching.

Is it suitable for plane correction of 3D data~?


By “plane correction” do you mean this (undo lens distortions):

or this (undo perspective projection):




As shown in the attached image,
Align the left and right sides and top and bottom with the same surface as possible.

I want to make it work like this:

Example) CloudCompare

  1. Tools -> Fit -> Plane (Get Matrix 4x4)
  2. Edit -> Apply Transformaction (Set Matrix 4x4)

If your data is supposed to represent a functional surface ( e.g. a height map where z = f(x, y) ), then it is not a good idea to apply a rotation to your points towards the fitted plane. Why? Because you will change the (x, y) coordinates too.

What you want is tecnically not a correction but an operation called detrending. Detrending alone is an entire field of research. Assuming your data is functional, a simple and fast procedure is: a) fit a plane like you suggested; b) evaluate the slope function at each data location (z* = f(x, y)); c) then making a new z for each data point z’ = z - z*.