1 Star 3 Fork 0

加冰不加糖/Halcon相关

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
图像旋转、镜像.hdev 5.33 KB
一键复制 编辑 原始数据 按行查看 历史
加冰不加糖 提交于 2023-07-31 17:21 . 图像旋转、镜像
<?xml version="1.0" encoding="UTF-8"?>
<hdevelop file_version="1.2" halcon_version="20.11.1.0">
<procedure name="main">
<interface/>
<body>
<l>gen_rectangle1 (ROI_0, -1032.77, -1599.46, 944.863, 273.265)</l>
<l>gen_rectangle1 (TMP_Region, 400, -680.547, 1200, 1250.34)</l>
<l>union2 (ROI_0, TMP_Region, ROI_0)</l>
<l>gen_rectangle1 (TMP_Region, 200, -680.547, 300, 1250.34)</l>
<l>union2 (ROI_0, TMP_Region, ROI_0)</l>
<c></c>
<l>smallest_rectangle1 (ROI_0,\
Row1, Column1, Row2, Column2)</l>
<c></c>
<l>Column_Center:=\
real(Column1+Column2)/2.0</l>
<c></c>
<l>Row_Center:=\
real(Row1+Row2)/2.0</l>
<l>stop ()</l>
<c></c>
<c>* 1:上下</c>
<c>* 2:左右</c>
<c>* 3:上下左右</c>
<c></c>
<c></c>
<c>* 当前操作</c>
<l>nFlip:= 0</l>
<l>nRotate:= 1</l>
<c></c>
<l>GenMirrorRotateHom2d (Row_Center,\
Column_Center, \
nFlip, nRotate,\
HomMat2D1)</l>
<c></c>
<c>* 对区域仿射变换</c>
<l>affine_trans_region (ROI_0, \
RegionAffineTrans, \
HomMat2D1, \
'nearest_neighbor')</l>
<c></c>
<l>GenMirrorRotateHom2d (Row_Center,\
Column_Center, \
0, 2,\
HomMat2D2)</l>
<c></c>
<c>* 对区域仿射变换-------对原图直接操作的效果图</c>
<l>affine_trans_region (ROI_0, \
RegionAffineTrans2, \
HomMat2D2, \
'nearest_neighbor')</l>
<c></c>
<c></c>
<c>* 原来的矩阵 HomMat2D1</c>
<c>* 操作的矩阵 HomMat2D2</c>
<c>* 保存矩阵的逆 InverseMatrix</c>
<c>* 操作矩阵 </c>
<l>hom_mat2d_identity (InverseMatrix)</l>
<c></c>
<c>* 矩阵求逆</c>
<l>hom_mat2d_invert (HomMat2D1, HomMat2D1_Invert)</l>
<l>hom_mat2d_compose (HomMat2D1_Invert, InverseMatrix, InverseMatrix)</l>
<c></c>
<c>* 操作矩阵</c>
<l>hom_mat2d_compose (HomMat2D2, InverseMatrix, HomMat2DWork)</l>
<c></c>
<c>* 对区域仿射变换----------对变换后的图像进行操作</c>
<l>affine_trans_region (RegionAffineTrans, \
RegionAffineTrans3, \
HomMat2DWork, \
'nearest_neighbor')</l>
<c></c>
<c></c>
<c></c>
<c></c>
<c></c>
<c></c>
<c></c>
<c></c>
<c></c>
<c></c>
<c></c>
<c></c>
<c></c>
<c></c>
<c></c>
<c></c>
</body>
<docu id="main">
<parameters/>
</docu>
</procedure>
<procedure name="GenMirrorRotateHom2d">
<interface>
<ic>
<par name="Row_Center" base_type="ctrl" dimension="0"/>
<par name="Column_Center" base_type="ctrl" dimension="0"/>
<par name="nFlip" base_type="ctrl" dimension="0"/>
<par name="nRotate" base_type="ctrl" dimension="0"/>
</ic>
<oc>
<par name="HomMat2DMirrorRotate" base_type="ctrl" dimension="0"/>
</oc>
</interface>
<body>
<l>hom_mat2d_identity (HomMat2DIdentity)</l>
<c>* 平移矩阵</c>
<l>hom_mat2d_translate (HomMat2DIdentity, \
-Row_Center,-Column_Center, \
HomMat2DTranslate)</l>
<c></c>
<c>* 缩放矩阵(镜像)</c>
<l>if (nFlip == 1)</l>
<l> hom_mat2d_scale(HomMat2DTranslate,\
-1, 1, 0, 0,HomMat2DMirror) </l>
<l>elseif (nFlip == 2)</l>
<l> hom_mat2d_scale(HomMat2DTranslate,\
1, -1, 0, 0,HomMat2DMirror) </l>
<l>elseif(nFlip == 3)</l>
<l> hom_mat2d_scale(HomMat2DTranslate,\
-1, -1, 0, 0,HomMat2DMirror)</l>
<l>else</l>
<l> hom_mat2d_scale(HomMat2DTranslate,\
1, 1, 0, 0,HomMat2DMirror)</l>
<l>endif</l>
<c></c>
<c>* 旋转矩阵</c>
<l>hom_mat2d_rotate (HomMat2DMirror, \
-rad(nRotate*90.0), \
0, 0, HomMat2DRotate)</l>
<c>* 再平移回来</c>
<l>hom_mat2d_translate(HomMat2DRotate, \
Row_Center,\
Column_Center, HomMat2DMirrorRotate)</l>
<l>return ()</l>
</body>
<docu id="GenMirrorRotateHom2d">
<parameters>
<parameter id="Column_Center"/>
<parameter id="HomMat2DMirrorRotate"/>
<parameter id="Row_Center"/>
<parameter id="nFlip"/>
<parameter id="nRotate"/>
</parameters>
</docu>
</procedure>
<procedure name="GenMirrorRotateHom2dSubpixel">
<interface>
<ic>
<par name="Row_Center" base_type="ctrl" dimension="0"/>
<par name="Column_Center" base_type="ctrl" dimension="0"/>
<par name="nFlip" base_type="ctrl" dimension="0"/>
<par name="nRotate" base_type="ctrl" dimension="0"/>
</ic>
<oc>
<par name="HomMat2DMirrorRotate" base_type="ctrl" dimension="0"/>
</oc>
</interface>
<body>
<c></c>
<l>dAngle:=nRotate*90.0</l>
<c></c>
<l>hom_mat2d_identity (HomMat2DIdentity)</l>
<l>hom_mat2d_translate (HomMat2DIdentity, \
-Row_Center-0.5,-Column_Center-0.5, \
HomMat2DTranslate)</l>
<c></c>
<l>if (nFlip == 1)</l>
<l> hom_mat2d_scale(HomMat2DTranslate,\
-1, 1, 0, 0,HomMat2DMirror) </l>
<l>elseif (nFlip == 2)</l>
<l> hom_mat2d_scale(HomMat2DTranslate,\
1, -1, 0, 0,HomMat2DMirror) </l>
<l>elseif(nFlip == 3)</l>
<l> hom_mat2d_scale(HomMat2DTranslate,\
-1, -1, 0, 0,HomMat2DMirror)</l>
<l>else</l>
<l> hom_mat2d_scale(HomMat2DTranslate,\
1, 1, 0, 0,HomMat2DMirror)</l>
<l>endif</l>
<c></c>
<c>* 旋转矩阵</c>
<l>hom_mat2d_rotate (HomMat2DMirror, \
-rad(dAngle),0,0, \
HomMat2DRotate)</l>
<c>* 平移矩阵</c>
<l>hom_mat2d_translate(HomMat2DRotate, \
Row_Center,\
Column_Center, HomMat2DMirrorRotate)</l>
<c></c>
<l>if (dAngle != int(dAngle)\
or int(dAngle)%180 == 0)</l>
<l> hom_mat2d_translate_local (HomMat2DMirrorRotate, \
0.5,0.5, \
HomMat2DMirrorRotate)</l>
<l>endif</l>
<l>return ()</l>
</body>
<docu id="GenMirrorRotateHom2dSubpixel">
<parameters>
<parameter id="Column_Center"/>
<parameter id="HomMat2DMirrorRotate"/>
<parameter id="Row_Center"/>
<parameter id="nFlip"/>
<parameter id="nRotate"/>
</parameters>
</docu>
</procedure>
</hdevelop>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/add-ice-without-sugar/halcon.git
git@gitee.com:add-ice-without-sugar/halcon.git
add-ice-without-sugar
halcon
Halcon相关
master

搜索帮助