利用halcon进行图像拼接的基本教程.doc

上传人:枫** 文档编号:555182333 上传时间:2023-04-29 格式:DOC 页数:14 大小:10.88MB
返回 下载 相关 举报
利用halcon进行图像拼接的基本教程.doc_第1页
第1页 / 共14页
利用halcon进行图像拼接的基本教程.doc_第2页
第2页 / 共14页
利用halcon进行图像拼接的基本教程.doc_第3页
第3页 / 共14页
利用halcon进行图像拼接的基本教程.doc_第4页
第4页 / 共14页
利用halcon进行图像拼接的基本教程.doc_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《利用halcon进行图像拼接的基本教程.doc》由会员分享,可在线阅读,更多相关《利用halcon进行图像拼接的基本教程.doc(14页珍藏版)》请在金锄头文库上搜索。

1、一、什么是图像拼接(略)二、拼接的基本过程使用halcon自带的例子来说明这个过程打开拼接下面的mosaicking.hdv(一)镜头校正CamParam := 0.0121693,-2675.63,7.40046e-006,7.4e-006,290.491,258.887,640,480change_radial_distortion_cam_par (adaptive, CamParam, 0, CamParOut)(二)获得图像* Read in the images and show them one-by-one.for J := 1 to 10 by 1 read_image (I

2、mage, ImgPath+ImgName+J$02) if (EliminateRadialDistortions) change_radial_distortion_image (Image, Image, Image, CamParam, CamParOut) endif concat_obj (Images, Image, Images) dev_display (Image) disp_message (WindowHandle1, Image +J$d, window, -1, -1, green, false) wait_seconds (0.5)endfor(三)图像配准til

3、e_images_offset (Images, TiledImage, 0,0,0,0,0,500,500,500,500,500, 0,660,1320,1980,2640,0,660,1320,1980,2640, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 3280, 980)(四)图像拼接,获得全军图像gen_projective_mosaic (Images, MosaicImag

4、e, StartImage, From, To, ProjMatrices, StackingOrder, false, MosaicMatrices2D)除了镜头校正以外,其他几个函数在拼接中是常见的,通过查看帮助获得了解。使用连铸拼接来说明这个问题,首先可以查看下面的原图和拼接后的图像(一) 获得图像,可以采用帮助工具,直接产生代码(二) 镜头校正projective_trans_imageread_image (Image000003, datacode/ecc200/ecc200_to_preprocess_001)hom_vector_to_proj_hom_mat2d (131,2

5、25,291,63, 102,97,291,274, 1,1,1,1, 63,291,291,63, 102,102,291,291, 1,1,1,1, normalized_dlt, HomMat2D)projective_trans_image (Image000003, TransImage, HomMat2D, bilinear, false, false)(三)图像配准,这个例子是居于模板匹配的(四)图像融和,这里采用了一种简单的融和方法。(五)得到了结果。可以看出,整改图像拼接两个重点,也是难点:一个是如何通过识别的方法,得到准确的偏移;二个是如何将不同图片之间由于光照等造成的差异

6、融和到最小。下面首先看halcon提供了那些工具和没有提供那些工具。三、halcon为拼接提供了那些工具 (一)模板识别工具 (二)专门的拼接算子这里做一个比较,模板匹配的用途很广泛,用于拼接只是其中的一种用法,而拼接算子就是专门用来拼接使用的;由于模板匹配提供了工具,所以比较适于实验的使用使用,而拼接算子能够直接得到变换矩阵,应该说功能很强;对于效果来说,模板匹配需要的特征点比专门的算子多,适合纹理比较多的情况。两者互为补充。 Halcon没有提供的工具融和的基本算法:基于Halcon的图像拼接算法研究_谭杰.pdf,采用如下加权渐变方法:细节自己看论文,融和的结果显示.仔细观察图片相交处,

7、可以看到在光度变换比较大的地方略有模糊,在光照比较好的地方拼接非常好。拼接的结果得到了客户的好评。细节在实验中说明,这里说明这就是融和。四、实验(一)基于模板的最基本拼接将和拼接到一起。注意这两张图片不是分别照的,是一张图片切割的,也正是因此,这个拼接是不需要融和的。下面全部代码和解释*拼接方法1,使用模板匹配set_system (border_shape_models, false)* 获取图形read_image (Image1, F:/不紧急/拼接最基本/1.jpg)read_image (Image2, F:/不紧急/拼接最基本/2.jpg)read_image (ImageBlac

8、k, F:/不紧急/拼接最基本/3.JPG)*获得图片的大小get_image_pointer1 (Image1, Pointer, Type, Width, Height)* Matching 01: build the ROI from basic regionsgen_rectangle1 (ModelRegion, 1180.05, 1207.55, 1304.15, 1959.45)* Matching 01: reduce the model templatereduce_domain (Image1, ModelRegion, TemplateImage)* Matching 0

9、1: create the shape modelcreate_shape_model (TemplateImage, 5, rad(0), rad(360), rad(0.2213), point_reduction_high,no_pregeneration, use_polarity, 6,11,5, 4, ModelId)* Matching 01: store the model contour for displaying the search results later*重点,分别从两张图片中获得模板的坐标,做差运算就可以获得偏移get_shape_model_contours

10、(ModelContours, ModelId, 1)find_shape_model (TemplateImage, ModelId, rad(0), rad(360), 0.5, 1, 0.5, least_squares, 5, 0.75, Row1, Col1, Angle1, Score1)dev_display_shape_matching_results (ModelId, red, Row1, Col1, Angle1, 1, 1, 0)find_shape_model (Image2, ModelId, rad(0), rad(360), 0.5, 1, 0.5, least

11、_squares, 5, 0.75, Row2, Col2, Angle2, Score2)dev_display_shape_matching_results (ModelId, green, Row2, Col2, Angle2, 1, 1, 0)vector_angle_to_rigid (Row1, Col1, 0, Row2, Col2, 0, HomMat2D)*拼接两张图片gen_empty_obj (Images)concat_obj (Images, Image1, Images)concat_obj (Images, Image2, Images)tile_images_o

12、ffset (Images, Imageresult, 0,(Row1-Row2), 0,(Col2-Col1), -1,-1, -1,-1, -1,-1, -1,-1, Width, Height*2)(三) 基于特征点的最基本拼接,为看懂halcon的例子做准备需求同上。采用的方法完全不同。Halcon中拼接的方法目前我就掌握这两种。*拼接方法2,使用foerstner方法set_system (border_shape_models, false)* 获取图形read_image (Image1, F:/不紧急/拼接最基本/1.jpg)read_image (Image2, F:/不紧急

13、/拼接最基本/2.jpg)read_image (ImageBlack, F:/不紧急/拼接最基本/3.JPG)get_image_pointer1 (Image1, Pointer, Type, Width, Height)gen_empty_obj (Images) concat_obj (Images, Image1, Images) concat_obj (Images, Image2, Images) tile_images_offset (Images, TiledImage, 0,Height+100, 0,0, -1,-1, -1,-1, -1,-1, -1,-1, Width

14、, Height*2+100)stop()ProjMatrices := Rows1 := Cols1 := Rows2 := Cols2 := NumMatches := *获得特征点points_foerstner (Image1, 1, 2, 3, 200, 0.3, gauss, false, RowJunctionsF, ColJunctionsF, CoRRJunctionsF, CoRCJunctionsF, CoCCJunctionsF, RowAreaF, ColAreaF, CoRRAreaF, CoRCAreaF, CoCCAreaF)points_foerstner (

15、Image2, 1, 2, 3, 200, 0.3, gauss, false, RowJunctionsT, ColJunctionsT, CoRRJunctionsT, CoRCJunctionsT, CoCCJunctionsT, RowAreaT, ColAreaT, CoRRAreaT, CoRCAreaT, CoCCAreaT) * Determine the point matches and the transformation for the current* image pair.*特征点拼接。细节自己看例子proj_match_points_ransac (Image1, Image2, RowJunctionsF, ColJunctionsF, RowJunctionsT, ColJunctio

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号