I want to solve the following problem:

Quantify the share (numbers of pixels) of soil, leaves and fruit (ears) within the given image.

Winter Wheat

For soil, this can easily be solved by looking at one of the color-bands, e.g. green, and identify all pixels with a gray value below a certain threshold. That means: very dark pixels are soil background.

Now for the fruit ears this becomes more difficult. I'd like to set up an algorithm that identifies their structure and labels those features for me. This cannot be done by pixel-per-pixel analysis, because it's the shape of the feature that defines its true nature. In other words: leaves and fruits are both green, but they look different. If I as a person can distinguish them, an algorithm can do so as well.

I tried skimage's contours, but I will need a machine learning algorithm to help me. Most examples and tutorials I found were categorising whole images (e.g. the "digits" dataset that recognizes hand-written digits). I am puzzled about what algorithm I should try. I can imagine both supervised or unsupervised classification.

Any help or hint is very much appreciated, thanks!


1 Answer 1


The task you are trying to solve is called Semantic segmentation, which assigns a label (probabilities) to each pixel. It is a supervised task so you will need some labeled data.

All good algorithms that solves this task are based on deep learning. For example Fully Convolutional Network (FCN) or ENet.

scikit-learn is not a good choice for deep learning. The best at the moment would be PyTorch or TensorFlow. There are many implementations of semantic segmentation in both frameworks. I personaly used this implementation.

  • $\begingroup$ Thanks a lot for your reply! I know about supervised learning on a pixel basis. However, I do not want the algorithms to check each pixel as a single element, but to identify groups of pixels that make up for a certain texture. Does that work similarly? $\endgroup$ Commented Sep 2, 2018 at 14:27
  • 1
    $\begingroup$ The algorithm is not looking at a single pixel, it is looking also at the pixels in a large neighborhood. And it learns to make a decision on what suits best - texture, color, shape or whatever else. This would work for your task, the only question is how much data would you need. $\endgroup$
    – Tomas P
    Commented Sep 3, 2018 at 8:41
  • $\begingroup$ I have to admit that in the meantime I decided to go for a brute force approach. But I am very much willing to learn, so I would give it another try and maybe apply it next time. Labelling my data is no problem! Thanks for your effort :) $\endgroup$ Commented Sep 4, 2018 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.