#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# Flow Field from Image

edited August 2014

I would like to start a discussion on how to make a flow field from an image. I have searched but have not found a method that describes creating it from an image. The idea is outlined (@11:55) in Daniel Schiffman's Nature of Code video on the subject here:

• Has anyone come across a method to do this?

-> Sample an image -> Perhaps "get()" the color of each pixel at some resolution lower than the image -> Fill a 2D array with this. -> Convert the color into an angle and load that into the PVector array.

However, I have not the syntax to accomplish this yet. I will try tonight and see where I can get.

Tagged:

If you have a PVector array in a grid of locations you can just use get() or the pixel array to get the color for each location. Then get the color's hue() en map if to a range from 0 to TWO_PI, then use that to create a vector with PVector.fromAngle(). Done.

• Excellent, that was a good one! I just used the get() function recently and was wondering if it could be applied in this direction - no pun.

Somehow, somehow I missed that there IS ALREADY AN EXAMPLE in the Nature of Code Book: https://github.com/shiffman/The-Nature-of-Code-Examples/tree/master/chp6_agents/FlowfieldImage

Of course I need to explore the route you suggested @amnon, but ultimately, I am looking to make some sort of boundary differential near every edge in the image. Once again assuming a binary image, I was thinking of using some sort of cellular automata Moore Neighborhood matrix to evaluate each pixel and the neighbors. When it encountered opposite color neighbors it would draw towards or away from the edge. Just a thought, need to keep coding and learning!

http://en.wikipedia.org/wiki/Moore_neighborhood