#SciFri: Using ImageJ to work out canopy cover
Sorry for the lack of a #SciFri blog post over the past month or so, I’ve been busy with fieldwork and a few other things! I was intending to post this a short while ago but I’ve had to tease out a few issues (that I’ll come to later). So as regular readers will know, I’ve been busy for the past few months chasing barred grass snakes (Natrix helvetica) in order to collect data for the PhD. One of the many parameters that I’m measuring is the canopy cover of each of the refugia. This has proved to be quite challenging but I think I’ve found an easily producible method of working out the total canopy area and I’m happy to share it with you!
One of the reasons it has taken me so long to get to the stage of being able to write this post, is because it took me so long to find a way to take a photo of the canopy cover that varied very little between each of the refugia. I’ve tried number of various different camera angles and keeping things kept to the same focal length but again, there was too much variation. I then struck upon and an idea based on something my friend had previously done to measure the canopy cover along a transect in the Andean rainforest – using a fish-eye lens to take the photos! I scoured eBay and Amazon to find a fish-eye lens adapted that could easily attach into my camera (Pentax K-50) and bought a few to see which work best.
This is where I hit another stumbling block, some of the screw in lenses sent to me were not as they were advertised. They were instead wide-angle lens adaptors and not the fish-eye adaptor I had been promised. This was no big issue, I hadn’t spent thousands of pounds on them and they were coming from questionable sellers overseas. I managed to return a couple of them on the grounds that they were no where near what they were described to be. This put me off using my DSLR and instead I turned my iPhone. It had a camera, could I buy a fish-eye lens adaptor for it? The answer was yes and they are relatively inexpensive so in my basket one went!
I had much more success with the clip-on style smartphone fish-eye lens as you can see from the photo above. The next issue is how to work out how many canopy cover you have? You could go old school and lay a grid over the image to work out your cover but I’m sure we can do better than that! I’ve used ImageJ a number of times in the past for various projects (such as measuring the length of slow worms) but I’d never used it for anything like this, so it’s taken a bit of work to drill down the protocol. The first thing is to transform the photo into a binary 8-bit image (of black and white pixels) of which the ratio can then be counted by ImageJ to give you a percentage cover.
As you can see from the above image, the conversion isn’t perfect but things are consistent across images. Sometimes some pre-binary editing needs to be done to ensure there is enough contrast between the sky/clouds and the vegetation that ImageJ is able to determine the outlines correctly. This can also be tweaked by increasing or decreasing the threshold, both method works it just depends which works best for you and how many images you’ve got to process.
I’ve used this process for each of my refugia and I intend to going into the future as well. From here you can select your area and then tell ImageJ to give you the total area taken up by both the white and black pixels, therefore giving you a value for canopy cover and open sky. If you’d like me yo cover this in a future post then please leave a comment below or feel free to contact me on Twitter.