如何從opencv中的影像中去除噪聲(參見輸入圖片)?我想在輸出中實作這一點,我只會得到白色背景和黑色文本。

uj5u.com熱心網友回復:
假設灰度影像,您可以像這樣部分消除噪聲:
# thresholding
thresh, thresh_img = cv.threshold(img, 128, 255, 0, cv.THRESH_BINARY)
# erode the image to *enlarge* black blobs
erode = cv.erode(thresh_img, cv.getStructuringElement(cv.MORPH_ELLIPSE, (3,3)))
# fill in the black blobs that are not surrounded by white:
_, filled, _, _ = cv.floodFill(erode, None, (0,0), 255)
# binary and with the threshold image to get rid of the thickness from erode
out = (filled==0) & (thresh_img==0)
# also
# out = cv.bitwise_and(filled, thresh_img)
輸出不干凈(文本行之間有一些黑色斑點,可以通過對連接組件的大小進行閾值化來進一步去除),但這應該是一個好的開始:

轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/483308.html
上一篇:使用蒙版對特定區域進行直方圖均衡
