Randomise pixels in image

This quick snippet will move pixels to (semi) random locations in each image in a stack. The output is saved as a new 3D wave called outWave. I wrote this for an analysis routine where I needed to assess correlation in a masked region of two images. The randomised version allows me to see what correlation we would expect by chance.

Function RandomiseImage(inWave)
    Wave inWave
    Duplicate/O inWave, outWave
    Variable xx = dimsize(inWave,0)
    Variable yy = dimsize(inWave,1)
    Variable zz = dimsize(inWave,2)
    Variable i
    for(i = 0; i < zz; i += 1)
        MatrixOp/O/FREE tempLayer = layer(inWave,i)
        Redimension/N=(xx*yy) tempLayer
        StatsSample/N=(xx*yy) tempLayer
        WAVE/Z W_Sampled
        Redimension/N=(xx,yy) W_Sampled
        outWave[][][i] = W_Sampled[p][q]




Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More