필터 지우기
필터 지우기

Pixel Shuffling using Chaotic Tinkerbell map(https:​//en.wikip​edia.org/w​iki/Tinker​bell_map) and Henon Map(https:​//en.wikip​edia.org/w​iki/H%C3%A​9non_map)

조회 수: 13 (최근 30일)
I have tried to do double shuffling of pixels in an image using Tinkerbell mal and Henon Map.The code is shown below. It is showing an error "Index exceeds matrix dimensions".Please help me in this regard
clear all
close all
clc
in_img=double(imread('cameraman.tif'));
in_img=double(in_img)/255;
subplot(221)
imshow(in_img)
x=in_img;
[m,n]=size(in_img);
%Shuffling using Tinkerbel Map
% a=0.9,b=-0.6013,c=2.0,d=0.50;
a=0.3;b=0.6000;c=2.0;d=0.27;
for i=1:m
for j=1:n
%Shuffling using Tinkerbel Map
r = [round(abs((i^2)-(j^2)+(a*i)+(b*j))),round(abs((2*i*j)+(c*i)+(d*j)))]
ggg(i,j)=in_img(r(1)+1,r(2)+1);
end
end
Tinkerbel_Shuffled=ggg;
subplot(222)
imshow(Tinkerbel_Shuffled,[])
%Shuffling using Henon map Map
[m,n]=size(in_img);
a = 1.4;b=0.3;
for i=1:m
for j=1:n
%Shuffling using Henon map Map
r = [round(abs(1-(a*(i^2))+j)),round(abs(b*i))];
ggg(i,j)=Tinkerbel_Shuffled(r(1)+1,r(2)+1);
end
end
subplot(223)
imshow(Double_Shuffled,[])

채택된 답변

Geoff Hayes
Geoff Hayes 2017년 2월 3일
Renjith - the problem is with the r
r = [round(abs((i^2)-(j^2)+(a*i)+(b*j))),round(abs((2*i*j)+(c*i)+(d*j)))]
There is no guarantee that the either component of this array will be valid indices into the image
ggg(i,j)=in_img(r(1)+1,r(2)+1);
What you can do is to find the modulus m and n for the first and second component of r respectively.
r = mod([round(abs((i^2)-(j^2)+(a*i)+(b*j))),round(abs((2*i*j)+(c*i)+(d*j)))], [m,n]);
The same would need to be done for the Henon Mapping
r = mod([round(abs(1-(a*(i^2))+j)),round(abs(b*i))],[m n]);
Though I don't know how this will impact the encryption...
Try the above and see what happens!
  댓글 수: 2
Renjith V Ravi
Renjith V Ravi 2017년 2월 4일
편집: Renjith V Ravi 2017년 2월 5일
Yes, I have tried it and obtained the output.But now the problem is with inverse operation.THe inverse process is not occurring properly.
clear all
clc
g=imread('cameraman.tif');
% g=double(g)/255;
subplot(231)
imshow(g)
original=g;
[m,n]=size(g);
mo=m;
num = 12;
K=10.^10;
% K=19;
%....................Shuffling.......................
disp('........................Started Shuffling.....................')
%Tinkerbell shuffling
a=0.3;b=0.6000;c=2.0;d=0.27;
for k= 1:num
for i=1:m
for j=1:n
r = mod([round(abs((i^2)-(j^2)+(a*i)+(b*j))),round(abs((2*i*j)+(c*i)+(d*j)))], [m,n]);
% r = mod([(i+j),(j+K*sin(((i+1)*n)/2*pi))],mo);
% r = [((i-1)+(K*sin(j-1))),((j-1)+i)];
% r = uint8(r);
ggg(i,j)=g(r(1)+1,r(2)+1);
% ggg(i,j)=g(r(1),r(2));
end
end
g=ggg;
end
subplot(232)
x=ggg;
imshow(ggg,[]);
title('Tinkerbell shuffled')
%henon Shuffling
[m,n]=size(x);
a = 1.4;b=0.3;
% num_iter=input('Enter the round for Arnold shuffling');
num_iter = 5;
% a=1.4;
% b=0.3;
for k=1:num_iter
for i=1:m
for j=1:m
r = mod([round(abs(1-(a*(i^2))+j)),round(abs(b*i))],[m n]);
xxx(i,j)=x(r(1)+1,r(2)+1);
end
end
x=xxx;
end
subplot(233)
imshow(xxx);
title('henon Shuffled Image')
save xxx x
disp('........................Shuffling process completed succesfully.....................')
%...................Inverse Shufling.............................
disp('........................Started Inverse Shuffling.....................')
%Henon Inverse Shuffling
for k=1:num_iter
for i=1:m
for j=1:n
r = mod([round(abs(1-(a*(i^2))+j)),round(abs(b*i))],[m n]);
x1(r(1)+1,r(2)+1)=xxx(i,j);
end
end
xxx=x1;
end
subplot(234)
imshow(x1);
title('henon Inverse Shuffled')
%Tinkerbell inverse shuffling
a=0.3;b=0.6000;c=2.0;d=0.27;
for k=1:num
for i=1:m
for j=1:n
r = mod([round(abs((i^2)-(j^2)+(a*i)+(b*j))),round(abs((2*i*j)+(c*i)+(d*j)))], [m,n]);
g1(r(1)+1,r(2)+1)=x1(i,j);
end
end
xxx=g1;
end
subplot(224)
imshow(g1)
title('Tinkerbell_inverse_shuffled')
disp('........................Inverse Shuffling process completed succesfully.....................')
psnr = psnr(g1,original)
ssim=ssim(g1,original)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Labeling, Segmentation, and Detection에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by