OpenCV is a fantastic tool for quickly processing satellite data. It is incredibly powerful and very fast. It has also just recently been updated; the full announcement is here. Previously I used Image Segmentation with the Watershed Algorithm to successfully map circular irrigation features using OpenCV. Like many geospatial/image processes (where there are multiple ways to get the final answer), I wondered if there is another way to map the irrigation features – with blob detection.
Wait, what is a Blob exactly?
BLOB stands for Binary Large OBject and refers to a group of connected pixels in a binary image. The term “Large” indicates that only objects of a certain size are of interest and that the other “small” binary objects are usually noise
taken from “What exactly is a Blob in OpenCV”
I’ve read a couple of blogs on blob detection and I am using the Python code in this one. What is clear is that the best results are generally going to be when the image is thresholded properly with a focus on the target – in this case the the circular irrigation fields. First, let’s have a look at RGB satellite images.
This is definitely not a good result. However the blob detector has parameters that allow us to control / filter on several variables including area, circularity and minimum distance between blobs.
Through trial and error I have adjusted some of the above parameters. The results show a much better detection rate and especially pleasing is the lack of false positives. There are however still far too many missed fields. It picked up 136 fields.
I looked at other RGB band combinations, performing histrogram stretches but it didn’t impact on the detections. Let’s take a look at some other options. First up, Landsat 8 Band.
I’d expect to see better results on this image – resolution is 15m and it’s a single grey scale image. This time I picked up 156 blobs, 20 more than before. I found that more blobs were detected (210) when I adjusted the circularity parameters closer to 1 (ie more circular), but it then gave me more false positives. This is shown below.
What about if I threshold the image in OpenCV (as per previous image segmentation)? 158 blobs detected and a few false positives – see the bottom part of the image. Meaning its worse than using the grey scale image above.
It seems that blob detection, or at least my usage of it, doesn’t seem capable of detecting all the irrigation fields. I don’t even feel at present this gets 80% of the target. Why is this? Some of the reasons could include:
- Satellite imagery is complex. The fields will be in different states at different times of the year – some are not completely circular. This is just a snap shot. The good news is that a temporal study might benefit from this type of analysis.
- Even at the resolution that Landsat captures (30-15m) it still seems the centre point, which reflects light differently from the surrounding surfaces, is being seen. This perhaps is a problem for blobs, as the connecting pixels will have a different property.
- The better defined the target is, in terms of pixels, the better the blob detector will be. I suspect blob detector would work very well on a classified satellite image.
- This is just one example. Perhaps blob detection would work in cities or using very high resolution data to detection tree tops? Plenty of areas to explore.
The code I used is here.
What are your experiences of blob detecting? I would love to hear your comments. firstname.lastname@example.org
I have grouped all my previous blogs (technical stuff / tutorials / opinions / ideas) are here http://gis.acgeospatial.co.uk