Ask Your Question

Revision history [back]

Color threshholding only outputs edge for green color.

So basically I tried to threshhold the white and green color. While the white color outputs ideal results, the green threshold only outputs the outline of the color.

import cv2 
import numpy as np 

img = cv2.imread('board.png')

#hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) 

lower_white = np.array([205, 235, 235]) 
upper_white = np.array([220, 240, 240]) 

lower_green = np.array([80, 140, 110]) 
upper_green = np.array([90, 160, 125]) 

mask_green = cv2.inRange(img, lower_green, upper_green)
mask_white = cv2.inRange(img, lower_white, upper_white)

mask = mask_white + mask_green

result = cv2.bitwise_and(img, img, mask = mask) 

cv2.imshow('mask', mask) 
cv2.imshow('result', result) 
cv2.waitKey(0) 
cv2.destroyAllWindows()

C:\fakepath\board.png

C:\fakepath\green_mask_doesnt_work.JPG

Color threshholding only outputs edge for green color.

So basically I tried to threshhold the white and green color. While the white color outputs ideal results, the green threshold only outputs the outline of the color.

import cv2 
import numpy as np 

img = cv2.imread('board.png')

#hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) 

lower_white = np.array([205, 235, 235]) 
upper_white = np.array([220, 240, 240]) 

lower_green = np.array([80, 140, 110]) 
upper_green = np.array([90, 160, 125]) 

mask_green = cv2.inRange(img, lower_green, upper_green)
mask_white = cv2.inRange(img, lower_white, upper_white)

mask = mask_white + mask_green

result = cv2.bitwise_and(img, img, mask = mask) 

cv2.imshow('mask', mask) 
cv2.imshow('result', result) 
cv2.waitKey(0) 
cv2.destroyAllWindows()

C:\fakepath\board.pngC:\fakepath\board.png

C:\fakepath\green_mask_doesnt_work.JPGC:\fakepath\green_mask_doesnt_work.JPG