You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Cigarette/CigaretteSingle/halcon.hdev

56 lines
2.2 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<hdevelop file_version="1.2" halcon_version="20.11.0.0">
<procedure name="main">
<interface/>
<body>
<c>*关窗口</c>
<l>dev_close_window()</l>
<c> </c>
<c>*开窗口</c>
<l>*dev_open_window (0, 0, 512, 512, 'white', WindowHandle)</l>
<c></c>
<l>read_image (Image, 'G:/ProjectFile/VS_project_file/cigarette/CigaretteSingle/image/1-1/2022-11-03_09-34-03_306_a.jpg')</l>
<l>rgb1_to_gray (Image, Image)</l>
<l>*dev_display(Image)</l>
<c></c>
<l>gen_rectangle1 (ROI_0, 206.943, 645.433, 351.551, 723.181)</l>
<c></c>
<l>region_features (ROI_0, 'width', Width)</l>
<l>region_features (ROI_0, 'height', Height)</l>
<l>reduce_domain(Image,ROI_0,ImageReduced)</l>
<l>crop_domain(ImageReduced, ImageReduced)</l>
<c>* Optimize the fft speed for the specific image size</c>
<l>optimize_rft_speed (Width, Height, 'standard')</l>
<c></c>
<c>* Construct a suitable filter by combining two gaussian</c>
<c>* filters</c>
<l>Sigma1 := 10.0</l>
<l>Sigma2 := 3.0</l>
<l>gen_gauss_filter (GaussFilter1, Sigma1, Sigma1, 0.0, 'none', 'rft', Width, Height)</l>
<l>gen_gauss_filter (GaussFilter2, Sigma2, Sigma2, 0.0, 'none', 'rft', Width, Height)</l>
<l>sub_image (GaussFilter1, GaussFilter2, Filter, 1, 0)</l>
<c></c>
<c> * Perform the convolution in the frequency domain</c>
<l>rft_generic (ImageReduced, ImageFFT, 'to_freq', 'none', 'complex', Width)</l>
<l>convol_fft (ImageFFT, Filter, ImageConvol)</l>
<l>rft_generic (ImageConvol, ImageFiltered, 'from_freq', 'n', 'real', Width)</l>
<c>* </c>
<c>* Process the filtered image</c>
<l>gray_range_rect (ImageFiltered, ImageResult, 10, 10)</l>
<l>min_max_gray (ImageResult, ImageResult, 0, Min, Max, Range)</l>
<l>threshold (ImageResult, RegionDynThresh, max([5.55,Max * 0.8]), 255)</l>
<l>connection (RegionDynThresh, ConnectedRegions)</l>
<l>select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 4, 99999)</l>
<l>union1 (SelectedRegions, RegionUnion)</l>
<l>closing_circle (RegionUnion, RegionClosing, 10)</l>
<l>connection (RegionClosing, ConnectedRegions1)</l>
<l>select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 10, 99999)</l>
<l>area_center (SelectedRegions1, Area, Row, Column)</l>
<c>* </c>
</body>
<docu id="main">
<parameters/>
</docu>
</procedure>
</hdevelop>