Forums > Jitter

to convert pixels to binary

June 18, 2007 | 12:14 pm

hi all

i’m attempting to load black and white line drawings into jit.qt.movie and have them come out via jit.spill as a long list of zeros and ones into a message box. my problem is that i can’t get past 256. i’ve identified iter as one culprit and tried replacing it with zl iter but i still have no joy. i’m limiting myself to 1024 values for now but i’d like to get much much higher.

any pointers welcome.

thanks

here’s the patch as it stands:

max v2;
#N vpatcher 160 44 1316 900;
#P origin -264 -24;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 18 214 65 196617 zl iter 1024;
#P window setfont "Fixedwidth Serif" 14.;
#P window linecount 29;
#P message 18 363 315 1441806 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 18 270 102 196617 mxj list.Group 1024;
#P newex 18 244 81 196617 scale 0 255 0 1;
#P button 0 68 15 0;
#P number 121 126 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 159 126 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 91 149 71 196617 pak offset 0 0;
#P message 330 87 85 196617 planemap 2 2 2 2;
#P user jit.pwindow 295 128 232 169 0 1 0 0 1 0;
#P newex 18 307 60 196617 prepend set;
#P newex 18 184 166 196617 jit.spill @plane 2 @listlength 1024;
#B color 5;
#P newex 174 213 30 196617 print;
#P flonum 115 28 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 115 49 42 196617 rate $1;
#P message 83 49 28 196617 read;
#P toggle 18 28 15 0;
#P newex 18 48 52 196617 metro 10;
#P newex 18 94 99 196617 jit.qt.movie 120 90;
#P connect 2 0 1 0;
#P fasten 4 0 0 0 120 80 23 80;
#P fasten 3 0 0 0 88 80 23 80;
#P fasten 14 0 0 0 5 88 23 88;
#P connect 1 0 0 0;
#P connect 0 0 7 0;
#P fasten 11 0 7 0 96 175 23 175;
#P connect 7 0 18 0;
#P connect 18 0 15 0;
#P connect 15 0 16 0;
#P connect 16 0 8 0;
#P connect 8 0 17 0;
#P connect 5 0 4 0;
#P connect 13 0 11 1;
#P fasten 12 0 11 2 164 145 156 145;
#P connect 7 1 6 0;
#P fasten 0 0 9 0 23 120 301 120;
#P fasten 10 0 9 0 335 115 301 115;
#P pop;


June 18, 2007 | 4:11 pm

On 18 juin 07, at 14:14, andy g wrote:

> hi all
>
> i’m attempting to load black and white line drawings into
> jit.qt.movie and have them come out via jit.spill as a long list of
> zeros and ones into a message box. my problem is that i can’t get
> past 256. i’ve identified iter as one culprit and tried replacing
> it with zl iter but i still have no joy. i’m limiting myself to
> 1024 values for now but i’d like to get much much higher.
>
> any pointers welcome.

zl object is limited to 256 items. So you can use [mxj list.Group 1]
instead. A few remarks though:
- working with big lists in the Max world is inefficient compared to
the Jitter world so you better have to do the scaling on the matrix
before converting it before.
- you can also iterate on the matrix using jit.iter

HTH,
ej


June 18, 2007 | 5:10 pm

if you have to deal with groups of numbers larger than 256 members,
best you keep it in jitter.

why do you need 1024 numbers? can you segment the matrices and do
your operations with smaller amounts at a time?

On Jun 18, 2007, at 8:14 AM, andy g wrote:

>
> hi all
>
>
> i’m attempting to load black and white line drawings into
> jit.qt.movie and have them come out via jit.spill as a long list of
> zeros and ones into a message box. my problem is that i can’t get
> past 256. i’ve identified iter as one culprit and tried replacing
> it with zl iter but i still have no joy. i’m limiting myself to
> 1024 values for now but i’d like to get much much higher.
>
>
> any pointers welcome.
>
>
> thanks
>
>
>
> here’s the patch as it stands:
>
> max v2;
> #N vpatcher 160 44 1316 900;
> #P origin -264 -24;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P newex 18 214 65 196617 zl iter 1024;
> #P window setfont "Fixedwidth Serif" 14.;
> #P window linecount 29;
> #P message 18 363 315 1441806 255 255 255 255 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
> 255 255 255 255 255 255 255 255 255 255!
> 255 255 255 255 255 255 255 255 255 255;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P newex 18 270 102 196617 mxj list.Group 1024;
> #P newex 18 244 81 196617 scale 0 255 0 1;
> #P button 0 68 15 0;
> #P number 121 126 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P number 159 126 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 91 149 71 196617 pak offset 0 0;
> #P message 330 87 85 196617 planemap 2 2 2 2;
> #P user jit.pwindow 295 128 232 169 0 1 0 0 1 0;
> #P newex 18 307 60 196617 prepend set;
> #P newex 18 184 166 196617 jit.spill @plane 2 @listlength 1024;
> #B color 5;
> #P newex 174 213 30 196617 print;
> #P flonum 115 28 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P message 115 49 42 196617 rate $1;
> #P message 83 49 28 196617 read;
> #P toggle 18 28 15 0;
> #P newex 18 48 52 196617 metro 10;
> #P newex 18 94 99 196617 jit.qt.movie 120 90;
> #P connect 2 0 1 0;
> #P fasten 4 0 0 0 120 80 23 80;
> #P fasten 3 0 0 0 88 80 23 80;
> #P fasten 14 0 0 0 5 88 23 88;
> #P connect 1 0 0 0;
> #P connect 0 0 7 0;
> #P fasten 11 0 7 0 96 175 23 175;
> #P connect 7 0 18 0;
> #P connect 18 0 15 0;
> #P connect 15 0 16 0;
> #P connect 16 0 8 0;
> #P connect 8 0 17 0;
> #P connect 5 0 4 0;
> #P connect 13 0 11 1;
> #P fasten 12 0 11 2 164 145 156 145;
> #P connect 7 1 6 0;
> #P fasten 0 0 9 0 23 120 301 120;
> #P fasten 10 0 9 0 335 115 301 115;
> #P pop;
>
>
>
>
>


June 18, 2007 | 5:39 pm

thanks for the replies.

i actually need more than 1024 values, in fact as many as there are pixels in the images i’m using. preferably i’d like to use a minumum of 120 x 90 which means i’m looking at 10,800 (!!).

basically what i want to do is represent a line drawing as binary. from that i can (hopefully) make text files, morse code, produce series of rythmic clicks etc etc – various ways of saving, representing or transmitting the data.

i’m sure there must be some way of scanning across an image and reporting whether a pixel is black or white thus giving me a zero or a one – and there must be some object that will allow me to collate that data in order.


June 18, 2007 | 5:48 pm

what about running your black and white matrix through jit.op @op –
@val 254 and using jit.textfile or jit.fprint to write the resulting
1s and 0s as ascii into a file?

On Jun 18, 2007, at 1:39 PM, andy g wrote:

>
> thanks for the replies.
>
> i actually need more than 1024 values, in fact as many as there are
> pixels in the images i’m using. preferably i’d like to use a
> minumum of 120 x 90 which means i’m looking at 10,800 (!!).
>
> basically what i want to do is represent a line drawing as binary.
> from that i can (hopefully) make text files, morse code, produce
> series of rythmic clicks etc etc – various ways of saving,
> representing or transmitting the data.
>
> i’m sure there must be some way of scanning across an image and
> reporting whether a pixel is black or white thus giving me a zero
> or a one – and there must be some object that will allow me to
> collate that data in order.
>
>
>


June 18, 2007 | 6:31 pm

jit.op @ op > , or >=, < =, etc.

On Jun 18, 2007, at 1:39 PM, andy g wrote:

>
> thanks for the replies.
>
> i actually need more than 1024 values, in fact as many as there are
> pixels in the images i’m using. preferably i’d like to use a
> minumum of 120 x 90 which means i’m looking at 10,800 (!!).
>
> basically what i want to do is represent a line drawing as binary.
> from that i can (hopefully) make text files, morse code, produce
> series of rythmic clicks etc etc – various ways of saving,
> representing or transmitting the data.
>
> i’m sure there must be some way of scanning across an image and
> reporting whether a pixel is black or white thus giving me a zero
> or a one – and there must be some object that will allow me to
> collate that data in order.
>
>

v a d e //

http://www.vade.info
abstrakt.vade.info


June 18, 2007 | 6:33 pm

I would strongly recommend using jit.peek~ and using MSP objects to
manage the data in this case, if you are looking to get a controllable
data stream out of your matrix.

Using list outputs is probably going to be totally cumbersome when
dealing with this much data.

AB


June 18, 2007 | 6:40 pm

>Using list outputs is probably going to be totally cumbersome when
>dealing with this much data.

If you have a special sound or visual effect you associate with dipping
into the deep well of understatement, this would be the time to summon
it to mind.

on the floor there’s a long wooden table/on the table there’s an open book/
on the page there’s a detailed drawing/and on the drawing is the name I took
Gregory Taylor http://www.rtqe.net


June 18, 2007 | 11:07 pm

now you mention it, MSP does seem to be the best place to go storing thousands of values. so i’ve cobbled together this little number using capture~ but i’m not convinced that what i’m getting is ‘meaningful’. the scope~ shows a square wave and the values in the capture~ pretty much suggest the same. besides a few minutes good fun turning up the volume and playing with the phasor~ it hasn’t really got me anywhere…

if anyone wants to take a look at the latest patch experiment and tell me where its all gone wrong please be my guest.

cheers

max v2;
#N vpatcher 137 88 881 803;
#P window setfont "Sans Serif" 9.;
#P message 84 569 33 196617 clear;
#P flonum 53 635 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 53 599 102 196617 capture~ f 4000 0 0;
#P flonum 268 460 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 248 485 30 196617 *~ 0;
#P number 121 245 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 121 269 39 196617 sig~ 0.;
#P user scope~ 94 364 224 494 256 3 128 -1. 1. 0 0. 0 0. 102 255 51 135 135 135 0;
#P message 199 512 27 196617 stop;
#P message 129 512 65 196617 startwindow;
#P newex 248 549 29 196617 dac~;
#P flonum 53 227 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 53 269 47 196617 *~ 320.;
#P newex 53 246 53 196617 phasor~ 3;
#P newex 53 323 78 196617 jit.peek~ scape;
#P user jit.pwindow 392 205 317 230 0 1 0 0 1 0;
#P newex 138 204 83 196617 jit.matrix scape;
#P button 120 134 15 0;
#P message 203 115 28 196617 read;
#P toggle 138 94 15 0;
#P newex 138 114 58 196617 metro 250;
#P newex 138 160 99 196617 jit.qt.movie 120 90;
#P connect 10 0 8 0;
#P connect 8 0 9 0;
#P connect 9 0 7 0;
#P fasten 1 0 19 0 143 152 12 152 12 552 58 552;
#P connect 7 0 19 0;
#P connect 21 0 19 0;
#P fasten 7 0 14 0 58 352 99 352;
#P connect 16 0 15 0;
#P connect 15 0 7 1;
#P connect 2 0 1 0;
#P connect 1 0 0 0;
#P fasten 4 0 0 0 125 154 143 154;
#P fasten 3 0 0 0 208 146 143 146;
#P connect 0 0 5 0;
#P fasten 7 0 17 0 58 347 253 347;
#P connect 17 0 11 0;
#P fasten 12 0 11 0 134 557 253 557;
#P fasten 13 0 11 0 204 557 253 557;
#P fasten 17 0 11 1 253 543 272 543;
#P connect 18 0 17 1;
#P fasten 0 0 6 0 143 189 398 189;
#P pop;


June 18, 2007 | 11:19 pm

There is nothing inherently wrong with your patch, except that there
doesn’t seem to be a stage where the data you are gathering from the
matrix becomes something meaningful. We can’t really predict what that
might be for you, as this is your project.

Good luck.

Andrew B.


June 18, 2007 | 11:32 pm

sorry – shouldn’t have lapsed into metaphorical babble ;)

i mean that i hope to be able to visualise the original image as 0s and 1s. for example if my image is (for simplicity’s sake) a white cross on a black ground i would end up with

001100
001100
111111
111111
001100
001100

even if the text file wasn’t formatted the same it could be rebuilt if one knew the original pixel dimensions. just the way that a jitter matrix can be pretty much written out as a series of numbers.

the repetitive 0s and 1s i get from my patch would never be able to be reformatted in to the drawing that generated them. i feel i’m missing something…


June 18, 2007 | 11:51 pm

aha,

What you are looking for is
examples/jitter-examples/misc/jit.lcd-ascii-art.pat

;)
AB


June 19, 2007 | 5:09 am

Converting the stuff is the easy bit. Mapping is everything, as you are
likely to find out – especially when you’re operating across sensory
modalities. Take heart – the 60s and 70s are chock full of bad proceduralist
art arid systems wanking that should provide you with all kinds of ideas
about where NOT to go (unless you like ‘em), and the opportunity to develop
a healthy respect for the Vasulkas :-). Or, alternately, do the Roethke thing
and "learn by going where to go."

One of the really great thing about the arrival of Max/MSP/Jitter into the
world is that it’s no longer enough to just say, "I mapped audio to video."
Enough people can do it that the emphasis has shifted to doing something
interesting (and Sturgeon’s Law reigns).

(my experiments are somewhere in the 90%, by the way….)


on the floor there’s a long wooden table/on the table there’s an open book/
on the page there’s a detailed drawing/and on the drawing is the name I took
Gregory Taylor http://www.rtqe.net


June 19, 2007 | 10:26 am

Quote: andrewb@cycling74.com wrote on Mon, 18 June 2007 17:51
—————————————————-
> aha,
>
> What you are looking for is
> examples/jitter-examples/misc/jit.lcd-ascii-art.pat
>
> ;)
> AB
>
—————————————————-

well i like it – but its not it.

a historical example is the image transmitted spacewards by the arecibo dish in the seventies.

http://physics.uoregon.edu/~jimbrau/astr123/Notes/ch28/AreciboMessage.html

its an image represented by a series of binary values that can be reconstituted into the image if put back into a grid of the same dimensions.

i know that this is pretty much what the jitter matrix does anyway. i just want to be able to see and store the whole thing in binary.

and thanks for the art theory and history lesson, gregory ;)


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