+36 70 203-3120 | agrowebsystem@gmail.com | Blog | Contact
Objectum detektárlás gyomos főldterületen

Object detection of plants

  • 278

One important step on the road to artificial intelligence is object detection. In our little example today, we are trying to detect weeds appearing in a dug up area and automatically extract them from the original image. The image was taken in my small garden using a simple Android phone.

In this small example, we only use image processing methods without artificial intelligence. However, the resulting images are good inputs for training an artificial intelligence or for a concrete use.

For the concrete task, we call on OpenCV and the Python language. In agriculture, there are many similar tasks where objects need to be extracted or recognized from a given image.

The following images show the original photo with the field and weeds. It is important to note that the image has quite strong shadow effects, which fortunately do not affect the detection of weeds.

But let’s look at it in order:

  1. The original image is first re-rendered from RGB to HSV.
  2. From the HSV color range, we extract the green color, i.e. the female parts.
  3. Then we create a grayscale image.
  4. Which, using a threshold process, we convert to a binary image.
  5. The resulting image is still very noisy, so we use an Erode-Dilate process to remove noise, remove redundant parts and fill in gaps.
  6. Then we count and colour in each plant or group of plants.
  7. We define a border for each of these areas.
  8. Then we crop the images and create the gallery, shown a little further down.

The result:

A couple of comments:

The above small script can be used to highlight plants over thousands of similar images and create a small image of up to 10s of thousands of images.

Another interesting thing is that the system detected small plants, petals, that I hadn’t noticed and suspected were a bug. But when I enlarged the original image, it turned out that, gee, there really is a small weed there, but in the shadows between the clumps the human eye didn’t notice it.

It’s a good idea to filter out the growths at the edges of images in a practical application, because straight non-natural cuts can be a bit misleading to algorithms doing recognition or teaching.

That’s it for today. Hope you enjoyed the above little program. It was just a small utility for quickly generating samples for teaching and testing an Artificial Intelligence. I will report on that in a future article.