[PD] pix_dump and average?
Tina Shah
surreal8 at hotmail.com
Mon Apr 10 20:57:11 CEST 2006
thanks IOhannes! yea, the average is just wrong with the current patch and
you're right, i do not want to include the alpha values. i am using gem
.90, and pix_mean_color will be very helpful in the future since that's
exactly what i want to do! i will look at frank's list-average abstraction
and see if it helps. i tried to use pix_resize and set it to 1 1, but it
didn't work, and it also didn't really work regularly... btw, i thought it
was weird that i was getting two floats, glad i could help in finding a bug
:-).
tina
----Original Message Follows----
hi
Tina Shah wrote:
> Hi List, I'm trying to get the average color data from an image. I'm
> using pix_dump and then trying to use 'average' to get the average of
> the dump, but the numbers are not matching. i tested just a 1 pixel
> image, got 4 values - 0.341176 0.360784 0.345098 1 - but the average is
> wrong - average: 0.35098.
hmm: what exactly is wrong? is "0.35098" the output of the [average]
object? or is it what you expect (because you know the image)?
i cannot reproduce the former: on my machine, [average 4] outputs
0.511765 when i send it [0.341176, 0.360784, 0.345098, 1(
i cannot reproduce the latter (since i don't have the image)
> anybody know what i'm doing wrong or know of
well:
[pix_dump] outputs a list(!) of values (r,g,b,a,r,g,b,a,...) AND
you cannot send a list to [average], it needs single numbers. so you
need to convert the list into a stream of numbers.
using a numberbox ([ \) does NOT convert a list into a stream of
numbers, it will just take the first number of that list and pass it on [1].
[average] is a moving average filter, and while you can use it to
calculate the total average of a list (with some tricks!), i would not
naturally use it.
the output of [pix_dump] also holds the alpha-value (the "1"), which you
most likely will not want to include in your averaging.
> an easier way? I'm on windows (pd .39-2) and just using gem... BTW,
what is "just using gem"? version?
in gem-0.91 (still not released) there is [pix_mean_color] which
calculates the average color of an image. (separate values for r, g, b
and a)
i don't know exactly what you want to get: separate values for r,g,b,a
or 1 "grey" value?
in the former case you will have to sort the output of [pix_dump] to
give you separate lists (or streams of floats) for the 4 channels.
since 0.39, you can do that with native pd objects (see frank's
list-abstractions, which most likely also has a [list-average] which
will output the total average of a list)
> does pix_resize work?
i thought so.
however, in older versions of gem you could not set the dimensions: it
would just resize the image to the next power-of-2 size. (see the
help-patch of the object whether in your version it is already able to
resize to an arbitrary size).
of course, if [pix_resize] does work for you, you could just use it to
resize the image to 1x1 and then do a dump.
> thanks!
i hope i gave you some clues....
mfg.asdr.
IOhannes
[1]: hey! you have discovered a bug!! sending a list of floats to a
numberbox will output 2 values (the 2nd and the 1st)!!! this should be
fixed in 0.40
More information about the Pd-list
mailing list