Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import numpy as np
- img = cv2.imread("c://png.png")
- hsvimg = cv2.cvtColor(img, cv2.COLOR_RGB2HSV)
- cv2.imshow('hsvimg',img)
- can = hsvimg[:,:,2]
- #print(can)
- mask = can > 100
- intmask =mask*1
- print(intmask)
- msk1 = np.empty(mask.shape,dtype="uint8")
- for i in range(mask.shape[0]):
- for j in range(mask.shape[1]):
- if mask[i, j] == True:
- msk1[i, j] = int(1)
- else:
- msk1[i,j]= int(0)
- res = cv2.bitwise_and(img,img, mask=msk1)
- cv2.imshow('i',res)
- cv2.waitKey(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement