to convert pixels to binary

andy g's icon

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 Patch
Copy patch and select New From Clipboard in Max.

Emmanuel Jourdan's icon

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

joshua goldberg's icon

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;
>
>
>
>
>

andy g's icon

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.

joshua goldberg's icon

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.
>
>
>

vade's icon

jit.op @ op > , or >=,

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 //

www.vade.info
abstrakt.vade.info

Andrew Benson's icon

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

Gregory Taylor's icon

>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

andy g's icon

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 Patch
Copy patch and select New From Clipboard in Max.

Andrew Benson's icon

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.

andy g's icon

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...

Andrew Benson's icon

aha,

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

;)
AB

Gregory Taylor's icon

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

andy g's icon

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.

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 ;)