Last weekend, I noticed that the Seattle weather turning to crap has also turned a good deal of the livecam images in the Mike Industries live header to crap. As it turns out, the moisture we get this time of year in the Northwest can turn a scenic Puget Sound view into an indistinguishable blob of grey in about 15 minutes. To make matters worse, the livecam is actually a Sony DV cam and not a proper high-resolution digital still camera, so a poorly defined subject area really makes for a blurry and unimpressive shot.
Here is a sampling of what the header looks like under different circumstances (Note: If you can’t see the live header, make sure you have Flash installed and click the “Live” theme in the sidebar) —
Header on a good day
Header when it’s extremely foggy
Header at night
Header with no image
Now, all of this wouldn’t be so bad if I wasn’t using the livecam as a masthead for my site, but I quite intentionally am, so I needed another solution. If I could only show something else when the view outside was crappy, then that would be great.
But how can you programmatically detect crappiness in photos? Luckily in my case, it wasn’t so hard.
If the contrast of any given photo from the livecam is not sufficiently high, I can deduce one of two things: it’s really foggy or rainy out, or it’s nighttime. Both of these cases produce ugly livecam images in the header, so if I can detect when low contrast occurs, I can change the header accordingly.
I’d heard about ImageMagick in the past but never actually used it. ImageMagick is basically a server module which lets you do all sorts of programmatic things with images like stretching, rotating, sizing, etc. However, it turns out you can also fetch the standard-deviation of each RGB channel of any given image. The standard deviation of an RGB channel is the range of values which encompasses two-thirds of the total number of pixels in an image. It’s a crude measure of contrast, but it works for my purposes.
The next step was writing a PHP script which would suck in the standard deviation value of each channel, come up with an average, and then output a tiny text file containing only a “0” or “1” depending on if the contrast value was above or below my threshold. Running this script via cron every 15 minutes would give me an accurate indicator of whether current conditions were defined enough to produce a good image. And finally, in order to actually act upon that information, I could simply feed “contrast=0″ or “contrast=1″ into my Flash header via PHP and the FlashVars property.
So now that I can detect when I don’t want to show the standard livecam image, I need to figure out what to show instead. Right now, I’m simply not loading the image and leaving the header as a block of mostly negative space. The header was originally designed to look presentable without an image, so this doesn’t bother me too much.
But I want to do more. I feel like there’s something more useful I could do in the header when it’s either foggy or night time and I’d love to hear any suggestions. So far, I’ve come up with these:
- Keep it blank.
- Bring back the crappy footage for the sake of it being a “live theme” and that’s what live themes do.
- Show nicer, higher resolution photos of a foggy scene and a night time scene when it’s appropriate (taken from a real digital camera).
- Come up with some sort of other element to load into the header (like an explanatory line of text) when conditions call for it.
Anyway, I have no idea what to do. Someone even suggested doing a panning lighthouse beacon when it’s foggy but that may be over the top. Any ideas?