一、矩简介

Opencv 笔记11 图像的矩原理解析_Σίσυφος1900的博客-CSDN博客_opencv 图像的矩

矩是概率与统计中的一个概念,假设有随机变量X,常数c,正整数k,则有

E[(X−c)k]称X为c 的k阶矩。

1.c=0->ak=E(Xk)称为X的k阶原点矩

2. c=E(X)。这时μk=E[(X−EX)k]称为X的k阶中心矩。(这个是我们经常使用的)

同理当随机变量是X 、Y的二维时候有如下:

1、A1=A2=0->上式称为X的p+q阶混合原点矩

2.  A1=E(X),A2=E(Y)->上式称为X的p+q阶混合中心矩

二、算子演示

disp_object_model_3d显示模型

GenParamName := ['lut','color_attrib','light_position','disp_pose','alpha']GenParamValue := ['color1','coord_z','0.0 0.0 -0.3 1.0','true',0.9]disp_object_model_3d (WindowHandle1, ObjectModel3D, [], DispPose1, GenParamName, GenParamValue)*案例GenParamName := ['lut','intensity','light_position','disp_pose','alpha']
GenParamValue := ['color1','coord_z','0.0 0.0 -0.3 1.0','true',0.9]'lut':渐变色        'intensity':沿着哪个方向改变颜色        'light_position':光照位置'disp_pose', 是否显示坐标轴'alpha':与透明度123456color_attrib :'none'、'&distance'、'coord_x'、'coord_y'、'coord_z'、用户定义的点属性或任何其他可用的点属性。
设置为 'coord_z',并且 'lut' 设置为 'color1',则 z 坐标的颜色编码将从红色变为蓝色。
如果 'lut' 设置为 'default',则属性值用于缩放由参数 'color' 设置的颜色。
如果 'lut' 设置为不同的值,则所有点的属性值在内部缩放到区间 [0,255] 并用作 LUT 函数的输入值。

moments_object_model_3d 计算3D模型的一阶、二阶矩

moments_object_model_3d (ObjectModel3D, 'central_moment_2_points', Moments)第二个参数: 'central_moment_2_points', 'mean_points', 'principal_axes'mean_points: 表示的均值,可以理解为一阶中心矩,返回值是三个数字,分别是点云在x,y,z 轴的均值central_moment_2_points: 表示的是方程,可以理解为二阶矩(表示的是浮动情况)  --结果是 x、y、z表示电云在各个轴上的波动情况(方差),x-y、x-z 和 y-z 轴的协方差,可以理解为点云在各个轴上的相关性【-1,1】)。principal_axes:计算 3D 对象模型的三个主轴,结果是一个以点的平均值为中心的姿势。
对应于姿势的坐标系具有沿第一主轴的x轴、沿第二主轴的y轴和沿第三主轴的z轴。

moments_object_model_3d (ObjectModel3D, 'central_moment_2_points', Moments)

第二个参数: 'central_moment_2_points', 'mean_points', 'principal_axes'

mean_points: 表示的均值,可以理解为一阶中心矩,返回值是三个数字,分别是点云在x,y,z 轴的均值

central_moment_2_points: 表示的是方程,可以理解为二阶矩(表示的是浮动情况)  --结果是 x、y、z表示电云在各个轴上的波动情况(方差),x-y、x-z 和 y-z 轴的协方差,可以理解为点云在各个轴上的相关性【-1,1】)。

principal_axes:计算 3D 对象模型的三个主轴,结果是一个以点的平均值为中心的姿势。
对应于姿势的坐标系具有沿第一主轴的x轴、沿第二主轴的y轴和沿第三主轴的z轴。

三、代码演示

*
* Object models e.g. acquired with a 3D sensor can have an object
* coordinate system, that is not aligned with the major axes of
* the object. If the object has a ridge, it is desirable that the
* object coordinate system is aligned with this ridge, e.g. that
* the x-axis indicates the direction of the ridge.
*
* This example demonstrates the use of the operator
* moments_object_model_3d to align 3D data with the x-, y-, z-
* coordinate axes.
* The operator can be used to determine the mean of all points of
* a 3d object model. Furthermore, the operator can be used to
* extract the principal axes of the model. The main principal axis
* is the axis along which the variance of the data is largest.
* If the 3D object model is transformed into the principal axes
* coordinate system, the x-axis corresponds to the first principal
* axes. The y-axis is the second principal axes. And the z-axis
* is the third principal axes.
*
* Prepare the main window
dev_close_window ()
FontSize := 14
WindowSize := 500
dev_open_window (0, 0, WindowSize, WindowSize, 'white', WindowHandle1)
set_display_font (WindowHandle1, FontSize, 'mono', 'true', 'false')
*
* Set visualization parameters for the 3d object model
* A lookup table (lut) is set that transforms attribute values into
* a color. In this example the color encodes the value of the
* z-component of the data. The alpha parameter defines the
* transparency of the object model.
GenParamName := ['lut','color_attrib','light_position','disp_pose','alpha']
*lut 表示的是
GenParamValue := ['color1','coord_z','0.0 0.0 -0.3 1.0','true',0.9]
* Define factor for scaling meter to millimeters
Scale2Millimeter := 1000
* Read the 3d object model from file
read_object_model_3d ('cutting_edge.om3', 'm', [], [], ObjectModel3D, Status)
* Define the poses from which the camera looks at the object model
create_pose (-0.0005, -0.0005, 0.04, 280, 0, 20, 'Rp+T', 'gba', 'point', DispPose1)
create_pose (0, -0.0005, 0.04, 280, 0, 20, 'Rp+T', 'gba', 'point', DispPose2)
*
* Display introduction text
Information := 'This example shows how an object coordinate'
Information[1] := 'system can be aligned with the data given by'
Information[2] := 'a 3D object model.'
Information[3] := ' '
Information[4] := 'This may be useful, e.g. to align a cutting'
Information[5] := 'edge in a way that the x-axis indicates the'
Information[6] := 'direction of the ridge.'
disp_message (WindowHandle1, Information, 'window', 12, 12, 'black', 'false')
disp_continue_message (WindowHandle1, 'black', 'true')
stop ()
*
* Visualize the 3d object model and its object coordinate system.
* The original coordinate axes are not aligned with the main axes
* of the data. The object coordinate system is shown with the
* x-axis in red, the y-axis in green and the z-axis in blue.
* The color of an object model point is determined by its z-coordinate.
* Thus, the color of the object model shows that points along the
* ridge of the object have different z-coordinates.
dev_set_window (WindowHandle1)
dev_clear_window ()
WindowTitle := 'The coordinate axes of the object model are'
WindowTitle[1] := 'not aligned with the main axes of the model.'
WindowTitle[2] := 'The coloring of the model shows that points'
WindowTitle[3] := 'along the top ridge of the object have '
WindowTitle[4] := 'different z-coordinates.'
disp_object_model_3d (WindowHandle1, ObjectModel3D, [], DispPose1, GenParamName, GenParamValue)
disp_message (WindowHandle1, WindowTitle, 'window', 12, 12, 'black', 'false')
disp_continue_message (WindowHandle1, 'black', 'true')
stop ()
dev_open_window (0, WindowSize + 13, WindowSize, WindowSize, 'white', WindowHandle2)
set_display_font (WindowHandle2, FontSize, 'mono', 'true', 'false')
*
* Compute the principal axes system for the 3d object model
* where the axes represent the directions largest variance.
* Transform the object model into the computed new
* coordinate system.
*
* The pose returned by moments_object_model_3d describes
* the principal axes coordinate system with respect to
* the original coordinate system of the 3D object model.
* The origin of the principal axes coordinate system is identical with
* the mean point of the object model.
moments_object_model_3d (ObjectModel3D, 'principal_axes', Pose)moments_object_model_3d (ObjectModel3D, 'mean_points', Posesss)
* Transform the 3D object model into its principal axes
* coordinate system.
* For transforming the points of the 3D object model into the
* principal axes coordinate system, the inverse of the computed
* pose is needed.
pose_invert (Pose, PoseInvert)
pose_to_hom_mat3d (PoseInvert, HomMat3D)
affine_trans_object_model_3d (ObjectModel3D, HomMat3D, ObjectModel3DPCA)
* Compute the moments of second order for the original model.
* These moments correspond to the variances in x, y, z and the
* covariances xy, xz and yz.
moments_object_model_3d (ObjectModel3D, 'central_moment_2_points', Moments)
* Extract the variance along the x, y, z axes (scaled to mm²)
MomentsSecondOrderOrig := Moments[0:2] * (Scale2Millimeter * Scale2Millimeter)
* Compute the moments of second order for the transformed model
moments_object_model_3d (ObjectModel3DPCA, 'central_moment_2_points', MomentsPCA)
* Extract the variance along the x, y, z axes (scaled to mm²)
MomentsSecondOrderPCA := MomentsPCA[0:2] * (Scale2Millimeter * Scale2Millimeter)
*
* Display results
WindowTitle := 'The 3D object model was transformed into its'
WindowTitle[1] := 'principal axes system. The object model is'
WindowTitle[2] := 'now aligned with the coordinate axes.'
* Compare the variances along the x, y, z axis in
* the old and in the new object coordinate system.
* For the principal axes system, it can be seen that
* the largest variance in the data is concentrated
* along the x-axis. The second largest variance
* occurs along the y-axis.
OldVariance[0] := 'Variances in original system:'
OldVariance[1] := ' '
OldVariance[2] := '  Var(x) = ' + MomentsSecondOrderOrig[0]$'.3f' + ' mm²'
OldVariance[3] := '  Var(y) = ' + MomentsSecondOrderOrig[1]$'.3f' + ' mm²'
OldVariance[4] := '  Var(z) = ' + MomentsSecondOrderOrig[2]$'.3f' + ' mm²'
* Variances for the object model in the new coordinate system
NewVariance[0] := 'Variances in new system:'
NewVariance[1] := ' '
NewVariance[2] := '  Var(x) = ' + MomentsSecondOrderPCA[0]$'.3f' + ' mm²'
NewVariance[3] := '  Var(y) = ' + MomentsSecondOrderPCA[1]$'.3f' + ' mm²'
NewVariance[4] := '  Var(z) = ' + MomentsSecondOrderPCA[2]$'.3f' + ' mm²'
disp_object_model_3d (WindowHandle2, ObjectModel3DPCA, [], DispPose2, GenParamName, GenParamValue)
disp_message (WindowHandle2, WindowTitle, 'window', 12, 12, 'black', 'false')
disp_message (WindowHandle2, NewVariance, 'window', 350, 12, 'black', 'false')
disp_message (WindowHandle1, OldVariance, 'window', 350, 12, 'black', 'false')
stop ()
disp_end_of_program_message (WindowHandle1, 'black', 'true')

Halcon 3D moments_object_model_3d简介相关推荐

  1. Halcon 3D 常见算子描述

    一.简介 halcon 中有很多常见的算子,我们经常在用,但是作为一名算法工程师我们不仅要会用,知道原理也是很重要的,所以对于很多事情我们不仅要所以然更有知其所以然. 二.算子解释 1.smooth_ ...

  2. Halcon 3D 切片法检测物料

    一.简介 在上一篇中,学习了鞋底切片法来求轮廓,那个思路是比较简单的,其次还提到了法向量重建的方法,目前由于没有用法向量重建来做那个项目,所以还是有很大的疑问,后续会继续学习那个方法然后重新在做一次, ...

  3. [Qt教程] 第48篇 进阶(八) 3D绘图简介

    [Qt教程] 第48篇 进阶(八) 3D绘图简介 楼主  发表于 2013-10-7 09:44:37 | 查看: 184| 回复: 0 3D绘图简介 版权声明 该文章原创于作者yafeilinux, ...

  4. HALCON标定板简介

    HALCON标定板简介

  5. Unity 3D 三维模型简介||

    Unity 3D 三维模型简介 三维模型是用三维建模软件建造的立体模型,也是构成 Unity 3D 场景的基础元素. Unity 3D 几乎支持所有主流格式的三维模型,如 FBX 文件和 OBJ 文件 ...

  6. Halcon—3D测量算法的那点数学公式和代码实现

    Halcon-3D测量算法的那点数学公式和代码实现 ✨博主介绍 前言 Halcon源码 ✨博主介绍

  7. Halcon 3D 三维重建

    一.简介 三维重建(3D Reconstruction)技术一直是计算机图形学和计算机视觉领域的一个热点课题.早期的三维重建技术通常以二维图像作为输入,重建出场景中的三维模型.但是,受限于输入的数据, ...

  8. halcon 3D Object Model 三维物体模型算子,持续更新

    目录 3D Object Model 三维物体模型 Creation创建 1.clear_object_model_3d 2.copy_object_model_3d 3. deserialize_o ...

  9. Halcon 3D点云和深度图的相互转化

    3D点云和深度图 1. 如何将灰度图转为3D点云 2. 创建一张深度图 3. 深度图转点云.点云转深度图 4. 代码和图片下载地址 1. 如何将灰度图转为3D点云 这里所说的灰度图转为3D点云,其实是 ...

最新文章

  1. A query was run and no Result Maps were found
  2. Decorator Pattern - C# 3.0 Design Patterns
  3. 【LeetCode】405 Convert a Number to Hexadecimal (java实现)
  4. Shiro过滤器源码
  5. 20145202马超《信息安全系统设计基础》实验四总结
  6. The import com.sun.tools cannot be resolved
  7. Linux——CentOS建立一个最高权限的用户
  8. 关于WinForm控件在asp.net中应用的问题。
  9. 【自动驾驶定位要求论文翻译】Localization Requirements for Autonomous Vehicles
  10. 无线鼠标服务器,remote mouse
  11. 服务器上使用nvcc编译多个cu文件,在cmake中使用nvcc编译。cu
  12. 千峰Java教程:071. 数据结构之链表①
  13. FxFactory 7 Pro for Mac(fcpx/ae/pr视觉特效插件包)v7.2.5
  14. java左手画圆右手画方_左手画圆,右手画方,有两个截然不同的说法,你知道吗?...
  15. Go基础语法(短句精简版)(上)
  16. php网站怎么给文件设置颜色,配置区块和文件颜色
  17. Helicon Focus Pro(景深合成软件)官方中文版V7.6.6 | helicon focus中文版下载 | 含helicon focus使用方法
  18. sentinel 实时监控服务
  19. 邮件服务器问题--邮件积压、传递延迟解决方法
  20. 人脸识别60年:欧盟通用数据保护条例真的算“史上最严”吗

热门文章

  1. 信息共享的记忆被囊群算法
  2. (精品原创)Java代码优化-代码复用与重构
  3. 上海市职称计算机证明补办,职称证书丢了还能补办吗?上海落户政策详解。
  4. 2022Q3手机配件增长榜:手机壳、数据线等供求不断增加
  5. 雪亮工程 视频分类总结
  6. arcgis制图 ——羽化效果
  7. 英语日常短语积累(6)-银行考试真题
  8. python-脚本自动生成二维码QRcode/quick response code
  9. 二维数组的定义和使用
  10. 小程序服务器域名和业务域名的总结和配置