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)

6 views (last 30 days)
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,[])
  1 Comment
ANURAG
ANURAG on 6 May 2024
clc
clear all
format short
%To solve the LPP by Simplex Method
%Min z=x1-3x2+2x3
%Subject to 3x1-x2+2x3<=7
%-2x1+4x2<=12
%-4x1+3x2+8x3<=10
%x1,x2,x3>=0
%First to change the objective function from minimization to maximization
%Max z=-x1+3x2-2x3
%To input parameters
C=[-1 3 -2]
info=[3 -1 2;-2 4 0; -4 3 8]
b=[7; 12; 10]
NOVariables=size(info,2)
s=eye(size(info,1))
A=[info s b]
Cost=zeros(1,size(A,2))
Cost(1:NOVariables)=C
BV=NOVariables+1:size(A,2)-1
%To calculate Z-Row(Zj-Cj)
ZRow=Cost(BV)*A-Cost
%To print the table
ZjCj=[ZRow; A]
SimpTable=array2table(ZjCj)
SimpTable.Properties.VariableNames(1:size(ZjCj,2))={'x_1','x_2','x_3','s_1','s_2','s_3','Sol'}
%Simplex Table Starts
Run=true;
while Run
if any(ZRow<0) %To check any negative value is there
fprintf('The current BFS is not optimal \n')
fprintf('\n=========The next iteration continues========\n')
disp('Old Basic Variable (BV)=')
disp(BV)
% To find entering Variable
ZC=ZRow(1:end-1)
[EnterCol, Pvt_Col]=min(ZC)
fprintf('The most negative element in Z-Row is %d Corresponding to Column %d \n', EnterCol, Pvt_Col)
fprintf('Entering Variable is %d \n', Pvt_Col)
%To find the leaving variable
sol=A(:,end)
Column=A(:,Pvt_Col)
if all(Column<=0)
error('LPP has unbounded solution. All entries <= 0 in column %d', Pvt_Col)
else
% To check minimum ratio is with positive entering column entries
for i=1:size(Column,1)
if Column(i)>0
ratio(i)=sol(i)./Column(i)
else
ratio(i)=inf
end
end
%To finding minimum ratio
[MinRatio, Pvt_Row]=min(ratio)
fprintf('Minimum ratio corresponding to pivot row is %d \n', Pvt_Row)
fprintf('Leaving Variable is %d \n', BV(Pvt_Row))
end
BV(Pvt_Row)=Pvt_Col
disp('New Basic Variables (BV) =')
disp(BV)
%Pivot Key
Pvt_Key=A(Pvt_Row,Pvt_Col)
%Update Table for next iteration
A(Pvt_Row,:)=A(Pvt_Row,:)./Pvt_Key
for i=1:size(A,1)
if i~=Pvt_Row
A(i,:)=A(i,:)-A(i,Pvt_Col).*A(Pvt_Row,:)
end
ZRow=ZRow-ZRow(Pvt_Col).*A(Pvt_Row,:)
%To print the updated table
ZjCj=[ZRow;A]
SimpTable=array2table(ZjCj)
SimpTable.Properties.VariableNames(1:size(ZjCj,2))={'x_1','x_2','x_3','s_1','s_2','s_3','Sol'}
BFS=zeros(1,size(A,2))
BFS(BV)=A(:,end)
BFS(end)=sum(BFS.*Cost)
CurrentBFS=array2table(BFS)
CurrentBFS.Properties.VariableNames(1:size(CurrentBFS,2))={'x_1','x_2','x_3','s_1','s_2','s_3','Sol'}
end
else
Run=false
fprintf('The current BFS is optimal and Optimality is reached \n')
end
end

Sign in to comment.

Accepted Answer

Geoff Hayes
Geoff Hayes on 3 Feb 2017
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 Comments
Renjith V Ravi
Renjith V Ravi on 4 Feb 2017
Edited: Renjith V Ravi on 5 Feb 2017
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)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!