字符分割时对粘连字符的处理方法
方法1:opening_rectangle1 (Solid, Cut, 1, 7),使用該方法進行分割,1是寬度,7是高度。Halcon范例bottle.hdev: Segment and read numbers on a beer bottle
方法2:使用partition_rectangle或partition_dynamic進行等間隔的字符分割,要求字符的間隔盡量保持一致
partition_dynamic(Region: Partitioned: Distance, Percent : )???? 函數作用:
在水平位置上以參數Distance的寬度分割區域,分割得到的位置是相對小的垂直部分。分割原理如下:
1、初始的分割位置是在水平方向上平均分配,也就是結果部分擁有相同的寬度。
2、分割后的塊數N是由參數Distance決定的,而Distance是由輸入區域的寬度除以N決定的。
3、分割后的等份區域進一步還計算區域間的最小垂直程度Percent,最后分割的位置與初始的最大浮動差是Distance*Percent*0.01
?
注:
?
參數列表:
Region(in):輸入的被分割區域
Partitioned(out):分割的區域
Distance(in):分割區域的大概寬度
Percent(in):分割位置的最大分數偏移
?
可能前置項
threshold, connection
?
可能替代項
partition_rectangle
方法3:滴水分割算法,該算法還沒有研究
?
將這個字符進行分割開的代碼思路
read_image (Image5, 'C:/Users/yuexinzheng/Desktop/5.png') threshold (Image5, Region1, 0, 123) fill_up (Region1, RegionFillUp1) closing_circle (RegionFillUp1, RegionClosing, 5.5) closing_rectangle1 (RegionClosing, RegionClosing1, 10, 19) fill_up (RegionClosing1, RegionFillUp2) *主要是利用opening_rectangle1()函數,將圖像部分進行膨脹,使接線明顯且加大 opening_rectangle1 (RegionFillUp2, RegionOpening1, 2, 44) *取分割開的圖與原Region的重疊區域 intersection (Region1, RegionOpening1, RegionIntersection1)方法2的代碼實現
read_image (Image5, 'C:/Users/yuexinzheng/Desktop/5.png') char_threshold (Image5,Image5 , Characters, 2, 95, Threshold) smallest_rectangle1 (Characters, Row1, Column1, Row2, Column2) region_features (Characters, 'width', Value) partition_dynamic (Characters, Partitioned, Value/2, 90)分割效果圖
總結
以上是生活随笔為你收集整理的字符分割时对粘连字符的处理方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 大牛证券锂矿板继续表现强势
- 下一篇: Unity中手动设置纵横比