Win*_*ier 0 python opencv computer-vision
我想在所有这些图像中去除背景中的噪声(即使第一个和第三个背景为白色,第二个为黑色),我尝试了这种方法:Removenoisefromthresholdimageopencvpython但它不起作用,怎么办我做吗?
您可以在 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()
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1297 次 |
最近记录: |