[英]Remove noise from threshold TEXT images in opencv
I want to remove the noise from the background(ie make the background white in 1st and 3rd and black in 2nd) in all these images, I tried this method: Remove noise from threshold image opencv python but it didn't work, how can I do it?我想在所有这些图像中去除背景噪声(即使第 1 和第 3 背景为白色,使第 2 个背景为黑色),我尝试了这种方法: 从阈值图像中去除噪声 opencv python但它没有用,怎么能我做吗?
PS This is the original image that I am trying to enhance. PS 这是我要增强的原始图像。
You can use adaptive threshold on your original image in Python/OpenCV您可以在 Python/OpenCV 中对原始图像使用自适应阈值
Input:输入:
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.