MATLAB: Least squares solution of a point cloud to a surface

fittingpoint cloudprocrustessurface

Hi, I have a point cloud in the form of 3 vectors (x,y,z), that have come from a 3D imaging technique. These represent a surface, plus noise and some bigger deviations (wrinkles).
To understand the extent of these wrinkles I want a least squares solution of the perpendicular distance of these points to the ideal surface (lets say a hemisphere).
procrustes is no good… I can't create a point cloud of the same number of points as my data. Even if I could the grouping of points on my data due to parts of the image would skew the results when compared to randomly distributed points…
Any ideas? Thanks in advance

Best Answer

The perpendicular distance to the sphere surface would be easiest. Describe your hemisphere as in the Wikipedia article on Sphere, then do a nonlinear least squares fit to it with nlinfit, lsqcurvefit, fminsearch, or the Curve Fitting Toolbox functions.