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 & HelpPrograms › get amount of painted pixels, and CA rules
Page Index Toggle Pages: 1
get amount of painted pixels, and CA rules (Read 449 times)
get amount of painted pixels, and CA rules
Jun 17th, 2007, 4:51pm
 
hi, I've just started my first processing applet, for now a still simple paint applet using 4 colors. Here my question: i'm looking for a smart way of getting the amount of colored pixels (for each color), (can be a rough estimate, based on percentage, so say 30% red, 20% green, 20% blue, 5% orange, and 25% not filled). How would i approach this?, because iterating each frame though all of my windows pixels, and checking what color they have seems a bit cpu intensive. I'm thinking of pattern recongnition, or downsampling techniques. What i intend to do is the following. Each color can represent a certain amount of m^2, so I can use my applet as a urban design sketch tool. The amount of m^2 is a valuable indicator for a sites development.

Let me give an example: I start painting red shapes (i.e houses) in my window. It tells me I have 20% covered in red, but my design constraint is 14%, I'd like to see the program self-reorganizes the red pixels (using some algorithm , like cellular automata maybe), to meet my set constraint of 14%. Anyone knows some examples that incorporate this principle??
Re: get amount of painted pixels, and CA rules
Reply #1 - Jun 17th, 2007, 7:12pm
 
Why not, instead of scanning every pixel, just scan every second , fourth or fifth pixel? It works very well for object tracking projects.

Pattern recognition is nigh on rocket science. Pixel based as opposed to vector based - doubly so.

What the hell is an m^2? What is m and why is it squared?

Using some logic you might save yourself from scanning the image as well. When I apply brush to paper, I don't keep daubbing the same spot, and I instantly know where I haven't painted and how much paint I've used.

If you're making a painting program, you might look up Harold Cohen. His piece AARON is a good example of the task that lies ahead.
Re: get amount of painted pixels, and CA rules
Reply #2 - Jun 17th, 2007, 8:48pm
 
thx for the feedback.

PS: for m^2 I meant square meter m², the SI derived unit of area.
Re: get amount of painted pixels, and CA rules
Reply #3 - Jul 11th, 2007, 2:56pm
 
Correct me if I'm wrong, but any kind of pattern recognition would involve iterating over pixels. Try making it like you said you *didn't* want to do, then optimise it.
Page Index Toggle Pages: 1