![](/profiles/wavemetrics/themes/wavemetrics/logo.png)
Randomise pixels in image
![](/sites/default/files/styles/thumbnail/public/sjr51/profile-images/2018-07/cube.png?itok=iXDZATA2)
sjr51
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]
endfor
End
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]
endfor
End
![](/sites/default/files/forum.png)
Forum
![](/sites/default/files/support.png)
Support
![](/sites/default/files/gallery.png)
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More