Image 如何对图像中的特定元素进行置乱?

Image 如何对图像中的特定元素进行置乱?,image,matlab,scramble,Image,Matlab,Scramble,虽然我能够成功地对图像进行置乱(使用JigSaw或RANDBLOCK),但我不知道如何对每个图像中的特定矩阵元素(块)进行置乱。我无法附加图像,所以我需要的正是以图像形式显示的(只需点击“置乱”)。正如您将看到的,第一个图像被划分为8 x 7矩阵,然后对特定元素进行置乱以生成第二个图像,即 [1,1;1,2;1,3;1,4;1,5;2,1;2,2;2,3;2,4;2,5;3,1;3,2;3,3;3,4;3,5;4,2;4,3;4,4;5,2;5,3;5,4;6,2;6,3;6,4] 我非常感

虽然我能够成功地对图像进行置乱(使用
JigSaw
RANDBLOCK
),但我不知道如何对每个图像中的特定矩阵元素(块)进行置乱。我无法附加图像,所以我需要的正是以图像形式显示的(只需点击“置乱”)。正如您将看到的,第一个图像被划分为
8 x 7
矩阵,然后对特定元素进行置乱以生成第二个图像,即

[1,1;1,2;1,3;1,4;1,5;2,1;2,2;2,3;2,4;2,5;3,1;3,2;3,3;3,4;3,5;4,2;4,3;4,4;5,2;5,3;5,4;6,2;6,3;6,4] 
我非常感谢任何建议,因为我是MATLAB的新手,需要尽快完成刺激

多谢各位


玛丽亚

我更喜欢丽娜,我们开始吧-

%// Indices of specific blocks to be randomized
sp_idx = [2,2;2,3;2,4;2,5;2,6;3,2;3,3;3,4;3,5;3,6;4,2;4,3;4,4;4,5;4,6;
          5,3;5,4;5,5;6,3;6,4;6,5;7,3;7,4;7,5];

%// Invite lena to MATLAB workspace and *cut off her right arm*
im = imread('http://www.ece.rice.edu/~wakin/images/lenaTest3.jpg');
im = im(:,1:448);

%// Define blocksize (rows x columns)
n = 64;
m = 64;

%// New random indices corresponding to sp_idx
new_rand_idx = sp_idx(randperm(size(sp_idx,1)),:);

%// Split image into blocks
split_blks = mat2cell(im, ones(1,8)*n, ones(1,7)*m);

%// Get old and new linear indices and thus randomize specific blocks
old_lind = sub2ind(size(split_blks),sp_idx(:,1),sp_idx(:,2));
new_lind = sub2ind(size(split_blks),new_rand_idx(:,1),new_rand_idx(:,2));
split_blks(new_lind) = split_blks(old_lind);
new_im = cell2mat(split_blks);

%// Show images
figure,
subplot(121),imshow(im),title('Before')
subplot(122),imshow(new_im),title('After')
输出-


我更喜欢
Lena
,我们开始吧-

%// Indices of specific blocks to be randomized
sp_idx = [2,2;2,3;2,4;2,5;2,6;3,2;3,3;3,4;3,5;3,6;4,2;4,3;4,4;4,5;4,6;
          5,3;5,4;5,5;6,3;6,4;6,5;7,3;7,4;7,5];

%// Invite lena to MATLAB workspace and *cut off her right arm*
im = imread('http://www.ece.rice.edu/~wakin/images/lenaTest3.jpg');
im = im(:,1:448);

%// Define blocksize (rows x columns)
n = 64;
m = 64;

%// New random indices corresponding to sp_idx
new_rand_idx = sp_idx(randperm(size(sp_idx,1)),:);

%// Split image into blocks
split_blks = mat2cell(im, ones(1,8)*n, ones(1,7)*m);

%// Get old and new linear indices and thus randomize specific blocks
old_lind = sub2ind(size(split_blks),sp_idx(:,1),sp_idx(:,2));
new_lind = sub2ind(size(split_blks),new_rand_idx(:,1),new_rand_idx(:,2));
split_blks(new_lind) = split_blks(old_lind);
new_im = cell2mat(split_blks);

%// Show images
figure,
subplot(121),imshow(im),title('Before')
subplot(122),imshow(new_im),title('After')
输出-


你应该展示一些关于这个主题的基础研究。看看如何在矩阵中为块建立索引,你应该准备好了。你应该展示一些关于这个主题的基础研究。查一下如何在矩阵中索引块,你应该可以很好地去做了。@LuisMendo用了我的魔杖;)虽然切断右臂是我今天做出的最艰难的决定:)@Benoit_11认为我们需要一些MATLAB内部笑话;)@谈到莉娜时,迪瓦卡小心翼翼地用词。。。。在《花花公子》杂志头版的照片中使用“魔杖”。。。。可能是。。。。误解:P@AnderBiguri我们不是IP人吗。。。“拥有”她胜过花花公子产业@路易斯门多用了我的魔杖;)虽然切断右臂是我今天做出的最艰难的决定:)@Benoit_11认为我们需要一些MATLAB内部笑话;)@谈到莉娜时,迪瓦卡小心翼翼地用词。。。。在《花花公子》杂志头版的照片中使用“魔杖”。。。。可能是。。。。误解:P@AnderBiguri我们不是IP人吗。。。“拥有”她胜过花花公子产业