思路:将原始图像转为HSV 格式,再通过颜色分割进行提取

[python]

import cv2
import numpy as np
np.set_printoptions(threshold=np.inf)
image = cv2.imread('C:\\Users\\user\\Desktop\\1093303-20171008194557012-1266465844.png')
hue_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
low_range = np.array([150, 103, 100])
high_range = np.array([180, 255, 255])
th = cv2.inRange(hue_image, low_range, high_range)
index1 = th == 255

img = np.zeros(image.shape, np.uint8)
img[:, :] = (255,255,255)
img[index1] = image[index1]#(0,0,255)
cv2.imshow('img', img)

[/python]
原始图片


提取的印章

发表评论

邮箱地址不会被公开。 必填项已用*标注