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