簡體   English   中英

opencv 中去除閾值 TEXT 圖片的噪聲

[英]Remove noise from threshold TEXT images in opencv

我有這些圖片: 在此處輸入圖像描述

我想在所有這些圖像中去除背景噪聲(即使第 1 和第 3 背景為白色,使第 2 個背景為黑色),我嘗試了這種方法: 從閾值圖像中去除噪聲 opencv python但它沒有用,怎么能我做嗎?

PS 這是我要增強的原始圖像。 在此處輸入圖像描述

您可以在 Python/OpenCV 中對原始圖像使用自適應閾值

輸入:

在此處輸入圖像描述

import cv2
import numpy as np

# read image
img = cv2.imread("writing.jpg")

# convert img to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# do adaptive threshold on gray image
thresh = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 21, 10)

# write results to disk
cv2.imwrite("writing_thresh.jpg", thresh)

# display it
cv2.imshow("thresh", thresh)
cv2.waitKey(0)
cv2.destroyAllWindows()

結果:

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM