Detecting tomatoes 2.
- 327
In the previous section we detected red tomatoes and counted how many ripe tomatoes are in the image.
Unfortunately we ended up with the result that if several tomatoes are touching or partially obscuring each other, the previous system detects 1 large tomato, which is not very accurate.
We improve the previous program a bit and separate the “merged” tomatoes.
To do this, we take advantage of the fact that the surface of the tomatoes is smooth and even, while we see concrete edges at the borders. Among other things, we humans can distinguish tomatoes by these edges.
We use an edge-highlighting detector in the original image. This will highlight any transitions and leave the smooth parts dark.
This edge highlight image is dithered to fill in any noise-induced discontinuities in the edges.
Next, we’ll make a mask of this.
We also made a mask in the previous section, but it was not of the edges, but a mask of the red color.
Now we’ll superimpose these 2 masks. In effect, we can separate the tomatoes, which are the same color, along the edges.
The result is that we have separated the tomatoes.
The resulting image shows that he detected the tomatoes touching each other nicely. It is particularly remarkable that a very stuck tomato was detected. On the other hand, green unripe tomatoes are not detected very correctly.