Recently our R&D team had to tackle quite an interesting challenge – detect colorado beetles in the images, taken with the mobile camera. In this post, we try to describe how we did an automated pest detection in natural scenes by applying image processing.

So, how do we detect those little beetles?

To address the complexity of detecting pests in the outdoor environment, we needed to come up with a set of some sort of descriptors that would allow us to separate beetles from the background. We decided to define the beetle coloring, form, structure, and create a unique descriptor. We applied in our algorithm and ran the application on the images we had. Our method showed 99% accuracy, but of course, it’s not the most representative, since we had limited dataset. Nonetheless, it’s a promising start. If you have a similar challenge, you can send us your photos, or a video.

Let’s work on the beetle detection step by step.

Here is the original image. Can you see this small pesky beetle?


Fig.1 Original image.

The first thing we need to do is to separate our beetle from the background. The easiest way would be to use color segmentation. As a result, we get a binary image. See the images below that demonstrate the whole process of the pest detection. (1)

Fig.2 Binary image with “non-green” areas (because beetles have different coloring).

Fig.3 Gradient’s horizontal image: x-gradient

Fig.4 Gradient’s vertical image: y-gradient

Fig.4. The magnitude of the gradients (3)

Fig.5. The result of filtering to the magnitude of the gradients.

As a result, we get a map of interest where the lightest pixels show with the highest probability where the beetles are. (1)

Fig. 6. Resulting image


We have presented an algorithm for automatic pest detection. The presented system is simple and yet efficient. Our image processing engineers used image processing techniques to detect the presence of insect pests in the captured image. The results and main benefits of the proposed solution are listed below:

  • The algorithms described here allow the inexpensive and scalable detection of colorado beetles.
  • The accuracy achieved by the system is good enough to allow the development of commercial products and could be a useful tool in pest control.
  • Its low computing cost allows for real-time pest detection.
  • The system can be used to measure the efficiency of pest control and pesticide products.

Here are an original set of images. Just point at the picture to see results of the pest detection.


If you found this interesting, or have some questions to our experts, just send us a message.


image processing, Matlab, C++

Insert math as
Additional settings
Formula color
Text color
Type math using LaTeX
Nothing to preview