Recursion vs. queuing

July 30, 2009

Yesterday I wrote a little piece of Python code that (1) searched for fires (by pixel colour)  in MODIS rapid response true colour images and (2)  checked the surrounding pixels to see if there colour was consistent with smoke.  The original code used recursion (one function calling itself over and over again) and worked well when smoke was discrete around fires as shown below (note that the smoke-finding algorithm is still very crude here — a masters student named Victoria Wan is working on the statistical improvement of this).

07_30_2009

07_30_2009

07_30_2009

07_30_2009

At this stage of development I was pleased with how the code was working, but when tested on a this much smokier image from Russia the maximum recursion depth of 5000 was both exceeded and too much for my MacBook to handle.  The second image comes from limiting the recursion to 2000 with a BREAK for anything deeper.

07_30_2009

07_30_2009

I spent much of this afternoon with Alisha or Aran (course TAs) by my side, trying to make the problem work without recursion by queuing the pixels still needing analysis.  We got to this code at the end, and I am not the only one who got confused along the way.  This is the product:

07_30_2009

Of course we’re getting some cloud and some desert landscape here, but that doesn’t worry me.  I am really looking forward to working with Victoria on the smoke-identification algorithm.  A great outcome from this course for me so far, and a huge thank you to Greg, Aran, Alisha, Jason, Rory, Jon and Andrew who have been so patient with me.

Follow

Get every new post delivered to your Inbox.