功能:分为图像拼接和图像融合两种,融合是指把两张有重叠区域的图像融合成一张图像
注意:这个融合是基于灰度值的,所以对于两次分开拍摄的图像存在融合失败的可能。

基础的XY方向拼接

图像融合(图像之间具有重合部分)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
dev_update_off()

read_image (Image1, 'mosaic/building_01')
read_image (Image2, 'mosaic/building_02')
get_image_size (Image1, Width, Height)

* 提取特征点
points_foerstner (Image1, 1, 2, 3, 50, 0.1, 'gauss', 'true', Rows1, Columns1, CoRRJunctions, CoRCJunctions, CoCCJunctions, RowArea, ColumnArea, CoRRArea, CoRCArea, CoCCArea)
points_foerstner (Image2, 1, 2, 3, 50, 0.1, 'gauss', 'true', Rows2, Columns2, CoRRJunctions, CoRCJunctions, CoCCJunctions, RowArea, ColumnArea, CoRRArea, CoRCArea, CoCCArea)

* 不考虑径向畸变的投影匹配
proj_match_points_ransac (Image1, Image2, Rows1, Columns1, Rows2, Columns2, 'ncc', 10, 0, 0, Height, Width, 0, 0.5, 'gold_standard', 2, 42, HomMat2DUnrectified, Points1Unrectified, Points2Unrectified)

* 拼接图像
concat_obj (Image1, Image2, Images)
gen_projective_mosaic (Images, MosaicImageUnrectified, 1, 1, 2, HomMat2DUnrectified, 'default', 'false', MosaicMatrices2DUnrectified)

* 考虑径向畸变的投影匹配
proj_match_points_distortion_ransac (Image1, Image2, Rows1, Columns1, Rows2, Columns2, 'ncc', 10, 0, 0, Height, Width, 0, 0.5, 'gold_standard', 1, 42, HomMat2D, Kappa, Error, Points1, Points2)

* 用于去除径向畸变的相机参数
gen_cam_par_area_scan_telecentric_division (1.0, Kappa, 1.0, 1.0, 0.5 * (Width - 1), 0.5 * (Height - 1), Width, Height, CamParDist)

* 去除图像中的径向畸变
change_radial_distortion_cam_par ('fixed', CamParDist, 0, CamPar)
change_radial_distortion_image (Image1, Image1, Image1Rect, CamParDist, CamPar)
change_radial_distortion_image (Image2, Image2, Image2Rect, CamParDist, CamPar)

* 拼接图像
concat_obj (Image1Rect, Image2Rect, ImagesRect)
gen_projective_mosaic (ImagesRect, MosaicImage, 1, 1, 2, HomMat2D, 'default', 'false', MosaicMatrices2D)


* dev_open_window_fit_image (MosaicImage, 0, 0, -1, -1, WindowHandle)
* dev_display (MosaicImageUnrectified)
* dev_display (MosaicImage)