一、读取tiff 图
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)xResolution:=0.0025
yResolution:=0.0025
zResolution:=0.001
read_image (IntputImage, 'C:/Users/alber/Desktop/2023-08-15_16-38-24-982_/Sta5_002.tif')
zoom_image_factor (IntputImage, IntputImage, 1,4, 'constant')
get_domain (IntputImage, Domain)
*获取该区域的最大最小值
min_max_gray (Domain, IntputImage, 0, Min, Max, Range)
*去除无效数据
threshold (IntputImage, Region,-1.2, Max)
reduce_domain (IntputImage, Region, ImageReduced)get_image_size (ImageReduced, Width, Height)
convert_image_type (ImageReduced, ImageConvertedX, 'real')
*生成xy坐标的图像映射,乘以分辨率就是xy的相对值
gen_image_surface_first_order (ImageSurface, 'real', 1, 0, 0, 0, 0, Width, Height)
gen_image_surface_first_order (ImageSurface1, 'real', 0, 1, 0, 0, 0, Width, Height)
scale_image (ImageSurface, X, xResolution, 0)
scale_image (ImageSurface1, Y, yResolution, 0)*创建3D模型
xyz_to_object_model_3d (Y,X,ImageReduced, ObjectModel3D)
write_object_model_3d (ObjectModel3D, 'ply', 'C:/Users/alber/Desktop/abc.ply', [], [])
disp_object_model_3d (WindowHandle, [ObjectModel3D], [], [], ['color_0','alpha'], ['green',0.7])
二、平面矫正
用Z轴来矫正
select_points_object_model_3d (ObjectModel3D, 'point_coord_x', 2.73, 3.2, ObjectModel3DThresholded)
select_points_object_model_3d (ObjectModel3DThresholded, 'point_coord_y', 1, 3.4, ObjectModel3DThresholded)
fit_primitives_object_model_3d (ObjectModel3DThresholded, ['primitive_type','fitting_algorithm'], ['plane','least_squares_tukey'], ObjectModel3DOut)* 这一步很重要
get_object_model_3d_params (ObjectModel3DOut, 'primitive_parameter_pose', pose)*用Z轴来矫正* 将旋转的角度转转回去pose[3]:=-pose[3]pose[4]:=-pose[4]pose[5]:=-pose[5]
write_object_model_3d (ObjectModel3DThresholded, 'ply', 'C:/Users/alber/Desktop/abc3333.ply', [], [])
*
rigid_trans_object_model_3d (ObjectModel3DThresholded, pose, ObjectModel3DRigidTrans)
write_object_model_3d (ObjectModel3DRigidTrans, 'ply', 'C:/Users/alber/Desktop/abc3333afffff.ply', [], [])rigid_trans_object_model_3d (ObjectModel3D, pose, ObjectModel3DRigidProdUCE)
write_object_model_3d (ObjectModel3DRigidProdUCE, 'ply', 'C:/Users/alber/Desktop/ABC_CR.ply', [], [])
三、 从一个姿态转到指定的姿态
1、将原始姿态pose ->matrix1
2、将指定的姿态pose 2->matrix2
3、svd 矩阵分解,计算出两个姿态的差接矩阵M
4、矩阵-》pose
5、rigid_trans_object_model_3d
矫正前:
矫正后:
全部代码:
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)xResolution:=0.0025
yResolution:=0.0025
zResolution:=0.001
read_image (IntputImage, 'C:/Users/alber/Desktop/2023-08-15_16-38-24-982_/Sta5_002.tif')
zoom_image_factor (IntputImage, IntputImage, 1,4, 'constant')
get_domain (IntputImage, Domain)
*获取该区域的最大最小值
min_max_gray (Domain, IntputImage, 0, Min, Max, Range)
*去除无效数据
threshold (IntputImage, Region,-1.2, Max)
reduce_domain (IntputImage, Region, ImageReduced)get_image_size (ImageReduced, Width, Height)
convert_image_type (ImageReduced, ImageConvertedX, 'real')
*生成xy坐标的图像映射,乘以分辨率就是xy的相对值
gen_image_surface_first_order (ImageSurface, 'real', 1, 0, 0, 0, 0, Width, Height)
gen_image_surface_first_order (ImageSurface1, 'real', 0, 1, 0, 0, 0, Width, Height)
scale_image (ImageSurface, X, xResolution, 0)
scale_image (ImageSurface1, Y, yResolution, 0)*创建3D模型
xyz_to_object_model_3d (Y,X,ImageReduced, ObjectModel3D)
write_object_model_3d (ObjectModel3D, 'ply', 'C:/Users/alber/Desktop/abc.ply', [], [])
disp_object_model_3d (WindowHandle, [ObjectModel3D], [], [], ['color_0','alpha'], ['green',0.7])select_points_object_model_3d (ObjectModel3D, 'point_coord_x', 2.73, 3.2, ObjectModel3DThresholded)
select_points_object_model_3d (ObjectModel3DThresholded, 'point_coord_y', 1, 3.4, ObjectModel3DThresholded)
fit_primitives_object_model_3d (ObjectModel3DThresholded, ['primitive_type','fitting_algorithm'], ['plane','least_squares_tukey'], ObjectModel3DOut)* 这一步很重要
get_object_model_3d_params (ObjectModel3DOut, 'primitive_parameter_pose', pose)*用Z轴来矫正* 将旋转的角度转转回去pose[3]:=-pose[3]pose[4]:=-pose[4]pose[5]:=-pose[5]
write_object_model_3d (ObjectModel3DThresholded, 'ply', 'C:/Users/alber/Desktop/abc3333.ply', [], [])
*
rigid_trans_object_model_3d (ObjectModel3DThresholded, pose, ObjectModel3DRigidTrans)
write_object_model_3d (ObjectModel3DRigidTrans, 'ply', 'C:/Users/alber/Desktop/abc3333afffff.ply', [], [])rigid_trans_object_model_3d (ObjectModel3D, pose, ObjectModel3DRigidProdUCE)
write_object_model_3d (ObjectModel3DRigidProdUCE, 'ply', 'C:/Users/alber/Desktop/ABC_CR.ply', [], [])pose_compose (pose, pose, PoseCompose)svd_matrix (, 'full', 'both', MatrixUID, MatrixSID, MatrixVID)