简体   繁体   English

2D平面拟合,ransac,matlab,链接

[英]2D plane fitting , ransac, matlab, link

I have set of 3D points. 我有一套3D点。

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 . 我认为这是2D问题。

z=bo+b1x+b2y;

I can't find a link for 2D ransac plane fitting . 我找不到2D ransac平面拟合的链接 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”矩阵

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; 其中b = [b0; b1; B1; b2] -- a column vector of the parameters you are trying to determine. b2] - 您要确定的参数的列向量。 This has the canonical solution 这有规范的解决方案

b=A\Points_Z(:)

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

See help on mldivide and pinv. 请参阅有关mldivide和pinv的帮助。

You must have 3 or more points which don't all lie on a line. 您必须有3个或更多点并不是全部都在一条线上。 For an overdetermined system like this, pinv and \\ will basically produce the same results. 对于像这样的超定系统,pinv和\\基本上会产生相同的结果。 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. b中的3个参数基本上是原点上方平面的高度,x斜率和平面的y斜率。 If you think about it, the "height" of a plane IS your z term. 如果你考虑一下,飞机的“高度”就是你的z项。 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(:) ) . 这可能只相当于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. 例如,如果您试图在房间的中心找到高度,沿着墙壁和内部采样点,那么用中位数替换平均值可能更合适。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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