Scrambled picture : is noise from a given matrix possible ?

Nicolas Lelievre's icon

Hi there,
I'm having some trouble achieving something apparently simple. I want to randomly distribute all the pixels in each row of a given matrix and get a « noisy » version of an image or video. To put it in simple words : is it possible to make something similar to noise but with a given number of predetermined cell values ? Like a puzzle-matrix in which each cell is a movable piece ? (The « only rows » option is just to give the result some consistancy compared to the original)
To be more explicit, here's a patch showing the two roads I've tried to go so far. Both are very straight forward but none is satisfying. Route one works well but takes loooots of time analysing the incoming matrix pixel by pixel. So definitely not realtime instant result…
Route two uses jit.iter and works fine with a simple tiny 1 char matrix but it's another story when it comes to image-size data…

I feel like I'm using my computer like a 19th century steam engine with these examples. There must be some more clever solution out there.

One last thing : I checked the jit.sprinkle object and its gl.pix equivalent. They give interesting results but somehow, I can't tweak them to get something looking as random as I want.
Any hint ?

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

Thanks !

Wetterberg's icon

jit.repos. Orig. matrix in the left inlet, and a [jit.noise 2 char your-x-size your-y-size] in the right.

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

hey
you'd rather use jit.repos :

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

this is simple wiht noise, but all the original cells won't necessarly be used. I tried to make a cell map that ensures all the original cells are re used, but it doesn't really work...

vichug's icon

hah wetterberg, ninja'd :))

Wetterberg's icon

hehe, well you did the good work with patches and all, so you're still ahead :)

Nicolas Lelievre's icon

Ooops… Jit.repos… I guess i should have rtfm better… I've used this object only for simple translation so far.
Thanks to both of you anyway, and for your information, the trick works even better using the td.repos.jxs shader.
Cheers !

vichug's icon

(hey, could you tell us if you achieved like scrambling the position of all pixel, without losing one ? and how, if it was with jit.repos ? i'm curious !)

Nicolas Lelievre's icon

Well the repos shader works perfectly fine for my ongoing little project. At least visually because I doubt the output contains the exact same pixels as the input. As I'm curious too, I tried this repos method with very small matrices so I can see, count and compare pixels before and after. The output seems to be more like an interpretation than a new combination of the same data.

It's visually satisfying on large matrices like regular video footage. I guess the large amount of pixels gives a good enough average noisy recombination but it feels a little bit like a telepod in Cronenberg's "The Fly" : the output looks the same but you don't know how it's been reinterpreted…

tom w's icon

Apologies for cross-posting, but I've been faced with a similar issue of trying to scramble cells in a matrix whilst preserving every individual cell value, and on another thread I was pointed in the right direction - I've also posted a small patch which does the job on matrices up to 256x256 in dimension. Hope this might be useful to somebody searching in the future.

Cheers

Tom