Forums > Jitter

### Most Prominent colour? (not jit.3m)

Apr 10 2007 | 10:23 pm

I am looking for a way to look at a matrix and see the most prominent
colour or section of colours.

I don’t want the average colour on screen, like, say you have a big red
field and a smaller blue field in the matrix. If I apply jit.3m I will
basically get a violet colour as the RGB mean. I would like to output
"red" in this example.

Would jit.histogram or jit.colorspace be helpful here?

Cheers,
Andreas.

Apr 10 2007 | 10:42 pm

If you want the most frequent color, jit.histogram is the object you need.

wes

On 4/10/07, Andreas Wetterberg wrote:
> I am looking for a way to look at a matrix and see the most prominent
> colour or section of colours.
>
> I don’t want the average colour on screen, like, say you have a big red
> field and a smaller blue field in the matrix. If I apply jit.3m I will
> basically get a violet colour as the RGB mean. I would like to output
> "red" in this example.
>
> Would jit.histogram or jit.colorspace be helpful here?
>
> Cheers,
> Andreas.
>

Apr 11 2007 | 5:19 am

Hi Wes,
Yes, histogram helps me clearly visualize what’s going on with regard to
colour in the matrix, but I honestly don’t have any idea how to
automatically extract an RGB value from histogram that says "THIS is the
most prominent value". Any pointers to send me in the right direction,
and I’ll happily patch it up for yall.

cheers,
Andreas.

Wesley Smith skrev:
> If you want the most frequent color, jit.histogram is the object you
> need.
>
> wes
>

Apr 11 2007 | 5:34 am

Actually now that I look at it, jit.histogram isn’t quite what you
want because it does per-plane binning. The only way I can think to
do it with standard jitter objects is to somehow make the 3 color
planes into a single plane of unique values per color triplet my
making a long with its 32 bytes as the ARGB char values. That’s a
pain to do. Seems like what you want calls for a custom external.
Perhaps someone else has a better idea?

wes

Apr 11 2007 | 7:21 am

Colorspace conversion? For example jit.rgb2hsl and then use
jit.histogram to extract the hue plane info?

M.

Wesley Smith wrote:
> Actually now that I look at it, jit.histogram isn’t quite what you
> want because it does per-plane binning. The only way I can think to
> do it with standard jitter objects is to somehow make the 3 color
> planes into a single plane of unique values per color triplet my
> making a long with its 32 bytes as the ARGB char values. That’s a
> pain to do. Seems like what you want calls for a custom external.
> Perhaps someone else has a better idea?
>
> wes
>
>

Apr 13 2007 | 6:39 am

jit.rgb2hsl + jit.histogram is the way to, but you will run into problems with multi-modal distributions. For example, take the following hue values:

0: 2
1: 2
2: 2
3: 2
155: 6

If you just look at the highest value, it would appear that blue (155) with 6 pixels is the most prominent colour. However, values 0 to 3 (red) account for 8 pixels, so there is really more red than blue.

Apr 13 2007 | 11:43 am

and that’s where jit.charmap might come in handy, no?

On Apr 13, 2007, at 8:39 AM, Jean-Marc Pelletier wrote:

>
> jit.rgb2hsl + jit.histogram is the way to, but you will run into
> problems with multi-modal distributions. For example, take the
> following hue values:
>
> 0: 2
> 1: 2
> 2: 2
> 3: 2
> 155: 6
>
> If you just look at the highest value, it would appear that blue
> (155) with 6 pixels is the most prominent colour. However, values 0
> to 3 (red) account for 8 pixels, so there is really more red than
> blue.

Apr 13 2007 | 12:24 pm

This sounds really really exciting for me. If anyone cracks this in a
patch I’d be so psyched!

Andreas _:

nesa skrev:
> and that’s where jit.charmap might come in handy, no?
>
> On Apr 13, 2007, at 8:39 AM, Jean-Marc Pelletier wrote:
>
>> jit.rgb2hsl + jit.histogram is the way to, but you will run into
>> problems with multi-modal distributions. For example, take the
>> following hue values:
>>
>> 0: 2
>> 1: 2
>> 2: 2
>> 3: 2
>> 155: 6
>>
>> If you just look at the highest value, it would appear that blue
>> (155) with 6 pixels is the most prominent colour. However, values 0
>> to 3 (red) account for 8 pixels, so there is really more red than blue.

Apr 13 2007 | 2:34 pm

here’s one quickie:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#N vpatcher 177 250 777 650;
#P window setfont "Sans Serif" 9.;
#P newex 156 178 34 196617 zl len;
#P comment 247 163 167 196617 the rest are always zeroes;
#P comment 247 147 167 196617 have meaningfull values;
#P newex 50 74 43 196617 jit.spill;
#P newex 50 106 52 196617 t b l;
#P newex 128 252 27 196617 + 1;
#P newex 50 194 25 196617 iter;
#P newex 50 315 55 196617 zl group 8;
#P newex 50 218 88 196617 t b i;
#P newex 50 284 88 196617 zl nth;
#P newex 50 256 52 196617 zl reg;
#P newex 50 171 36 196617 zl reg;
#P inlet 50 25 15 0;
#P inlet 76 138 15 0;
#P outlet 50 337 15 0;
#P comment 247 131 243 196617 only cells with coordinates from lut list;
#P connect 3 0 12 0;
#P connect 12 0 11 0;
#P connect 11 0 4 0;
#P connect 4 0 9 0;
#P connect 9 0 7 0;
#P connect 7 0 5 0;
#P connect 5 0 6 0;
#P connect 6 0 8 0;
#P connect 8 0 1 0;
#P connect 2 0 4 1;
#P connect 11 1 5 1;
#P fasten 15 0 8 1 161 311 100 311;
#P connect 7 1 10 0;
#P connect 10 0 6 1;
#P fasten 2 0 15 0 81 163 161 163;
#P pop;
#P newobj 452 211 144 196617 p histogram list filter;
#P comment 327 393 50 196617 256 hues;
#P message 247 65 91 196617 read dvducks.mov;
#P message 233 42 76 196617 read bball.mov;
#P user multiSlider 452 245 179 163 0. 32000. 8 2664 15 0 0 1 8 66 0;
#M frgb 248 0 0;
#M brgb 0 0 0;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 248 139 0;
#M rgb5 255 229 8;
#M rgb6 46 223 25;
#M rgb7 24 251 255;
#M rgb8 11 9 223;
#M rgb9 193 32 216;
#M rgb10 220 12 12;
#P newex 452 181 131 196617 jit.histogram @autoclear 1;
#P newex 342 34 48 196617 loadbang;
#B color 6;
#P user jit.pwindow 271 266 162 122 0 1 0 0 1 0;
#P newex 342 91 52 196617 jit.fill lut;
#P message 342 61 145 196617 0 26 40 80 124 167 211 255;
#P newex 342 119 111 196617 jit.matrix lut 1 char 8;
#P newex 122 180 62 196617 jit.charmap;
#P button 64 59 15 0;
#P newex 108 234 58 196617 jit.hsl2rgb;
#P newex 108 210 53 196617 jit.pack;
#P newex 108 150 66 196617 jit.unpack;
#P newex 108 126 58 196617 jit.rgb2hsl;
#P flonum 183 39 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 183 59 42 196617 rate \$1;
#P flonum 142 39 35 9 0.5 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 108 39 15 0;
#P newex 108 59 51 196617 qmetro 2;
#P newex 108 96 142 196617 jit.qt.movie 320 240 @vol 0.;
#B color 5;
#P comment 172 393 50 196617 8 hues;
#P user jit.pwindow 107 266 162 122 0 1 0 0 1 0;
#P comment 400 41 335 196617 hand-picket hues (red-orange-yellow-
green-cyan-blue-magenta-red);
#P comment 634 249 100 196617 red and ‘hueless’;
#P connect 6 0 5 0;
#P fasten 24 0 4 0 252 93 113 93;
#P fasten 23 0 4 0 238 90 113 90;
#P connect 14 0 4 0;
#P fasten 5 0 4 0 113 89 113 89;
#P fasten 8 0 4 0 188 86 113 86;
#P connect 4 0 10 0;
#P connect 10 0 11 0;
#P connect 11 0 12 0;
#P connect 12 0 13 0;
#P connect 13 0 2 0;
#P connect 11 1 15 0;
#P connect 15 0 12 1;
#P connect 11 2 12 2;
#P connect 7 0 5 1;
#P connect 11 3 12 3;
#P connect 16 0 15 1;
#P connect 9 0 8 0;
#P fasten 4 0 19 0 113 117 277 117;
#P connect 20 0 17 0;
#P connect 17 0 18 0;
#P connect 18 0 16 0;
#P fasten 15 0 21 0 127 202 444 202 444 172 457 172;
#P connect 21 0 26 0;
#P connect 26 0 22 0;
#P fasten 17 0 26 1 347 84 591 84;
#P window clipboard copycount 27;

cheers,
nesa

Apr 13 2007 | 6:19 pm

nesa skrev:
> here’s one quickie:
AWESOME!

And, since I just got word that my little shipment of 6 big RGB LED par
lamps is coming early next week, I will definitely do some testing with
video controlling the RGBs. (*school-girlish giggle*)

Andreas.

Apr 13 2007 | 6:25 pm

I can’t think of any approaches using the standard Jitter objects.
You could program an object in Java or C that loops through the
image, counting the instances of each color. I would recommend that
you limit the range first, though, perhaps to 1000 colors by dividing
by 25 and then multiplying by 25.

Jeremy

On Apr 11, 2007, at 3:21 AM, marco lorenzin wrote:

> Colorspace conversion? For example jit.rgb2hsl and then use
> jit.histogram to extract the hue plane info?
>
> M.
>
> Wesley Smith wrote:
>> Actually now that I look at it, jit.histogram isn’t quite what you
>> want because it does per-plane binning. The only way I can think to
>> do it with standard jitter objects is to somehow make the 3 color
>> planes into a single plane of unique values per color triplet my
>> making a long with its 32 bytes as the ARGB char values. That’s a
>> pain to do. Seems like what you want calls for a custom external.
>> Perhaps someone else has a better idea?
>> wes
>
>
>

Viewing 11 posts - 1 through 11 (of 11 total)

Forums > Jitter