使用OpenCV进行颜色分割
重磅干货,第一时间送达
import cv2 as cv
import matplotlib.pyplot as pltfrom PIL
import Image
!wget -nv https://static.independent.co.uk/s3fs-public/thumbnails/image/2018/04/10/19/pinyon-jay-bird.jpg -O bird.png
img = Image.open('./bird.png')
blur = cv.blur(img,(5,5))
blur0=cv.medianBlur(blur,5)
blur1= cv.GaussianBlur(blur0,(5,5),0)
blur2= cv.bilateralFilter(blur1,9,75,75)
hsv = cv.cvtColor(blur2, cv.COLOR_BGR2HSV)
low_blue = np.array([55, 0, 0])
high_blue = np.array([118, 255, 255])
mask = cv.inRange(hsv, low_blue, high_blue)
res = cv.bitwise_and(img,img, mask= mask)
交流群
赞 (0)