我正在嘗試尋找一種方法來(lái)打破已自適應(yīng)閾值的掃描文檔中的文本行?,F(xiàn)在,我將文檔的像素值存儲(chǔ)為0到255之間的無(wú)符號(hào)整數(shù),并獲取每行像素的平均值,然后根據(jù)像素值的平均值是否為0將行劃分為多個(gè)范圍大于250,然后將其取為各行范圍的中值。但是,此方法有時(shí)會(huì)失敗,因?yàn)閳D像上可能會(huì)出現(xiàn)黑色斑點(diǎn)。有沒(méi)有更抗噪的方法來(lái)執(zhí)行此任務(wù)?編輯:這是一些代碼?!芭で笔窃紙D像的名稱,“剪切”是我要分割圖像的位置。warped = threshold_adaptive(warped, 250, offset = 10)warped = warped.astype("uint8") * 255# get areas where we can split image on whitespace to make OCR more accuratecolor_level = np.array([np.sum(line) / len(line) for line in warped])cuts = []i = 0while(i < len(color_level)): if color_level[i] > 250: begin = i while(color_level[i] > 250): i += 1 cuts.append((i + begin)/2) # middle of the whitespace region else: i += 1
添加回答
舉報(bào)
0/150
提交
取消