简体   繁体   中英

2D plane fitting , ransac, matlab, link

I have set of 3D points.

Points_[x,y,z]% n*3 where n is number of points

I want to fit a plane (it is floor) and check height of plane. I think it is 2D problem .

z=bo+b1x+b2y;

I can't find a link for 2D ransac plane fitting . Can someone please give this link or file.

Secondly, Some softwares (commercial)gives height value of plane. It is mean or some complex value.

Regards,

If you form the following "A" matrix

A = [ones(numel(Points_X),1), Points_X(:), Points_Y(:)]; 

where the (:) is to give you column vectors (in case they were not to begin with)

Then you can write your equation as the classic linear system of equations:

A*b = Points_Z(:);

where b = [b0; b1; b2] -- a column vector of the parameters you are trying to determine. This has the canonical solution

b=A\Points_Z(:)

or b=pinv(A)*Points_Z(:)

See help on mldivide and pinv.

You must have 3 or more points which don't all lie on a line. For an overdetermined system like this, pinv and \\ will basically produce the same results. If they are nearly colinear, there may be some advantage using .

The 3 parameters in b are basically the height of the plane above the origin, the x slope, and the y slope of the plane. If you think about it, the "height" of a plane IS your z term. You can talk about height above some point (like the origin). Now, if you want height at the center of mass of the sampled points, you would then do

z_mean = [1 mean(Points_X(:) ) mean( Points_Y(:) )] * b

which is probably just equivalent to mean( Points_Z(:) ) . For this definition to be meaningful, you would have to ensure that you have a uniformly spaced grid over the region of interest.

There may be other definitions, depending on your application. For instance, if you are trying to find the height at a center of a room, with points sampled along the walls and interior, then replacing mean with median might be more appropriate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM