[Gridflow-dev] #moment_polar

Mathieu Bouchard matju at artengine.ca
Mon Nov 21 01:06:13 EST 2011


Le 2011-09-04 à 15:00:00, James Harkins a écrit :

> Sorry for the basic question -- I'm very confused about the output of 
> #moment_polar.

Sorry for completely forgetting to reply to this one.

> I have a grayscale grid going into a [#moment 2] --> [#moment_polar].

> ^^ What is the actual unit of measurement? Clearly not degrees or 
> radians. I tried scaling like so -- [expr $f1 / 16383 * 180] thinking, 
> maybe -16384 corresponds to -180 degrees and 16383 to 180 degrees.

no, -18000 corresponds to -180 degrees, and 17999 to nearly +180 degrees. 
It's the same centidegrees (hundredths of degrees) as used in much of the 
rest of GridFlow. When we chose that format for much of GridFlow, we 
needed something that worked well with ints, and I was hesitating between 
dividing the circle in 36000 or 65536 parts. The latter is more efficient 
in several ways, but 36000 makes it easier to read because no need to use 
a converter to get the babylonian degrees that everybody is used to.

However, in the case of [#moment_polar], you have to treat those values as 
mod 18000. there is no difference of meaning between angle values that are 
180 degrees apart (18000), because they're about directions of lines, not 
of arrows.

I just updated the helpfile to account for this.

> What I got is an angle hovering around -155, regardless of the image 
> contents.

If it sticks to the same values, it's because you're not doing things to 
make the inputs more distinct. [#moment] and [#moment 2] only do very 
simple statistics on the grid you give them. They give you the average 
x,y,x²,xy,y² weighted by pixel value. If you don't heavily filter the 
data, you will get stats about the whole image at once. Instead you can 
filter things by brightness using [# >] or [# <], or else filter things by 
colour by using [#inner (3 1 # ...)] and then filtering by brightness.

There's also [#labelling], which flood-fills each «1» region of a two-tone 
image and does a separate [#moment] and [#moment 2] on each distinct 
region separately and efficiently.

  ______________________________________________________________________
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC


More information about the Gridflow-dev mailing list