find_shape_model (Image, ModelID, rad(-90), rad(180), 0.7, 1, 0.5, 'least_squares', 0, 0.5,modelRow1, modelColumn1, modelAngle1, Score1)
if (|modelAngle1|>0)
vector_angle_to_rigid (0, 0, 0, modelRow1, modelColumn1, modelAngle1, HomMat2D)
affine_trans_contour_xld (ModelContours, ContoursAffineTrans, HomMat2D)
dev_set_draw ('margin')
vector_angle_to_rigid (modelRow0, modelColumn0, modelAngle0, modelRow1, modelColumn1, modelAngle1, HomMat2D1)
affine_trans_region (Rectangle, RegionAffineTrans0, HomMat2D1, 'nearest_neighbor')
endif
read_image (Image, ImageFiles[Index])
find_shape_model (Image, ModelID, rad(-180), rad(360), 0.5, 1, 0.5, 'least_squares', 0, 0.9, RowCur, ColumnCur, AngleCur, Score)
*得到现在图片与模板图 矩阵变化
vector_angle_to_rigid (RowModel, ColumnModel, AngleModel, RowCur, ColumnCur, AngleCur, HomMat2D)
* hom_mat2d_identity (HomMat2DIdentity)
* hom_mat2d_rotate (HomMat2DIdentity, AngleCur, 0, 0, HomMat2DRotate)
* hom_mat2d_translate (HomMat2DRotate, RowCur, ColumnCur, HomMat2DTranslate)
*将模板轮廓 根据矩阵变化 贴合现在图片显示
affine_trans_contour_xld (Edges, ContoursAffineTrans, HomMat2D)
*读取待旋转图片
read_image(Image, '待旋转')
*获取大小
get_image_size (Image, Width, Height)
*关闭当前活动图形窗口
dev_close_window ()
*建立和原图一样大小的窗口
dev_open_window_fit_image (Image, 0, 0, Width, Height, WindowHandle)
*选择区域填充模式
dev_set_draw ('fill')
*获取RGB三幅图
decompose3 (Image, R, G, B)
*对B进行阈值化(这个根据情况选择)
threshold (B, Regions, 87, 255)
*连接区域
connection (Regions, ConnectedRegions)
*根据像素面积大小选择区域(注意:这里不灵活,图片一变就不适应了。)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 200000, 210000)
*填满区域
fill_up (SelectedRegions, RegionFillUp)
*获取区域Phi(这里要理解Phi是什么,自己去理解吧!!)
orientation_region (RegionFillUp, Phi)
*根据Phi旋转原图
rotate_image (Image, ImageRotate, 3.1415-Phi, 'constant')
*清理活动窗口
dev_clear_window()
*显示最终旋转后的图片
dev_display (ImageRotate)
read_image(Image2,'C:/ Users / Pictures / 2.png')
*匹配01:模型初始化生成代码的BEGIN
set_system('border_shape_models','false')
*匹配01:获取模型图像
*匹配01:假设图像在
*匹配中可用01:变量最后显示在图形窗口中
copy_obj(Image2,Image,1,1)
*匹配01:从基本区域构建ROI
gen_rectangle1(ModelRegion,363.354,445.481,465.233,537.484)
*匹配01:减少模型模板
reduce_domain (Image,ModelRegion,TemplateImage)
*匹配01:创建形状模型
create_shape_model(TemplateImage,3,rad(0),rad(360),rad(2.5886),['none','no_pregeneration'],'use_polarity',[16,22,4],10,ModelId)
*匹配01 :获取模型轮廓以便稍后将其转换为图像
get_shape_model_contours(ModelContours,ModelId,1)
*匹配01:生成代码的END用于模型初始化
*匹配01:模型应用生成代码的BEGIN
*匹配01:以下操作是通常移动到
*匹配01:处理获取图像的循环
*匹配01:找到模型
*图像采集01:图像采集生成的代码01
list_files('C:/ Users / Pictures',['files',' follow_links'],ImageFiles)
tuple_regexp_select(ImageFiles,['\\。(tif | tiff | gif | bmp | jpg | jpeg | jp2 | png | pcx | pgm | ppm | pbm | xwd | ima | hobj),'ignore_case'],ImageFiles)
索引:= 0到| ImageFiles | - 1 by 1
read_image(Image,ImageFiles [Index])
*图像采集01:做一些事情
find_shape_model(Image,ModelId,rad(0),rad(360),0.7,0,0.5,'least_squares',[3,1 ],1,ModelRow,ModelColumn,ModelAngle,ModelScore)
*匹配01:将模型轮廓转换
为MatchingObjIdx 的检测位置:= 0到| ModelScore | - 1 by 1
hom_mat2d_identity(HomMat)
hom_mat2d_rotate(HomMat,ModelAngle [MatchingObjIdx],0,0,HomMat)
hom_mat2d_translate(HomMat,ModelRow [MatchingObjIdx],ModelColumn [MatchingObjIdx],HomMat)
affine_trans_contour_xld(ModelContours,TransContours,HomMat)
disp_message(3600,deg(ModelAngle),'window',20,20,'black','true')
dev_display(TransContours)
endfor
endfor
*匹配01:完成时清除模型
clear_shape_model(ModelId )