blurring a float matrix?

Wetterberg's icon

okay, so I may be losing my marbles completely here, but... how on earth do you blur a float32 matrix?

jit.fastblur is char only, and the closest thing I've found is jit.avg4, which isn't really it either.

My matrix is "mymatrixname 3 float32 100 100", so it's rather small, and I can afford to throw some processing at it, but I *cant* do shaders, since I need this in matrix-land still.

any pointers? I reckon there might be a simple jit.pix hack I could do? I don't mind quirky blurs, either.

Christopher Dobrian's icon
Max Patch
Copy patch and select New From Clipboard in Max.

One way is simply to downsample and then re-upsample with interpolation, but the more sophisticated way is convolution with jit.convolve, I think.

Wetterberg's icon

thanks. I love how jit.convolve's help file AND reference assume that the jitter users know what convolving two matrices with each other entails. ;)

I'll be using this, but damn, it ain't pretty.

ćwiek's icon

jit.gl.slab.gauss6x works pretty well also with float32 matrices, and it's great! :)

t's icon

i would use jit.gl.slab.gauss6x, and then go back from openGL to CPU...

Wetterberg's icon

slab processing for a small matrix which is just a tiny bit of a larger whole? Am I completely nuts for thinking that that is too convoluted? (pardon the pun)

t's icon

well it depends what kind of blurring you're after

Wetterberg's icon

well, I reckon what I'd really like is something like jit.gl.slab.gauss6x, but in matrix-land.

Do any of you have this wrapped up in an abstraction that handles the back-and-forth from- and to- matrices internally?

t's icon

it's not an abstraction but i hope it will help you anyway...

Max Patch
Copy patch and select New From Clipboard in Max.

PS: the rendering context is made with jit.window, which is a bit annoying - there is a "useless" window floating. for some unknown reasons, my Max crashes if i make the rendering context with jit.matrix...? anyway, all you have to do is to adjust the dimensions...

ćwiek's icon
Max Patch
Copy patch and select New From Clipboard in Max.

?

t's icon

@napentro: Thanks, that is even sexyer solution! I removed also the videoplane and changed the "jit.pwindow @name maax" with "jit.matrix maax", to remove the unnecessary processing.

Max Patch
Copy patch and select New From Clipboard in Max.

PS: Creating rendering context with jit.matrix seems to work for smaller matrices. I remember I had problems with larger ones...my Max always crashed. And even few moments ago that happened with 320x240 matrix. I don't know what is the reason for that dodgy behavior...

t's icon

I played a little bit more with the patch and it seems that if creating rendering context with matrix, patch works slow and dodgy. Can anyone explain that?

ćwiek's icon

i think, that videoplane is nessesary. there is jitter tutorial 31RenderDestinations, that allows you to change the destination of opengl objects, but in my case when trying render to matrix pops up "jit.gl: invalid extension called" - maybe it is some kind of bug.

anyway i think, that videoplane is nessesary to send the context of renderer anywhere.

Max Patch
Copy patch and select New From Clipboard in Max.

it is a modyfied version of the tutorial with "jit.gl: invalid extension called" error:

Max Patch
Copy patch and select New From Clipboard in Max.

if it would work the patch with rendering gl.slab to matrix should looks like that:

or maybe i'am missing something @:)
after all sorry for my english :)

t's icon

i don't get any errors in your first patch. also the last patch i posted (without videoplane) works. but as i said, it is dodgy. now, for instance, when i tested it again, it first didn't work, then my Max crashed, but after i restarted it, it started to work.

i would expect that when i make the rendering context with matrix instead of window or pwindow, that the patch would run faster, since there is nothing (necessary) to display. but as i said, things start to crash, behave dodgy, works slow...???