The 27 Permutions Of The RGB Channels

Sometimes it’s nice to do something really simple.

Core Image Filter Kernels:

	The 27 permutations of the RGB channels.
	toneburst 2009

kernel vec4 RRR(sampler image) { return sample(image, samplerCoord(image)).rrra; }
kernel vec4 RRG(sampler image) { return sample(image, samplerCoord(image)).rrga; }
kernel vec4 RRB(sampler image) { return sample(image, samplerCoord(image)).rrba; }
kernel vec4 RGG(sampler image) { return sample(image, samplerCoord(image)).rgga; }
kernel vec4 RGB(sampler image) { return sample(image, samplerCoord(image)).rgba; }
kernel vec4 RGR(sampler image) { return sample(image, samplerCoord(image)).rgra; }
kernel vec4 RBR(sampler image) { return sample(image, samplerCoord(image)).rbra; }
kernel vec4 RBG(sampler image) { return sample(image, samplerCoord(image)).rbga; }
kernel vec4 RBB(sampler image) { return sample(image, samplerCoord(image)).rbba; }

kernel vec4 GRR(sampler image) { return sample(image, samplerCoord(image)).grra; }
kernel vec4 GRG(sampler image) { return sample(image, samplerCoord(image)).grga; }
kernel vec4 GRB(sampler image) { return sample(image, samplerCoord(image)).grba; }
kernel vec4 GGR(sampler image) { return sample(image, samplerCoord(image)).ggra; }
kernel vec4 GGG(sampler image) { return sample(image, samplerCoord(image)).ggga; }
kernel vec4 GGB(sampler image) { return sample(image, samplerCoord(image)).ggba; }
kernel vec4 GBR(sampler image) { return sample(image, samplerCoord(image)).gbra; }
kernel vec4 GBG(sampler image) { return sample(image, samplerCoord(image)).gbga; }
kernel vec4 GBB(sampler image) { return sample(image, samplerCoord(image)).gbba; }

kernel vec4 BRR(sampler image) { return sample(image, samplerCoord(image)).brra; }
kernel vec4 BRG(sampler image) { return sample(image, samplerCoord(image)).brga; }
kernel vec4 BRB(sampler image) { return sample(image, samplerCoord(image)).brba; }
kernel vec4 BGR(sampler image) { return sample(image, samplerCoord(image)).bgra; }
kernel vec4 BGG(sampler image) { return sample(image, samplerCoord(image)).bgga; }
kernel vec4 BGB(sampler image) { return sample(image, samplerCoord(image)).bgba; }
kernel vec4 BBR(sampler image) { return sample(image, samplerCoord(image)).bbra; }
kernel vec4 BBG(sampler image) { return sample(image, samplerCoord(image)).bbga; }
kernel vec4 BBB(sampler image) { return sample(image, samplerCoord(image)).bbba; }

Filter Function javascript:

	The 27 permutations of the RGB channels.
	toneburst 2009

function __image main(__image Image, __index Permutation) {
	switch(Permutation) {
		case  0: return RRR.apply(Image.definition, null, Image); break;
		case  1: return RRG.apply(Image.definition, null, Image); break;
		case  2: return RRB.apply(Image.definition, null, Image); break;
		case  3: return RGG.apply(Image.definition, null, Image); break;
		case  4: return RGB.apply(Image.definition, null, Image); break;
		case  5: return RGR.apply(Image.definition, null, Image); break;
		case  6: return RBR.apply(Image.definition, null, Image); break;
		case  7: return RBG.apply(Image.definition, null, Image); break;
		case  8: return RBB.apply(Image.definition, null, Image); break;
		case  9: return GRR.apply(Image.definition, null, Image); break;
		case 10: return GRG.apply(Image.definition, null, Image); break;
		case 11: return GRB.apply(Image.definition, null, Image); break;
		case 12: return GGR.apply(Image.definition, null, Image); break;
		case 13: return GGG.apply(Image.definition, null, Image); break;
		case 14: return GGB.apply(Image.definition, null, Image); break;
		case 15: return GBR.apply(Image.definition, null, Image); break;
		case 16: return GBG.apply(Image.definition, null, Image); break;
		case 17: return GBB.apply(Image.definition, null, Image); break;
		case 18: return BRR.apply(Image.definition, null, Image); break;
		case 19: return BRG.apply(Image.definition, null, Image); break;
		case 20: return BRB.apply(Image.definition, null, Image); break;
		case 21: return BGR.apply(Image.definition, null, Image); break;
		case 22: return BGG.apply(Image.definition, null, Image); break;
		case 23: return BGB.apply(Image.definition, null, Image); break;
		case 24: return BBR.apply(Image.definition, null, Image); break;
		case 25: return BBG.apply(Image.definition, null, Image); break;
		case 26: return BBB.apply(Image.definition, null, Image); break;

4 Responses to “The 27 Permutions Of The RGB Channels”

  1. 1 Sune Watts
    January 6, 2010 at 11:03 am

    Hey a|x

    You rock!

    Does your site have a global RSS feed for new entries?

    Maybe I’m just dense, but I haven’t been able to locate it.

    All the best

    • 2 toneburst
      January 6, 2010 at 11:19 am

      Thanks for the feedback!
      I’m sorry I haven’t updated it recently- I’ve been away so haven’t had a chance.

      Re. the RSS feed: in Safari on the Mac, you can get to the RSS feed for the main page by just going to the site front page, and clicking on the RSS link on the right of the Address Bar. Not sure about other browsers and OSes though. I’ve added a link to the feeds for posts and comments to the top of the right sidebar now, anyway, so if you can’t get to it any other way, you can now use those links to subscribe.



  2. February 3, 2010 at 11:16 pm

    TruchetTileTest looks trés interesting!

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


November 2009
« Oct   Feb »


Blog Stats

  • 481,663 hits

%d bloggers like this: