Thursday, November 12, 2009

The art of canopy image processing

Since 2004, I’ve spent countless hours in taking and analyzing a special kind of photographs: skyward looking images that display tree crowns. Back in 2004 I managed to get a summer job at Metla, so I spent six weeks at Puolanka photographing tree crowns with a digital camera (back then it was not obvious that all cameras are digital). As a continuation project, I was hired to analyze the data: there were something like 1500 images, and emailed instructions how to analyze them with Paint Shop Pro. I needed to separate the sky and canopy pixels in the image so that the percent canopy closure could be calculated as the proportion of canopy pixels. Basically the job was a continuous torture for the keyboard and mouse (not to mention the analyst!), as most of the images needed some manual tuning before the conversion to binary format succeeded.

In spite of all this, I ended up using similar data in my master’s thesis, which meant more of the same cake. In addition, I manually painted the small gaps inside the crowns crowns black so that proportion of between-crown gaps could also be derived. Having gained some hard-earned expertise in this area, I came to contact with Hannu Ilvesniemi, who was planning a large-scale inventory in which crown photographs should also be taken. Fine, but who would analyze all those images? Luckily that wasn’t me: Jaakko Heikkinen happened to work for Hannu at that time, and he knew how Matlab could be used to repeat automatically everything that I had done manually. I was not familiar with automated image processing back then, so it looked almost like magic how he could obtain the same results than I just by typing the name of program into the Matlab command prompt. The trick is actually quite simple – using just the blue RGB channel helps to get rid of problems with clouds and contrast, and an automatic algorithm can be used to select the threshold value consistently. Even better, Jaakko could also separate the between-crown areas automatically with morphological image processing operations. He implemented this all so that results ended up neatly in excel sheets without any human interference, and an additional check image was printed for every image so that any problems could be spotted just by browsing them.

I started to feel that we had done something worth publishing – we had a nice method of analysis, images, and validation data that showed a reasonable correlation. So just the work of putting it all to paper remained. Review process went through quite smoothly, so now you can read it all from this article, download current version of our code here, and everything should work out of the box. This study is really one of the most satisfactory things that I’ve been part of during my career as a canopy researcher – I know that I’ll never need to work with canopy images using such elementary methods as I did five years ago. And the story is not over –I still use different versions of the same code for different tasks, such as estimation of LAI from hemispherical or even aerial images. As a summary: a programmer is the master of the computer, whereas the end user of the software is more or less its slave. So all the students out there – take your programming classes, someday it’ll pay back.

No comments: