Image Segmentation - Cleaning up

Hey Guys! I was trying to segment the crops from the soil as seen in the following image(‘Segmentation.JPG’).

I tried using a median filter to clean up the noise but I am not able to get a clear distinct segmented image.

This is the best I could get after using a median filter(‘median_filter.jpg’)

How do I go about achieving a clear segmented image something of this sort? (‘clear_segmented.jpg’)

Since this is a common problem on this forum there are some variants to solve the segmentation problem.

One solution would be to use the exellent Trainable Weka Segmentation plugin:

You will find a lot of resources and threads about this plugin when searching this forum for old threads or the ImageJ mailing list.

You could also try to simply color threshold the Image (is it a NDVI variant?) for segmentation see:

Have also a look at Template matching:

1 Like

For color images you can also use SIOX, which combines color clustering with morphology operators to refine the result:



The image is not a NDVI variant. It is just a simple RGB image unfortunately. The problem is the whole process needs to be done in real time using a Raspberry pi 3. Not too sure if it is powerful enough to perform these advanced concepts?

Hey! That looks lovely! I was just wondering if this would be able to detect say even the smaller plants like in the following image? The algorithm should be able to detect and classify both the type of plants ( small and big).

Object of such a difference in size are difficult for SIOX. You might get more lucky using the Trainable Weka Segmentation.

@iarganda Hey! So, I tried trainable weka segmentation. The following is the classifier I developed with three different classes ( crop, weed and background).

I tried loading a different image to see if the classifier does a good job:

It does a good job recognising all the crops.(misclassified the weed as crop as well)

Is there anyway to train the classifier with more than one image? How many do you reckon will be needed in order for justifiable results? Is there any other way around this?

Yes, you can use several images if you open them as a stack. But be aware that RGB images might use more RAM.

It depends on how similar your images are. If they keep the same colors and shapes of the objects of interest, then you won’t need many to train, but that’s not usually the case because the illumination and colors normally change among image acquisitions. You might want to normalize your images before processing them. Have a look at this conversation in the forum.