我想删除包含文本的图像的背景,使其在白色背景上的文本。
图像样本
到目前为止,我已经尝试过获得图像的HSV和上下限,但我找不到可以消除所有背景效果的上下限
到目前为止使用的代码:
import cv2
import numpy as np
# Take each frame
filename = 'img2.png'
img = cv2.imread(filename, 1)
# Convert BGR to HSV
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
# define range of blue color in HSV
lower_blue = np.array([110,50,50])
upper_blue = np.array([130,255,255])
# Threshold the HSV image to get only blue colors
image_final = cv2.inRange(hsv, lower_blue, upper_blue)
# Bitwise-AND mask and original image
res = cv2.bitwise_and(img,img, mask= mask)
cv2.imshow('frame',img)
cv2.imwrite('mask.png',image_final)
cv2.waitKey(0)
有没有更好的方法,或者我必须结合多个下限和上限才能达到我的目标?
https://stackoverflow.com/questions/50768295
复制相似问题