我需要在一个图像中随机重排像素位置,但像素的值不会改变。能给我一些想法,我将如何解决这个问题?
答案 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