技术标签: 《Halcon》
写在前面:
从“矩阵都是对基的变换”这个角度去理解仿射变换,这样更为直观。
矩阵的学习应从矩阵的几何意义入手
一 参考MATLAB文档
1. Pixel Indices (matlab文档)
origin in upper left corner of the image (pixel 和 image 都是这个坐标系),左上角的像素坐标为(1,1),右边的像素为(1,2),像素坐标表示为(Row,Column),元素之间是离散的,如下图所示。
2. Spatial Coordinates
(1) Intrinsic Coordinate System(matlab文档)
origin in the middle of the upper left pixel (area_center等是在这个坐标系下进行计算),The coordinates(x,y) of the center point of any pixel areidentical to the column and row indices for that pixel。一定要注意的是,图片左上角的坐标为(0.5,0.5)(此处有疑问,Halcon文档中图片左上角的坐标为(-0.5,-0.5),还是以Halcon中为准),而不是(0,0),图片右下角的坐标为(ColsNum+0.5,RowsNum+0.5)。 From this Cartesian(笛卡尔) perspective, an (x,y) location such as (3.2,5.3) is meaningful, and is distinct from pixel (5,3).
二 参考Halcon文档
The different tasks in HALCON need different image coordinate systems,the positions for pixel-precise regions differ from those used for subpixel-precise XLD contours by 0.5 pixels,the estimated position returned by the matching can not be used directly but is optimized for the creation of the transformation matrices that are used to apply the applications described above.
The difference between affine_trans_pixel and affine_trans_point_2d lies in the used coordinate system: affine_trans_pixel uses a coordinate system with origin in the upper left corner of the image, The coordinate system runs from (0,0) (upper left corner) to (Width-1,Height-1). while affine_trans_point_2d uses the standard image coordinate system, whose origin lies in the middle of the upper left pixel and which is also used by operators like area_center.
In contrast to affine_trans_point_2d,affine_trans_pixel first converts the input coordinates from HALCON's standard coordinate system(with the origin in the center of the upper left pixel) to a coordinate system with the origin in the upper left corner of the upper left pixel. After the transformation with HomMat2D the result is converted back to the standard coordinate system.
*测试程序1:
gen_rectangle1(Rect,0,0,0,0)area_center(Rect,Area, Row, Column) 以上代码绘制一个像素大小的矩形,Row=0,Column=0
*测试程序2:
gen_rectangle1 (Rect, 0, 0, 1,1)area_center(Rect,Area, Row, Column)绘制四个像素大小的矩形,Row=0.5,Column=0.5
HALCON中的两个图像坐标示意图如下所示:
affine_trans_point_2d use the right coordinate system,the standard image coordinate system for which a position corresponds to the center of a pixel
.In contrast ,the operators affine_trans_pixel, affine_trans_contour_xld,affine_trans_region, andaffine_trans_image use the coordinate system depicted in
figure left.
halcon算子affine_trans_image reference 中有如下说明:
for example, if you use this operator to calculate the center of gravity of a rotationally symmetric image and then rotate the image around this
point using hom_mat2d_rotate, the resulting image will not lie on the original one.In such a case(特指绕中心点旋转的情况),you can compensate this effect
by applying the following translations to HomMat2D before using it in affine_trans_image:
area_center(Image,Area,Row,Column)
vector_angle_to_rigid(Row,Column,0,Row,Column,rad(90),HomMat2D)
hom_mat2d_translate(HomMat2D, 0.5, 0.5, HomMat2DTmp)
hom_mat2d_translate_local(HomMat2DTmp, -0.5, -0.5, HomMat2DAdapted)
affine_trans_image(Image, ImageAffinTrans, HomMat2DAdapted, 'constant', 'false')
**
如果将Row和Column的求法换为如下方法,就不需要translate和translate-local这两步get_image_size(Image,Width,Height)
Row := Height/2
Column := Width/2
这个地方之所以要对旋转矩阵进行变换,是因为旋转中心点的坐标是基于标准图像坐标系,图片左上角的坐标是(0.5,0.5)。
hom_mat2d_translate 是矩阵左乘
hom_mat2d_translate_local 是矩阵右乘,基于本地坐标系
Row和Column指的的是图片像素坐标
经过以上矩阵变换后再对图片旋转90度,如右图所示,可以发现旋转前后的图片位于同一位置(此时旋转发生在标准图像坐标系,而非像素坐标系)。左图中未对旋转进行进行调整,显然可知旋转前后的图片并不在同一位置。
需要注意的是,假如程序修改为
hom_mat2d_translate(HomMat2D,-0.5,-0.5,HomMat2DTmp)
hom_mat2d_translate_local(HomMat2DTmp,0.5,0.5,HomMat2DAdapted)
旋转后图片位置也会偏移。
如下操作,旋转后的图片也是重合的。(旋转发生在像素坐标系下,而非标准图像坐标系)
area_center(Circle,Area, Row,Column)
vector_angle_to_rigid(Row+0.5,Column+0.5,0,Row+0.5,Column+0.5,rad(90),HomMat2D)
affine_trans_image(ImageResult,ImageAffinTrans2,HomMat2D,'constant', 'false')
相关资料:
(1)origin pixel in the image coordinate system in opencv
(2)Question about coordinate system in matlab
(3)Image Coordinate SystemsMATLAB文档中也讲到了 Image Coordinate System
(4)affine transformation matrix 仿射变换矩阵 与 OpenGL
(5)http://www.itwendao.com/article/detail/139651.html
参考资料(5)中有如下描述:
affine_trans_pixel 和 affine_trans_point_2d的不同在于所使用的坐标系原点不同,affine_trans_pixel 使用的是像素坐标系, 即原点位于图像的左上角第一个像素,使用row和column来确定像素位置,而affine_trans_point_2d的原点位于左上角第一个像素的中心,使用x和 y来标识坐标位置(实际原点相差(0.5,0.5))。并且在使用affine_trans_point_2d时如果使用标准图像坐标系,则row坐标必须传递Px,列坐标必须传递Py以保证旋转方向的正确性。(这句话如何理解?既然如此,那为什么还用Px,Py,而不是Row ,Column)
HALCON文档中 Description:
1) affine_trans_point_2d(::HomMat2D,Px,Py:Qx,Qy)
If the points to transform are specified in standard image coordinate,their row coordinate must be passed in Px and their column coordinate in Py. This is necessary to obtain a right-handed coordinate system for the image. In particular,this assure that rotations are performed in the correct direction. Note that the (x,y) order of the matircs quite naturally correspond to the usual (Row,Column) order for coordinate in the image.
2) hom_mat2d_translate(::HomMat2D,Tx,Ty:HomMat2DTranslate)
It should be noted that homogeneous transformation matircs refer to a general right-handed mathematical coordinate system. If a homogeneous transformation matrix is used to transform images,regions,XLD contours,or any other data that has been extracted from images,the row coordinates of the transformation must be passed in the x coordinates,whilethe column must be passed in the y coordinates. Consequently,the order of passing row and column coordinates follows the usual order(Row,Column).This convention is essential to obtain aright-handed coordinate system for the transformation of iconic data,and consequently to ensure in particular that rotations are performed in the correct mathematical direction.
---------------------
作者:莫干
来源:CSDN
原文:https://blog.csdn.net/qq_20161893/article/details/72917780
版权声明:本文为博主原创文章,转载请附上博文链接!
1.写在前面前面的博客,我已经简单的介绍了elasticsearch的安装,以及一些的工具的安装,只是简简单单入了一个门,但是elasticsearch一般都离不来集群,我们知道它是一个分布式,高性能、高可用、可伸缩的搜索和分析系统,所以今天的博客打算介绍一下它的集群的方式,但是由于我的电脑的配置有限,所以这儿就简简单单在一台机器上启动三个elasticsearch,然后搭建集群,当然多台机器搭建集群的方式比较简单,我在这儿就不介绍了。2.搭建集群的方式我们这儿主要是介绍两种方式,一种是通过多配置的文
学完ES分布式集群的工作原理以及一些基本的将数据放入索引然后检索它们的所有方法,我们可以继续学习在分布式系统中,每个分片的文档是被如何索引和查询的。路由首先,我们需要明白,文档和分片之间是如何匹配的,这就是路由。当你索引一个文档,它被存储在单独一个主分片上。Elasticsearch是如何知道文档属于哪个分片的呢?当你创建一个新文档,它是如何知道是应该存储在分片1还是分片2上的呢?进程不能是随机的...
ASIHTTPRequest使用指南--->当第一次使用ASIHTTPRequest进行http请求时,会出现非常多的bug提示.查了一些资料,发现在少倒入了几个资源包:大概是:CFNetwork.framework;SystemConfiguration.framework;MobileCoreServices.framework.原文
链接:https://pan.baidu.com/s/1vb9Pvfv_6NgwVjYNdea5Qg 提取码:5zid crack[email protected]@ukr.netSolidConverterv9KFMK
1、访问XenServer的IP地址,下载XenCenter
当今的android应用设计中。一种主流的设计方式就是会拥有一个側滑菜单,以图为证: 实现这种側滑效果,在5.0曾经我们用的最多的就是SlidingMenu这个开源框架,而5.0之后。google推出了自己的側滑实现库。那就是DrawerLayout,它的使用方法比SlidingMenu更简单,并且由于是google的亲生儿子,所以...
简单模拟spring底层提供的动态技术JDK实现,耦合度降低,提高 程序的复用性和灵活性同时提高了开发效率,且便于维护public interface UserService { /** * 增 */ public void insert(); /** * 删 */ public void delete(); ...
Server ADF 动态创建mapService说明:加入地图包括图层渲染,标注等,数据从ArcSDE中读出! 代码中有两个数据表:mapinfo(存储地图信息,key:地图GUID),LayerInfo(存储图层信息,包括其在SDE中的名称,以及最主要的其属于哪个地图的地图GUID),代码中的MapGUID即为地图GUID。 代码中包括连接SDE以及常见sde工作空间...
Mybatis-Plus 日志配置我们在mybatisplus中sql语句是看不见的,配置日志后可以查看一系列操作在yml中配置这个,这个是默认控制台输出,如果用log4j或者common要导入相关依赖#配置日志 打印sql语句mybatis-plus: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl...
前段时间,有个郑州的朋友在微信上给我留言,咨询培训班毕业找工作的事情。我当时答应他会写一篇文章的,没想到耽搁到现在。所以,趁着今天有空,在公司码点字,聊聊这方面的事情。想知道出路,必先摸清来路。接下来,我会分情况聊聊,请各位同学对号入座,愿你们读时有耐心,读完有信心。一、如果你是还没报名培训班,正在门外犹豫的同学这部分同学,不妨听听我对培训市场的一些看法。从培训机构招生来...
(1) Spring是什么?IOC(控制反转)和AOP(面向方面编程)作为Spring框架的两个核心,很好地实现了解耦合。所以,简单来说,Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架。spring的基本框架主要包含六大模块:DAO、ORM、AOP、JEE、WEB、CORESpring DAO:Spring提供了对JDBC的操作支持:JdbcTemplate模板工具类 。Spring ORM:Spring可以与ORM框架整合。例如Spring整...
Mysql出现问题:ERROR 1040 (08004 (ER_CON_COUNT_ERROR)): Too many connections解决方案