Green sky, blue grass

Greensky Bluegrass is a great name for a band, especially if you were trying to start a bluegrass band. The name is unfortunately also taken by a band, they’re called Greensky Bluegrass. In the opinion of some friends (Trace Friends Mucho), they’re “stealing all of our money [sic].” I don’t know what that means, but I can say they do a pretty imaginative version of Pink Floyd’s “Time.”

But enough about this band. Let’s go back to that name. Bluegrass is a genre, right? But grass isn’t blue, it’s green. You know what is blue? The sky:

blueskygreengrass
Blue sky, green grass

It’s fun to contemplate the chiasmus a bit longer than perhaps the band’s originators intended. After awhile, you start daydreaming about what the world would look like with the colors swapped. Well, daydream no longer:

greenskybluegrass
Green sky, blue grass??

 

This is pretty easily done with MATLAB’s image processing toolbox. If you studied applied math or engineering, chances are good that a professor assigned you a problem involving MATLAB, likely without giving any instruction on it. If you don’t have a soul and thus listen to talk radio, you will have noticed the manufacturer, MathWorks, Inc., advertising on your favorite millenial-targeted talk show. But for the uninitiated, MATLAB is a set of programming tools that work extremely well for certain problem domains, but are grossly inadequate for others (though that doesn’t stop people from trying).

Despite its overuse — some might even say abuse — it turns out that MATLAB is particularly well suited for image processing applications. I don’t want to get into it here, but it has to do with the types of data structures that MATLAB is optimized for. The language’s name is a shortened version of MATrix LABoratory, so naturally, the data structure that it does best is a matrix. Given that a matrix is usually just a two dimensional array of numbers, it sort of makes sense that MATLAB would handle images well, since they can be represented as two dimensional arrays of numbers.

Please don't sue me, Randall.
Discussing the in’s and out’s of why MATLAB is inappropriately applied to certain problems would be about as nerdy as an xkcd comic.

 

That’s actually only true of a grey-scale image. A color image is actually 3 two dimensional arrays, one for R, G, and B:

rgbfigs
Blue is the only thing that really needed to change

The technique I used was simple thresholding. This means that I looked at the parts of the image that were the most blue (above a threshold that I set myself) and deleted those values. Then I looked at the parts of the bottom half of the image that were above a (different) threshold for green, and added blue to those parts. Somewhat interestingly, the sky-blue color is actually quite saturated in both green and blue (we’re talking within additive color models, folks), so the recipe is:

  1. Green sky: remove blue from sky
  2. Blue grass: add blue to grass

which surprised me because I thought I was going to be adding green at some point.

In conclusion, you should definitely check out Greensky’s actual music, which turns out to be impressively expansive and sprawling given their traditional bluegrass instruments, and also happens to be quite good. No, they’re not paying me to say this, and no, I haven’t asked. I like to think that I’m tactful about the difficulties of making a living as a professional musician, unlike some others I know (I’m looking at you, Trace Friends Mucho). On the other hand, MathWorks should definitely be paying me for promoting their image processing toolbox. I’m sure they have some pretty deep pockets, what with the large scale racket they’ve built for themselves in the engineering community. I practically already have the jingle written:

violetsareredrosesareblue
Violets are red, roses are blue. MATLAB’s image processing toolbox is fast, efficient, and easy to use.

OH, and if you ever want to jazz up your MATLAB icon, I also have to tools to make the icon look way silly:

logorainbow
Pay me, MathWorks, Inc.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s