1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        python實(shí)現(xiàn)圖片中文字分割效果

        共 1737字,需瀏覽 4分鐘

         ·

        2021-04-13 21:55

        本文實(shí)例為大家分享了python實(shí)現(xiàn)圖片中文字分割的具體代碼,具體內(nèi)容如下

        1、原始圖片(包含數(shù)字):

        結(jié)果圖:

        2、原始圖片(包含文字):

        結(jié)果圖:


        3、代碼如下:

        import cv2import numpy as nppath = 'test.jpg'root = 'output\\'# 圖像resizedsize = 36img = cv2.imread(path)data = np.array(img)height = data.shape[0]width = data.shape[1]# 設(shè)置最小的文字像素高度min_val = 10 start_i = -1end_i = -1# 存放每行的起止坐標(biāo)rowinfo = [] # 行分割for i in range(height):  # 行中有字相關(guān)信息 if (not data[i].all()): end_i = i if(start_i < 0): start_i = i pass # 行中無字相關(guān)信息 elif (data[i].all() and start_i >= 0): if(end_i - start_i >= min_val): rowinfo.append((start_i, end_i)) pass start_i, end_i = -1, -1print(rowinfo) # 列分割start_j = -1end_j = -1# 最小文字像素寬度min_val_word = 5# 分割后保存編號(hào)number = 0for start, end in rowinfo: for j in range(width): # 列中有字相關(guān)信息 if(not data[start: end, j].all()): end_j = j if(start_j < 0):  start_j = j  pass # 列中無字信息 elif(data[start: end, j].all() and start_j >= 0): if(end_j - start_j >= min_val_word): img = data[start:end, start_j: end_j] im2save = cv2.resize(img, (dsize, dsize)) #歸一化處理 cv2.imwrite(root + '%d.jpg' % number, im2save) number += 1 pass start_j, end_j = -1, -1

        「?? 感謝大家」

        如果你覺得這篇內(nèi)容對(duì)你挺有有幫助的話:

        1. 點(diǎn)贊支持下吧,讓更多的人也能看到這篇內(nèi)容(收藏不點(diǎn)贊,都是耍流氓 -_-)
        2. 歡迎在留言區(qū)與我分享你的想法,也歡迎你在留言區(qū)記錄你的思考過程。
        3. 覺得不錯(cuò)的話,也可以閱讀近期梳理的文章(感謝鼓勵(lì)與支持??????):

        老鐵,三連支持一下,好嗎?↓↓↓


        歡迎大家加入到知識(shí)星球這個(gè)大家庭,這里一定有與你志同道合的小伙伴,在這里大家可以一起交流,一起學(xué)習(xí),一同吹逼,一同玩耍。。。


        長(zhǎng)按按鈕  “識(shí)別二維碼” 關(guān)注我
        更多精彩內(nèi)容等著你哦

        點(diǎn)分享

        點(diǎn)點(diǎn)贊

        點(diǎn)在

        瀏覽 85
        點(diǎn)贊
        評(píng)論
        收藏
        分享

        手機(jī)掃一掃分享

        分享
        舉報(bào)
        評(píng)論
        圖片
        表情
        推薦
        點(diǎn)贊
        評(píng)論
        收藏
        分享

        手機(jī)掃一掃分享

        分享
        舉報(bào)
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            国内自拍第一页 | 美谷朱里av在线播放 | 日韩在线视频第一页 | 男生操女生网站 | 久久久亚洲精品石原莉奈 | 国产馆操逼的视频 | 国产黄网站在线观看 | 一边吃奶一边扎下边爽了动画开始播放 | 一级a一级a免费观看视频Al明星 | 欧美xxxx黑人xyx性爽 |