We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Sorting pixels[] by colour
Page Index Toggle Pages: 1
Sorting pixels[] by colour? (Read 584 times)
Sorting pixels[] by colour?
Mar 1st, 2008, 11:58pm
 
Hi,
I am new to processing and am trying to write a program that will take the colours of every pixel and then arrange them sort the pixels[] array by similarity of the colour.

Evidently, sort(pixels) isn't the way to go about it as I am getting bunches of white lines in between areas of colour. I am thinking this has a lot more to do with RGB theory than syntax. It's confusing because the white is popping up everywhere because of the way RGB works – I'm wondering if there's a colourmode that will let you sort things more simply than building some crazy model to sort RGB values?

Right now, i am just sorting pixels[] and using set to redraw each pixel based on the sorted array.

If anyone could point me in the right direction, that would be fantastic!

Thanks a lot!
Alan

http://img.waffl.ca/ZZ6B0DD415.jpg
Re: Sorting pixels[] by colour?
Reply #1 - Mar 2nd, 2008, 2:02pm
 
would the pixel intensity be enough ?
you could convert the pixel to a greyscale scale and sort by intensity.

I = R+G+B / 3

or using multipliers to modulate each channel

I = (R*0.3 + G*0.59+ B*0.11)


not sure how it would look but, worth a try.
Re: Sorting pixels[] by colour?
Reply #2 - Mar 2nd, 2008, 4:37pm
 
Toxi has done this a while  ago:http://toxi.co.uk/blog/2006/04/colour-code-snippets.htm
Page Index Toggle Pages: 1