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. anybody know what i'm doing wrong or know of an easier way? I'm on windows (pd .39-2) and just using gem... BTW, does pix_resize work? thanks! here's the patch:
#N canvas 514 -19 949 762 10; #X obj 143 110 gemhead; #X obj 25 259 gemwin; #X msg 25 110 create; #X msg 53 142 1; #X msg 53 172 0; #X msg 25 208 destroy; #X obj 143 203 pix_dump; #X msg 154 167 bang; #X obj 143 387 pix_texture; #X msg 149 366 quality 0; #X obj 143 409 square 2; #X obj 149 343 loadbang; #X text 197 167 trigger the pix_dump; #X obj 194 254 print dump; #X msg 398 174 bang; #X msg 559 180 clear; #X floatatom 299 195 0 0 0 0 - - -; #X obj 143 135 pix_image dumptest3.jpg; #X obj 338 280 print average; #X text 31 40 dump the pixles of the image & get an average; #X obj 338 232 average 4; #X connect 0 0 17 0; #X connect 2 0 1 0; #X connect 3 0 1 0; #X connect 4 0 1 0; #X connect 5 0 1 0; #X connect 6 0 8 0; #X connect 6 1 13 0; #X connect 6 1 16 0; #X connect 7 0 6 0; #X connect 8 0 10 0; #X connect 9 0 8 0; #X connect 11 0 9 0; #X connect 14 0 20 0; #X connect 15 0 20 0; #X connect 16 0 20 0; #X connect 17 0 6 0; #X connect 20 0 18 0;
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
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
You can use pix_blob.
[pix_video] //Or whatever | [pix_blob 1] //The size outlet will give the amount of red | [pix_blob 2] //The size outlet will give the amount of green | [pix_blob 3] //The size outlet will give the amount of blue
As an added bonus, you get centers of gravity.
Tom
On 4/10/06, Tina Shah surreal8@hotmail.com wrote:
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
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
hi, i guess this is a newbie question. i want to use frank's list-accum abstraction. i just downloaded the list_accum.pd and the help.pd but it's not working. i'm getting these errors:
tried C:\Program Files\pd\my_projects\list-drip.dll and failed tried C:\Program Files\pd\extra\list-drip.dll and failed tried C:\Program Files\pd\my_projects\list-drip\list-drip.dll and failed tried C:\Program Files\pd\extra\list-drip\list-drip.dll and failed tried C:\Program Files\pd\my_projects\list-drip.pd and failed tried C:\Program Files\pd\extra\list-drip.pd and failed tried C:\Program Files\pd\my_projects\list-drip.pat and failed tried C:\Program Files\pd\extra\list-drip.pat and failed list-drip ... couldn't create tried C:\Program Files\pd\my_projects\list-accum.dll and failed tried C:\Program Files\pd\extra\list-accum.dll and failed tried C:\Program Files\pd\my_projects\list-accum\list-accum.dll and failed tried C:\Program Files\pd\extra\list-accum\list-accum.dll and failed tried C:\Program Files\pd\my_projects\list-accum.pd and failed tried C:\Program Files\pd\extra\list-accum.pd and failed tried C:\Program Files\pd\my_projects\list-accum.pat and failed tried C:\Program Files\pd\extra\list-accum.pat and failed list-accum ... couldn't create error: inlet: expected '' but got 'list'
i didn't see any other files to download like .dll... i'm using pd .39-2 and gem .90...
thanks, tina
----Original Message Follows---- From: IOhannes m zmoelnig zmoelnig@iem.at To: Tina Shah surreal8@hotmail.com CC: pd-list@iem.at Subject: Re: [PD] pix_dump and average? Date: Mon, 10 Apr 2006 11:50:08 +0200 MIME-Version: 1.0 Received: from bay0-mc1-f18.bay0.hotmail.com ([65.54.244.26]) by bay0-imc3-s32.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 10 Apr 2006 02:48:06 -0700 Received: from mail.iem.at ([193.170.191.180]) by bay0-mc1-f18.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 10 Apr 2006 02:48:04 -0700 Received: from router.iemnet ([192.168.7.1] helo=[192.168.7.141])by mail.iem.at with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32)(Exim 4.60)(envelope-from zmoelnig@iem.at)id 1FSt04-0007AX-MW; Mon, 10 Apr 2006 11:48:04 +0200 X-Message-Info: JGTYoYF78jEHjJx36Oi8+Z3TmmkSEdPtfpLB7P/ybN8= Organization: Institute of Electronic Music and Acoustics, Graz User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en References: BAY102-F200AF4B078982F318A009899CC0@phx.gbl X-Enigmail-Version: 0.93.0.0 X-Spam-Score: -5.9 X-Spam-Level: ----- X-Spam-Tests: ALL_TRUSTED,BAYES_00 Return-Path: zmoelnig@iem.at X-OriginalArrivalTime: 10 Apr 2006 09:48:05.0294 (UTC) FILETIME=[DD7B14E0:01C65C83]
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