Pixel Shuffling using Chaotic Tinkerbell map(https://en.wikipedia.org/wiki/Tinkerbell_map) and Henon Map(https://en.wikipedia.org/wiki/H%C3%A9non_map)
6 次查看(过去 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,[])
1 个评论
ANURAG
2024-5-6
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
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Labeling, Segmentation, and Detection 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!