• 排序学习总结


    取每个对象的内接矩形框,然后再排序,根据排序的结果确定原对象顺序。

    1. inner_rectangle1(RegionAffineTrans1, Row1, Column1, Row2, Column2)
    2. gen_rectangle1(Rect,Row1, Column1, Row2, Column2)
    3. sort_region(Rect,RectSort,'character','true', 'row')
    4. count_obj (RegionAffineTrans1, Number)
    5. gen_empty_obj(RegionAffineTransSort)
    6. dev_update_off ()
    7. for i:=1 to Number by 1
    8. select_obj (RectSort, ObjectSelected1, i)
    9. for j:=1 to Number by 1
    10. select_obj (RegionAffineTrans1, ObjectSelected2, j)
    11. intersection(ObjectSelected1,ObjectSelected2,ObjectSelected)
    12. area_center (ObjectSelected, Area, Row1, Column1)
    13. if (Area>1)
    14. concat_obj(RegionAffineTransSort,ObjectSelected2,RegionAffineTransSort)
    15. break
    16. endif
    17. endfor
    18. endfor

    1. dev_update_off ()
    2. dev_close_window ()
    3. read_image (Image, 'E:/Users/laihuaxun/Desktop/14_51340_b19208273509701.jpg')
    4. get_image_size (Image, Width, Height)
    5. dev_open_window (0, 0, Width/4, Height/4, 'black', WindowHandle)
    6. dev_display (Image)
    7. draw_rectangle1 (WindowHandle, Row1, Column1, Row2, Column2)
    8. gen_rectangle1 (Rectangle, Row1, Column1, Row2, Column2)
    9. dev_display (Image)
    10. dev_display (Rectangle)
    11. *扣图
    12. reduce_domain (Image, Rectangle, ImageReduced)
    13. *分割
    14. threshold (ImageReduced, Regions, 150, 255)
    15. connection (Regions, ConnectedRegions)
    16. *筛选
    17. select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 1475, 99999)
    18. *求区域中心
    19. area_center (SelectedRegions, Area1, Row, Column)
    20. *在区域中心生成小圆
    21. tuple_gen_const (|Row|, 20.5, Radius)
    22. gen_circle (Circle, Row, Column, Radius)
    23. *对小圆排序
    24. sort_region (Circle, SortedRegions, 'character', 'true', 'row')
    25. *得到排序后的中心坐标
    26. area_center (SortedRegions, Area, Row1, Column1)
    27. *显示结果
    28. dev_display (ImageReduced)
    29. set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
    30. count_obj (SortedRegions, Number)
    31. for i:=1 to Number by 1
    32. *根扰排序后坐标得到筛选区域索引
    33. get_region_index (SelectedRegions, Row1[i-1], Column1[i-1], Index)
    34. *根据索引选择区域,这个区域就是按顺序进行选中
    35. select_obj (SelectedRegions, ObjectSelected1, Index)
    36. *显示
    37. dev_display (ObjectSelected1)
    38. dev_disp_text (i, 'image', Row1[i-1]-10, Column1[i-1]-10, 'yellow', 'box', 'false')
    39. endfor
    1. threshold (Image, Regions, 118, 255)
    2. closing_circle (Regions, RegionClosing, 55)
    3. connection (RegionClosing, ConnectedRegions)
    4. select_shape_std (ConnectedRegions, SelectedRegions, 'max_area', 70)
    5. intersection (Regions, SelectedRegions, RegionIntersection)
    6. closing_circle (RegionIntersection, RegionClosing1, 5)
    7. connection (RegionClosing1, ConnectedRegions1)
    8. select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 880.22, 10000)
    9. shape_trans (SelectedRegions1, RegionTrans, 'convex')
    10. area_center (RegionTrans, Area, Row, Column)
    11. tuple_round (Row/10, Round)
    12. Round:=Round*10
    13. Round:=Round-Round[0]
    14. Round:=round(Round/70.0)
    15. Round:=Round*70.0+Row[0]/10*10
    16. gen_region_points (Region, Round, Column)
    17. connection (Region, ConnectedRegions2)
    18. sort_region (ConnectedRegions2, SortedRegions, 'upper_left', 'true', 'row')

     

     

  • 相关阅读:
    【并发编程】Condition条件锁源码详解
    MyBatis-Plus 和swagger
    【Axure教程】中继器制作树元件
    基于stm32移植使用u8g2 库
    QT实现人脸识别
    开源模型应用落地-FastAPI-助力模型交互-WebSocket篇(三)
    设计海报都有哪些好用的软件推荐
    对比Excel学openpyxl系列之单元格选择与字体设置
    C语言字符串查找函数和错误信息报告函数(strstr、strtok,strerror)
    OpenAI 宣布, ChatGPT 网页端无需注册就能立即使用(2024年4月1日)
  • 原文地址:https://blog.csdn.net/qq_30807313/article/details/133354756