I need to remove the green color from the background and leave only the wheat grains in black background. Any suggestion will be appreciated? Here is how image looks like:
I need to remove the green color from the background and leave only the wheat grains in black background. Any suggestion will be appreciated? Here is how image looks like:
You mean this? :
import cv2
import numpy as npimg = cv2.imread("image.jpg")
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)mask = cv2.inRange(hsv, (0, 0, 0), (75, 255, 255))
imask = mask > 0
green = np.zeros_like(img, np.uint8)
green[imask] = img[imask]cv2.imwrite("result.png", green)
Output