how to swap bit plane???

2 次查看(过去 30 天)
it is bitplane decomposition code..i want to swap them.. how to do it???
g=imread('girl.png');
g=rgb2gray(I_scramble);
g1=bitget(g,1);
g2=bitget(g,2);
g3=bitget(g,3);
g4=bitget(g,4);
g5=bitget(g,5);
g6=bitget(g,6);
g7=bitget(g,7);
g8=bitget(g,8);
figure,imshow(g);
title('original image');
subplot(4,4,1),imshow(logical(g1)),title('Bit 1');
subplot(4,4,2),imshow(logical(g2)),title('Bit 2');
subplot(4,4,3),imshow(logical(g3)),title('Bit 3');
subplot(4,4,4),imshow(logical(g4)),title('Bit 4');
subplot(4,4,5),imshow(logical(g5)),title('Bit 5');
subplot(4,4,6),imshow(logical(g6)),title('Bit 6');
subplot(4,4,7),imshow(logical(g7)),title('Bit 7');
subplot(4,4,8),imshow(logical(g8)),title('Bit 8');
%L=imread('monarch.png');
L=rgb2gray(I1_scramble);
L1=bitget(L,1);
L2=bitget(L,2);
L3=bitget(L,3);
L4=bitget(L,4);
L5=bitget(L,5);
L6=bitget(L,6);
L7=bitget(L,7);
L8=bitget(L,8);
figure,imshow(L);
title('original image');
subplot(4,4,1),imshow(logical(L1)),title('Bit 1');
subplot(4,4,2),imshow(logical(L2)),title('Bit 2');
subplot(4,4,3),imshow(logical(L3)),title('Bit 3');
subplot(4,4,4),imshow(logical(L4)),title('Bit 4');
subplot(4,4,5),imshow(logical(L5)),title('Bit 5');
subplot(4,4,6),imshow(logical(L6)),title('Bit 6');
subplot(4,4,7),imshow(logical(L7)),title('Bit 7');
subplot(4,4,8),imshow(logical(L8)),title('Bit 8');
how to swap this ???

采纳的回答

Walter Roberson
Walter Roberson 2018-10-25
gall = cat(3, g1, g2, g3, g4, g5, g6, g7, g8);
gall_scramble = gall(:, :, randperm(8));
gscramble = zeros(size(g));
for p = 1 : 8
gscramble = bitset(gscramble, p, gall_scramble(:,:,p));
end
  4 个评论
Image Analyst
Image Analyst 2018-10-26
Why? Just for curiosity to see what it looks like? Or do you have an actual real-world "use case"?
Walter Roberson
Walter Roberson 2018-10-26
I rather suspect that "image encryption" will form part of the answer.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Historical Contests 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by