-1

I am currently trying a code which I saw in a youtube tutorial(I specified it in my Github link from above). I see that there are two masks applied but I tried several RGB values and I still can`t get the lighr green pixels(which are exposed to more light). I would like to know what masks should I apply in my code and how can I tell which one is good in any given color extraction.

   image_blur = cv2.GaussianBlur(image, (7, 7), 0)
   #t unlike RGB, HSV separates luma, or the image intensity, from
   # chroma or the color information.
   #just want to focus on color, segmentation
   image_blur_hsv = cv2.cvtColor(image_blur, cv2.COLOR_RGB2HSV)

   # Filter by colour
   # 0-10 hue
   #minimum red amount, max red amount
   min_green = np.array([36, 0, 0])
   max_green = np.array([70, 255,255])
   #layer
   mask1 = cv2.inRange(image_blur_hsv, min_green, max_green)

   #birghtness of a color is hue
   # 170-180 hue
   min_green2 = np.array([188,0,0])
   max_green2 = np.array([208,243,139])
   mask2 = cv2.inRange(image_blur_hsv, min_green2, max_green2)

   #looking for what is in both ranges
   # Combine masks
   mask = mask1 + mask2

Here is my link to Github where you can find the pictures and the entire code: https://github.com/andreyy03/PlantsRecognition

Thank you!

1 Answers1

0

There is not such a thing like "the perfect filter" you just try. I've made a tool some months ago to do exactly that. Although I'm pretty sure there are better ones out there, but this can do the trick, and help you select the range/s. Of course it is not perfect. Hope it helps.

You can use it like python tool.py name_of_your_image.jpg or in a secuence python tool.py path/to/your/secuence although you'll have to play with the code a little bit in the second form.

Jose A. García
  • 888
  • 5
  • 13