+36 70 203-3120 | agrowebsystem@gmail.com | Blog | Contact
paradicsom detektálása

Tomato detection 1.

  • 355

Detecting crops is quite important in agricultural image processing. It’s important to recognize fruits and vegetables.

One of the main tasks is to detect disease on the fruit, the other is to detect the ripening fruit.

Today we will detect tomatoes. Ripe tomatoes are fortunately red, while unripe tomatoes are green. We’ll take advantage of this.

The image, which is RGB by default, will be converted to HSV format. This color transformation makes it easier to work with colors.

The red parts of the HSV color range are extracted and a mask is created from it.

This mask highlights many other red colors or shades besides tomatoes. There are over 70 small red parts in the image. These will have to be removed later.

On the mask, a contour detection is used to determine the contours that enclose the red areas.

Then, based on the length of the contours, the short ones are skipped – they are the unnecessary noise in the image – leaving the long contoured objects.

Drawing these on the original image shows a nice visible outline of the red ripe tomatoes.

But some of the tomatoes are obscured by the leaves. And here comes the second assumption, that the tomatoes in the picture are of the round variety. That is, we fit a regular circle to each of the resulting outlines.

This completes the detection of the red tomatoes.

We also calculate the number of tomatoes.

This doesn’t seem very useful, but if you feed the system 5000 images and it can say that it detected 22,000 ripe tomatoes in the plantation, that’s something to go on.

This method seems pretty good, until you give the system an image where 2 or more tomatoes are touching or partially overlapping.

I will write about this problem in my next article.