This question already has an answer here:
- OpenCV Android Green Color Detection 1 answer
I just want to detect only green objects from an image which captured in natural environment.How to define it? Because in here I want to pass the threshold value let's say 'x', by using this x I want to get only green colour objects in to one colour(white) others are must appear in another colour(black) Please guide me to do this. thanks in advance.
Update:
I make a
HSV
colormap. It'smore easy and accurate
to find the color range using this map than before.And maybe I should change use
(40, 40,40) ~ (70, 255,255) in hsv
to find thegreen
.Original answer:
HSV
color-space,cv2.inRange(hsv, hsv_lower, hsv_higher)
to get the green mask.We use
the range (in hsv)
:(36,0,0) ~ (86,255,255)
for thissunflower
.The source image:
The masked green regions:
More steps:
The core source code:
Similar: