2D baker map code implementation

I am trying to implement the discretized baker map for the shuffling of pixels,i am not able to understand the discretized version of it clearly.and neither am i able to implement it properly on matlab it always show index out of bounds error. here is the link http://link.springer.com/chapter/10.1007/978-3-540-95972-4_16 please can somebody help. I am a beginner and this is my effort at it i know it is pathetic but still.
for i=1:row
for j=1:col
if(1<=j<row/2)
newcord1=((2*(j-1))+mod(i-1,2));
newcord2=(floor(0.5*(i-mod(i-1,2))+1));
im(i,j)=im(newcord2,newcord1);
elseif(row/2 <=j <=row)
newcord1=((2*(j-64))+mod(i,2));
newcord2=floor(0.5*(i-mod(i,2))+63);
im(i,j)=im(newcord2,newcord1);
end
end
end

5 件のコメント

Syahirah Rahim
Syahirah Rahim 2019 年 3 月 12 日
Hi. I also a beginner and new to MATLAB. I am trying to code on discretized baker map but I did not really understand.
Could you please tell me how this line works?
newcord1=((2*(j-1))+mod(i-1,2));
newcord2=(floor(0.5*(i-mod(i-1,2))+1));
and also
newcord1=((2*(j-64))+mod(i,2));
newcord2=floor(0.5*(i-mod(i,2))+63);
How can i divide the square size image to few verticle rectangle and implement above code?
su su maung
su su maung 2020 年 9 月 25 日
Here is the matlab code for 2D baker map.
#################### Baker Map for 6x6 pixels ###########
A=[1:1:6;7:1:12;13:1:18;19:1:24;25:1:30;31:1:36];
tic;
N0=0;
N1=3;
N2=4;
n1=3;
n2=1;
n3=2;
for i=1:1% 9 times
for r=0:2
for s=0:5
X(r+1,s+1)=A(floor((6/n1)*(r-N0)+mod(s,(6/n1)))+1,floor((n1/6)*(s-mod(s,(6/n1)))+N0)+1);
end
end
for r=3:3
for s=0:5
X(r+1,s+1)=A(floor((6/n2)*(r-N1)+mod(s,(6/n2)))+1,floor((n2/6)*(s-mod(s,(6/n2)))+N1)+1);
end
end
for r=4:5
for s=0:5
X(r+1,s+1)=A(floor((6/n3)*(r-N2)+mod(s,(6/n3)))+1,floor((n3/6)*(s-mod(s,(6/n3)))+N2)+1);
end
end
%A=X;
end
toc
Parveiz Lone
Parveiz Lone 2021 年 3 月 28 日
what about inverse
Zeina Abdullah
Zeina Abdullah 2022 年 2 月 21 日
Hi , please can you help me i need a chaotic interleaver code using baker map . please tell any thing can help me in my problem . @Parveiz Lone @su su maung @Syahirah Rahim @myetceteramail myetceteramail @Walter Roberson
Zeina Abdullah
Zeina Abdullah 2022 年 2 月 22 日
@su su maung if the input 8*8 how dose the code will be change

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 1 月 12 日

1 投票

if(1<=j<row/2)
means
if ((1<=j)<row/2)
The first part, 1<=j, returns false (0) or true (1). That 0 or 1 is then compared to row/2.
You probably want
if 1<=j && j<row/2

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by