我想洗掉影像
import cv2
import numpy as np
# Read image
img = cv2.imread('brain.png')
hh, ww = img.shape[:2]
# threshold on white
# Define lower and uppper limits
lower = np.array([90, 120, 200])
upper = np.array([170, 200, 255])
# Create mask to only select black
thresh = cv2.inRange(img, lower, upper)
# invert threshold image
mask = 255 - thresh
# apply mask to image
result = cv2.bitwise_and(img, img, mask=mask)
# save results
cv2.imwrite('1_thresh.jpg', thresh)
cv2.imwrite('1_result.jpg', result)
cv2.imshow('thresh', thresh)
cv2.imshow('mask', mask)
cv2.imshow('result', result)
cv2.waitKey(0)
cv2.destroyAllWindows()
閾值影像:

結果:

轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/365631.html
上一篇:我將如何扭曲影像邊緣的文本?
