<?xml version="1.0" encoding="UTF-8"?>
|
<hdevelop file_version="1.1" halcon_version="12.0">
|
<procedure name="StationThree_Pretreatment">
|
<interface>
|
<io>
|
<par name="INPUT_Image" base_type="iconic" dimension="0"/>
|
</io>
|
<oo>
|
<par name="OUTPUT_Images" base_type="iconic" dimension="0"/>
|
</oo>
|
<oc>
|
<par name="OUTPUT_Params" base_type="ctrl" dimension="0"/>
|
<par name="OUTPUT_Flag" base_type="ctrl" dimension="0"/>
|
<par name="ContourRow" base_type="ctrl" dimension="0"/>
|
<par name="ContourColumn" base_type="ctrl" dimension="0"/>
|
</oc>
|
</interface>
|
<body>
|
<c>**初始化点位数组**</c>
|
<l>OUTPUT_Params:=[]</l>
|
<l>ContourRow:=[]</l>
|
<l>ContourColumn:=[]</l>
|
<c>**切图行数**</c>
|
<l>Cropi:=2</l>
|
<c>**切图列数**</c>
|
<l>Cropj:=2</l>
|
<c>**切图分辨率**</c>
|
<l>CropWidth:=2248</l>
|
<l>CropHeight:=1736</l>
|
<c>**原图分辨率**</c>
|
<l>get_image_size (INPUT_Image, Width, Height)</l>
|
<c></c>
|
<c>**重复区域,重复区域小于0不切图**</c>
|
<l>OverlapWidth:=CropWidth*Cropj-Width</l>
|
<l>OverlapHeight:=CropHeight*Cropi-Height</l>
|
<c></c>
|
<c></c>
|
<c>**切图**</c>
|
<l>try</l>
|
<l> if (OverlapWidth>=0 and OverlapHeight>=0)</l>
|
<l> for i := 1 to Cropi by 1</l>
|
<l> for j := 1 to Cropj by 1</l>
|
<l> if(j=1)</l>
|
<l> Column:=0</l>
|
<l> else</l>
|
<l> Column:=(j-1)*(CropWidth-1)-(j-1)*OverlapWidth/(Cropj-1)</l>
|
<l> endif</l>
|
<l> if(i=1)</l>
|
<l> Row:=0</l>
|
<l> else</l>
|
<l> Row:=(i-1)*(CropHeight-1)-(i-1)*OverlapHeight/(Cropi-1)</l>
|
<l> endif</l>
|
<l> if (j=1 and i=1)</l>
|
<l> gen_rectangle1 (Rectangle, Row, Column, Row+1735, Column+2247)</l>
|
<l> reduce_domain (INPUT_Image, Rectangle, ImageReduced)</l>
|
<l> crop_domain (ImageReduced, OUTPUT_Images)</l>
|
<l> get_image_size (OUTPUT_Images, Width1, Height1)</l>
|
<l> else</l>
|
<l> gen_rectangle1 (Rectangle, Row, Column, Row+1735, Column+2247)</l>
|
<l> reduce_domain (INPUT_Image, Rectangle, ImageReduced)</l>
|
<l> crop_domain (ImageReduced, ImagePart)</l>
|
<l> concat_obj (OUTPUT_Images, ImagePart, OUTPUT_Images)</l>
|
<l> endif</l>
|
<l> Params:=[Column,Row]</l>
|
<l> tuple_concat (OUTPUT_Params, Params, OUTPUT_Params)</l>
|
<l> Params:=[]</l>
|
<l> endfor</l>
|
<c> </c>
|
<l> endfor</l>
|
<l> OUTPUT_Flag:=1</l>
|
<l> else</l>
|
<l> zoom_image_size (INPUT_Image, ImageZoom, CropWidth, CropHeight, 'constant')</l>
|
<l> OUTPUT_Images:=ImageZoom</l>
|
<l> OUTPUT_Flag:=-1</l>
|
<l> endif</l>
|
<l>catch (Exception)</l>
|
<l> zoom_image_size (INPUT_Image, ImageZoom, CropWidth, CropHeight, 'constant')</l>
|
<l>* write_image (ImageZoom, 'png', 0, 'E:/JACE/P091/20211223/20211222_D002OK/OK/'+ BaseName +'_' + [i] + '_' + [j] + '.png')</l>
|
<l> OUTPUT_Images:=ImageZoom</l>
|
<l> OUTPUT_Flag:=-1</l>
|
<l>endtry</l>
|
<c></c>
|
<l>return ()</l>
|
</body>
|
<docu id="StationThree_Pretreatment">
|
<parameters>
|
<parameter id="ContourColumn"/>
|
<parameter id="ContourRow"/>
|
<parameter id="INPUT_Image"/>
|
<parameter id="OUTPUT_Flag"/>
|
<parameter id="OUTPUT_Images"/>
|
<parameter id="OUTPUT_Params"/>
|
</parameters>
|
</docu>
|
</procedure>
|
</hdevelop>
|