read_image (ImageOrg, 'D:/TAOCI/20250321/result/save_row7_col30_org.jpg') read_image (ImageTemp, 'D:/TAOCI/20250321/result/Temp_row7_col30.jpg') read_image (ImageOrg, 'D:/TAOCI/20250321/result/save_row7_col36_org.jpg') read_image (ImageTemp, 'D:/TAOCI/20250321/result/Temp_row7_col36.jpg') rgb1_to_gray (ImageOrg, GrayImage) ref_threshold :=100 input_threshold := 38 input_rotate:=-0.171 area_thresh :=300 minFindScore:=0.1 *原圖轉正采集 rotate_image (GrayImage, ImageRotate, input_rotate, 'constant') get_domain (ImageRotate, Domain) inner_rectangle1 (Domain, Row1, Column1, Row2, Column2) gen_rectangle1 (Rectangle, Row1, Column1, Row2, Column2) reduce_domain (ImageRotate, Rectangle, ImageReduced) *2值化圖片 mean_image (ImageReduced, ImageMean, 7, 7) threshold (ImageMean, Region, input_threshold, 255) connection (Region, ConnectedRegions) select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', area_thresh, 99999999) get_image_size (ImageMean, Width, Height) region_to_bin (SelectedRegions, BinImage, 255, 0, Width, Height) *原圖匹配模版 *create_shape_model (BinImage, 4, 0, 0.79, 'auto', 'auto', 'use_polarity', 30, 10, ModelID) *find_shape_model (ImageTemp, ModelID, 0, 0.79, 0.4, 1, 0.5, 'least_squares', 0, 0.8, Row, Column, Angle, Score) create_scaled_shape_model (BinImage, 'auto', -0.1, 0.79, 'auto', 0.9, 1.1, 'auto', 'auto', 'use_polarity', 'auto', 'auto', ModelID) get_shape_model_contours (ModelContours, ModelID, 1) * area_center (Region, Area, 2560, 2560) vector_angle_to_rigid (0, 0, 0, 2559, 2559, 0, HomMat2D) affine_trans_contour_xld (ModelContours, ContoursAffineTrans, HomMat2D) find_scaled_shape_models (ImageTemp, ModelID, -0.39, 0.78, 0.5, 1.5, minFindScore, 1, 0.5, 'least_squares', 0, 0.2, Row, Column, Angle, Scale, Score, Model) hom_mat2d_identity (HomMat2DIdentity) hom_mat2d_scale (HomMat2DIdentity, Scale, Scale, 0, 0, HomMat2DScale) hom_mat2d_rotate (HomMat2DScale, Angle, 0, 0, HomMat2DRotate) hom_mat2d_translate (HomMat2DRotate, Row,Column, HomMat2DTranslate) affine_trans_contour_xld (ModelContours, ConAffineTrans1, HomMat2DTranslate) get_image_size (BinImage, Width1, Height1) *裁剪圖片 gen_rectangle1 (Rectangle1, Row-Height1/2, Column-Width1/2, Row+Height1/2-1, Column+Width1/2-1) reduce_domain (ImageTemp, Rectangle1, ImageReduced2) crop_domain (ImageReduced2, ImagePart) get_image_size (ImagePart, Width1, Height1) *查找差異 abs_diff_image (BinImage, ImagePart, ImageAbsDiff, 1) threshold (ImageAbsDiff, Regiondiff, 100, 255) opening_circle (Regiondiff, RegionOpening, 15) *erosion_circle (Regiondiff, RegionErosion,10) connection (RegionOpening, ConnectedRegions) select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', area_thresh, 99999999)
本文來自博客園,作者:七星落地,轉載請注明原文鏈接:http://www.rzrgm.cn/dwx-bzdcxy/p/18791636
浙公網安備 33010602011771號