a1249720090@hotmail.com
2022-05-04 de73f99619354249596115845d1b8106152daa39
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?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&gt;=0 and OverlapHeight&gt;=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>