Hi Jes,
I understand that you have measurement data from a sensor doing spiral scanning. The data is 3-Dimensional point data for geometries like sphere, cylinder and plane. The tasks required are:
- Preprocess Data (Filtering, Centering and Vertex Search)
- Fit the right model (Sphere, Plane or Cylinder)
- Output the Fitted Parameters and errors with visualization
Assuming you are looking to write a script for the above functions. Different functions can be written to filter, center the data and to do vertex search. From the pre-processed data, you can then fit and visualize the required model.
This is an example to pre-process the data, assuming you are loading the data from a file path.
STEP 1: Preprocessing the data
This is an example:
ptCloud = pointCloud(data);
centroid = mean(ptCloud.Location, 1);
ptCloud = pointCloud(ptCloud.Location - centroid);
fprintf('Point cloud centered at the origin.\n');
For removing noisy points that are far from their neighbours, which helps to improve the accuracy of model fitting.
[ptCloud_filtered, ~] = pcdenoise(ptCloud, 'NumNeighbors', 10, 'Threshold', 1.0);
num_removed = ptCloud.Count - ptCloud_filtered.Count;
fprintf('Removed %d outliers using SOR filter.\n', num_removed);
For the vertex search :-
kdTree = KDTreeSearcher(ptCloud_filtered.Location);
STEP 2: Fitting the right model and visualization
For example, these commands can be used for ellipsoid and spherical fit:
fobjEllipsoid=ellipsoidalFit(xyz);
fobjSphere=sphericalFit(xyz),
[hE,hData]=plot(fobjEllipsoid);
hS=showfit(fobjSphere,'FaceAlpha',0.3,'FaceColor','g');
legend([hE,hS,hData],'Ellipsoid fit','Sphere fit','XYZ samples','Location','northeast','FontSize',15);
You can refer to the following links for the relevant documentation:
Hope this helps.