RGB Data from Image

Dec 21, 2009 at 9:09pm

RGB Data from Image

I am trying to extract RGB data from an image that I can convert to waveform or frequency data. I am probably going about this the wrong way but the patch below is what I have done so far (not much).

What I am not sure about with this is the (x y)coordinates. The pic I used is only 144 x 162 in Photoshop but the (x y) coordinates continue beyond those ranges. How can I get these two to correspond? Also, if you know of a better way to go about this let me know =)

– Pasted Max Patch, click to expand. –
#47350
Dec 23, 2009 at 7:21pm

here’s one way among many to do this with jitter:

– Pasted Max Patch, click to expand. –
#170413
Mar 8, 2010 at 8:42pm

Sorry i haven’t responded to any of this yet. Your patch is very helpful. To take this further what I’d like to do is be able to send out a series bangs or something to grab the RGB values along the x/y axis. One thought I have had is to use UZI to bang across the x axis and then drop a line then do it again until the entire image has been analyzed that way. My problem is that I do not see what I can use to do that with. Is there an object or something that will allow me to control it as per coordinates using UZI or something like it? I am thinking of a pointer or something of that sort. I know this is kind of vague but I am struggling with this as I do not know Jitter very well at all (I know you’re very surprised =) )

#170414
Mar 9, 2010 at 9:04pm

If I may also add to this the Tutorial 11 seems to look like what I am after, though I am not so sure. I’d like to be able to extract the RGB into a table just like this so I can export that and then analyze it in another program. I am just not sure how to get the individual data from each pixel (e.g. 320 x 2490) image into the table.

#170415
Mar 9, 2010 at 9:26pm

not sure if im misunderstanding here, but jit.cellblock is a table you can store planes of an image in, have you looked at that?

#170416
Mar 9, 2010 at 9:57pm

Yes, that is what I am talking about. I’d like to be able to get the data from the image (in this a .jpg or similar file) and into jit.cellblock. My problem is I cannot do this with very much accuracy using my mouse to click on the image (in a 320 x 240 image that comes to 76,800 clicks!). What I’d like to do is automate it so that I can get the data from each pixel in a left to right motion and then when I reach the end of the image drop down a line and then do the same.

#170417
Mar 9, 2010 at 10:02pm

Maybe this is just to unwieldy. I don’t know. I am trying to do some color analysis on the image. maybe there is a better way to do this.

#170418
Mar 9, 2010 at 10:27pm

jit.iter?

otherwise simple getcell message to jit.matrix.

#170419
Mar 9, 2010 at 10:35pm

“Yes, that is what I am talking about. I’d like to be able to get the data from the image (in this a .jpg or similar file) and into jit.cellblock.”

simply just put a jitter matrix going into jit.cellblock then… you’ll have all the data for each pixel there in a table.. as shown in this example below. this is only showing a 10×10 matrix (change the argument of jit.matrix to change the size) for ease of explanation, use importmovie to load an image into the jit.matrix. beware it will be greyscale (1 plane). if you want to do processing on R G and B values, then pass only that colour channel from an original 4 plane jitter matrix and then do this. you can just jit.op @pass to pass a specific channel of a matrix i think.

– Pasted Max Patch, click to expand. –

a jit.cellblock can also be linked to a coll, which you may find of use

#170420
Mar 10, 2010 at 4:30pm

Thanks the_man361! That looks like what I need to do.

I need to do some study again about planes and matrices again so i can know what is going on and how to get the RGB values in there =)

A question though, what does each of the numbers in the jit.cellblock represent? Is there a table they correspond to?

#170421
Mar 10, 2010 at 6:11pm

Rob,

Your idea of jit.iter is also helpful. That seems to really get at it. I need to figure it all out now. As I play with it I am not sure why certain actions don’t work and kinds of data are being output, etc. Thanks. I may be chekcing back in.

#170422
Mar 10, 2010 at 11:34pm

no worries. each number in the jit.cellblock represents the value of the corresponding pixel.

since i converted RGB to luminescence (greyscale) in that patch i sent (one plane, brightness) the jit.cellblock shows brightness of each pixel. if you load an image with some bright and some dark in it to that cellblock you should see it… 255 is totally white, 0 is black.

if you want to do the same thing for R,G and B, then pass only that channel as one plane in jitter and do the same thing there (eg 255 will be totally red, 0 will be black).

this may not be of so much learning use, and im sure its a terrible way to patch (i didnt spend any time thinking about what i wanted to do or managing my patch in any way at all) but here is a patch that scans an image, looking for the average brightness value in an 8×8 window in R, G, B and brightness and sonifies the result very basically using 4 sawtooth oscillators (its not meant to sound nice).

this patch is badly made and everything, but it might give you an idea in this kind of area. you’ll need to save it an re-open it when youve downloaded it so that the loadbangs work. then pop it into presentation mode and load an image using ‘loadmovie’ then hit go and admire the horror. its very much work in progress, and doesnt do anything like what i originally thought would be cool to bash out one evening

– Pasted Max Patch, click to expand. –
#170423

You must be logged in to reply to this topic.