- read_image (Image, './1.jpg')
- get_image_size (Image, Width, Height)
- threshold (Image, RegionB, 22, 255)
- connection (RegionB, RegionB)
- select_shape (RegionB, RegionB, 'area', 'and', 2000, 999999999)
- sort_region (RegionB, RegionB, 'first_point', 'true', 'column')
- select_obj (RegionB, Region1, 1)
- select_obj (RegionB, Region2, 2)
- *针对左边缘的区域
- erosion_circle (Region1, Region1E, 12.5)
- connection (Region1E, Region1E)
- dilation_circle (Region1E, Region1ED, 12.5)
- select_obj (Region1ED, Region1ED1, 1)
- select_obj (Region1ED, Region1ED2, 2)
- *1.计算左上区域
- smallest_rectangle1 (Region1ED1, Row1, Column1, Row2, Column2)
- gen_rectangle1 (Rect1U, Row1-100, Column1-50, Row1+100, Column2+50)
- intersection (Region1, Rect1U, Region1U)
- gen_rectangle1 (Rect1D, Row2-100, Column1-50, Row2+100, Column2+50)
- intersection (Region1ED1, Rect1D, Region1D)
- union2 (Region1U, Region1D, Region11)
- smallest_rectangle2 (Region11, Row11, Column11, Phi11, L111, L211)
- *左上测量结果可视化
- get_rect2_vertex (Row11, Column11, Phi11, L111, L211,\
- RowTL, ColTL, RowTR, ColTR,\
- RowBL, ColBL, RowBR, ColBR)
- gen_arrow_contour_xld (ArrowS111, (RowTL+RowTR)/2, (ColTL+ColTR)/2, (RowBL+RowBR)/2, (ColBL+ColBR)/2, 40, 40)
- gen_arrow_contour_xld (ArrowS112, (RowBL+RowBR)/2, (ColBL+ColBR)/2, (RowTL+RowTR)/2, (ColTL+ColTR)/2, 40, 40)
- gen_contour_polygon_xld (ContourS111, [RowTL,RowTR], [ColTL,ColTR])
- gen_contour_polygon_xld (ContourS112, [RowBL,RowBR], [ColBL,ColBR])
- concat_obj (ArrowS111, ArrowS112, ObjectsConcat1)
- concat_obj (ContourS111, ContourS112, ObjectsConcat2)
- concat_obj (ObjectsConcat1, ObjectsConcat2, ConShow11)
- *计算左下区域
- *获得左下区域Region12
- dilation_circle (Region1D, Region1D, 20.5)
- difference (Region1, Region1D, Region1)
- connection (Region1, Region1)
- sort_region (Region1, Region1, 'first_point', 'true', 'row')
- select_obj (Region1, Region12, 2)
- *2.计算和可视化
- smallest_rectangle2 (Region12, Row12, Column12, Phi12, L112, L212)
- get_rect2_vertex (Row12, Column12, Phi12, L112, L212,\
- RowTL, ColTL, RowTR, ColTR,\
- RowBL, ColBL, RowBR, ColBR)
- gen_arrow_contour_xld (ArrowS121, (RowTL+RowTR)/2, (ColTL+ColTR)/2, (RowBL+RowBR)/2, (ColBL+ColBR)/2, 40, 40)
- gen_arrow_contour_xld (ArrowS122, (RowBL+RowBR)/2, (ColBL+ColBR)/2, (RowTL+RowTR)/2, (ColTL+ColTR)/2, 40, 40)
- gen_contour_polygon_xld (ContourS121, [RowTL,RowTR], [ColTL,ColTR])
- gen_contour_polygon_xld (ContourS122, [RowBL,RowBR], [ColBL,ColBR])
- concat_obj (ArrowS121, ArrowS122, ObjectsConcat1)
- concat_obj (ContourS121, ContourS122, ObjectsConcat2)
- concat_obj (ObjectsConcat1, ObjectsConcat2, ConShow12)
- *处理右侧区域
- smallest_rectangle1 (Region2, Row1R2, Column1R2, Row2R2, Column2R2)
- gen_rectangle1 (Rect2U, Row1R2-1, Column1R2, Row1R2+400, Column2R2)
- intersection (Region2, Rect2U, Region2U)
- gen_rectangle1 (Rect2D, Row2R2-150, Column1R2, Row2R2, Column2R2)
- intersection (Region2, Rect2D, Region2D)
- connection (Region2U, Region2U)
- sort_region (Region2U, Region2U, 'first_point', 'true', 'column')
- connection (Region2D, Region2D)
- sort_region (Region2D, Region2D, 'first_point', 'true', 'column')
- select_obj (Region2U, Region2U1, 1)
- select_obj (Region2U, Region2U2, 2)
- select_obj (Region2D, Region2D1, 1)
- select_obj (Region2D, Region2D2, 2)
- union2 (Region2U1, Region2D2, Region21)
- union2 (Region2U2, Region2D1, Region22)
- *3.计算和可视化
- smallest_rectangle2 (Region21, Row21, Column21, Phi21, L121, L221)
- get_rect2_vertex (Row21, Column21, Phi21, L121, L221,\
- RowTL, ColTL, RowTR, ColTR,\
- RowBL, ColBL, RowBR, ColBR)
- gen_arrow_contour_xld (ArrowS211, (RowTL+RowTR)/2, (ColTL+ColTR)/2, (RowBL+RowBR)/2, (ColBL+ColBR)/2, 40, 40)
- gen_arrow_contour_xld (ArrowS212, (RowBL+RowBR)/2, (ColBL+ColBR)/2, (RowTL+RowTR)/2, (ColTL+ColTR)/2, 40, 40)
- gen_contour_polygon_xld (ContourS211, [RowTL,RowTR], [ColTL,ColTR])
- gen_contour_polygon_xld (ContourS212, [RowBL,RowBR], [ColBL,ColBR])
- concat_obj (ArrowS211, ArrowS212, ObjectsConcat1)
- concat_obj (ContourS211, ContourS212, ObjectsConcat2)
- concat_obj (ObjectsConcat1, ObjectsConcat2, ConShow21)
- *4.计算和可视化
- smallest_rectangle2 (Region22, Row22, Column22, Phi22, L122, L222)
- get_rect2_vertex (Row22, Column22, Phi22, L122, L222,\
- RowTL, ColTL, RowTR, ColTR,\
- RowBL, ColBL, RowBR, ColBR)
- gen_arrow_contour_xld (ArrowS221, (RowTL+RowTR)/2, (ColTL+ColTR)/2, (RowBL+RowBR)/2, (ColBL+ColBR)/2, 40, 40)
- gen_arrow_contour_xld (ArrowS222, (RowBL+RowBR)/2, (ColBL+ColBR)/2, (RowTL+RowTR)/2, (ColTL+ColTR)/2, 40, 40)
- gen_contour_polygon_xld (ContourS221, [RowTL,RowTR], [ColTL,ColTR])
- gen_contour_polygon_xld (ContourS222, [RowBL,RowBR], [ColBL,ColBR])
- concat_obj (ArrowS221, ArrowS222, ObjectsConcat1)
- concat_obj (ContourS221, ContourS222, ObjectsConcat2)
- concat_obj (ObjectsConcat1, ObjectsConcat2, ConShow22)
- dev_clear_window ()
- dev_display (Image)
- dev_set_color ('red')
- dev_display (ConShow11)
- disp_message (200000, 'L: '+number((L111*2)$'.2f')+' pix', 'image', Row11, Column11-200, 'green', 'false')
- dev_display (ConShow12)
- disp_message (200000, 'L: '+number((L112*2)$'.2f')+' pix', 'image', Row12, Column12-200, 'green', 'false')
- dev_display (ConShow21)
- disp_message (200000, 'L: '+number((L121*2)$'.2f')+' pix', 'image', Row21, Column21-200, 'green', 'false')
- dev_display (ConShow22)
- disp_message (200000, 'L: '+number((L122*2)$'.2f')+' pix', 'image', Row22-200, Column22-200, 'green', 'false')
复制代码
|