图像中像素的随机排列

时间:2015-03-09 08:51:46

标签: matlab image-processing

我需要在一个图像中随机重排像素位置,但像素的值不会改变。能给我一些想法,我将如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

使用randperm

img = imread( ... ); % read image
rimg = reshape( img, [], size(img,3) ); % arrange as 1D image with x-channels
n = size(rimg,1); % how many pixels you have
simg = rimg( randperm(n), : ); % shuffle pixels
simg = reshape( simg, size(img) ); % reshape back