Arnolds cat map like scrambling

Hello to everybody!
Does anyone know how can you use any dynamical system to scramble an image just like you would do with arnolds cat map?
For example how would you do it for the standard map:

2 comentarios

Image Analyst
Image Analyst el 31 de Oct. de 2021
I've posted my Arnolds cat map here before, which you've probably found. For your formula, I'm not sure what p, K, and theta represent. Do you have an image with 2-dimensions? Your formulas here seem to refer to 1-D signals.
george korris
george korris el 31 de Oct. de 2021
Hello and thanks for the response!
The standard map is an area-preserving chaotic map from a square with side 2*pi onto itself. It is constructed by a Poincaré's surface of section of the kicked rotator, and is defined by the formulas i posted in the original question. where θ and p are taken modulo 2*pi . Some basic pictures of the phase diagram can be found
I hope i answered your question. I have seen your beautiful code but when i tried to alter the lines that changed the equation i got errors.

Iniciar sesión para comentar.

 Respuesta aceptada

Image Analyst
Image Analyst el 6 de Nov. de 2021
Editada: Image Analyst el 6 de Nov. de 2021
George, I've tried to use your sin() formula to apply it to an image and this is what I get. I have no idea what K should be though. For every pixel in the input image, I compute p as the radius from the center of the image, and theta as the angle. Then I put them into your formula to get the next p and theta, and I send the input pixel to that location in the output image.
% Demo by Image Analyst.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clearvars;
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 16;
numberOfIterations = 1200;
K = 1.3;
p = ones(numberOfIterations, 1);
theta = zeros(numberOfIterations, 1);
plotColors = jet(numberOfIterations);
originalImage = imread('peppers.png');
outputImage = zeros(size(originalImage), 'uint8');
[rows, columns, numberOfColorchannels] = size(originalImage)
for col = 1 : columns
fprintf('Column %d of %d.\n', col, columns)
for row = 1 : rows
% Find initial p and theta for this pixel.
p1 = sqrt((row-rows/2).^2 + (col-columns/2).^2);
theta1 = atan((row-rows/2)/(col-columns/2));
% Find next p and theta for this pixel.
% Where are we going to send this pixel to?
% Compute new p according to the formula.
p2 = p1 + K * sin(theta1);
% Compute new theta according to the formula.
theta2 = theta1 + p1;
% Make them mod 2 * pi
p2 = mod(p2, 2*pi);
theta2 = mod(theta2, 2*pi);
% Convert from polar to cartesian coordinates.
row2 = round(p2 * sin(theta2) + rows/2);
col2 = round(p2 * cos(theta2) + columns/2);
if isnan(row2) || isnan(col2)
continue;
end
% Skip it if it's outside the image.
if row2 <= 1 || row2 > rows || col2 <= 1 || col2 > columns
continue
end
outputImage(row2, col2, :) = originalImage(row, col, :);
end
end
% Display output image
imshow(outputImage)
title('Complete Chaos!', 'FontSize', fontSize);
axis('on', 'image');
impixelinfo

3 comentarios

george korris
george korris el 8 de Nov. de 2021
Hi @Image Analyst Is this what you get when you run the code?
Thank you so much for your time!
Image Analyst
Image Analyst el 8 de Nov. de 2021
Yes. I just used the formula. Not sure what you're using for K. It looks like you'll need to adapt the code if you want to have the output image be larger. Probably need a scaling factor in there somewhere, but I didn't have time and I figured you could research that since it's your problem.
george korris
george korris el 8 de Nov. de 2021
Yes of course!
Thank you @Image Analyst!

Iniciar sesión para comentar.

Más respuestas (4)

Image Analyst
Image Analyst el 31 de Oct. de 2021

1 voto

@george korris I don't really know since chaos is not my field. I know that some of the mini-hack image entries are using chaos so you might check out the code there:
yanqi liu
yanqi liu el 1 de Nov. de 2021
Editada: yanqi liu el 9 de Nov. de 2021
sir,may be use some logistics or chaos to generate some location change

5 comentarios

Image Analyst
Image Analyst el 1 de Nov. de 2021
Does this use the formula he gave? Where is the call to sin()?
george korris
george korris el 1 de Nov. de 2021
Hi yanqi liu and thank you for your response!
Isn't your code about the normal arnolds cat map? or am I missing something?
If it is not arnolds cat map could you please help me a bit in what it does?
yanqi liu
yanqi liu el 1 de Nov. de 2021
sir,yes,it is a normal arnolds process,use in watermark application
Image Analyst
Image Analyst el 1 de Nov. de 2021
OK, but do you have anything that does the chaos thing with the sin() function like he asked in the original post?
george korris
george korris el 3 de Nov. de 2021
@yanqi liu thank you for your answer firstly when i run your code i get this error
Unrecognized function or variable 'num'.
Error in Untitled (line 9)
for i=1 : num+1e3
and secondly what does your code do?
i cant read the comments

Iniciar sesión para comentar.

Image Analyst
Image Analyst el 2 de Nov. de 2021
George, try this:
% Demo by Image Analyst.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clearvars;
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 16;
numberOfIterations = 1200;
K = 1.3;
p = ones(numberOfIterations, 1);
theta = zeros(numberOfIterations, 1);
plotColors = jet(numberOfIterations);
for n = 1 : numberOfIterations-1
% Compute new p according to the formula.
p(n+1) = p(n) + K * sin(theta(n));
% Compute new theta according to the formula.
theta(n+1) = theta(n) + p(n+1);
% Make them mod 2 * pi
p(n+1) = mod(p(n+1), 2*pi);
theta(n+1) = mod(theta(n+1), 2*pi);
% Plot it
plot([p(n), p(n+1)], [theta(n), theta(n+1)], '-', 'Color',plotColors(n, :));
hold on;
end
% Plot it.
% plot(theta, p, 'b-');
grid on;
title('Complete Chaos!', 'FontSize', fontSize);
ylabel('p', 'FontSize', fontSize);
xlabel('theta', 'FontSize', fontSize);
xticks(0 : pi/4 : 2*pi)
xlim([0, 2*pi])
ylim([0, 2*pi])

5 comentarios

yanqi liu
yanqi liu el 2 de Nov. de 2021
sir, its great, but may be make an inverse transfer
Image Analyst
Image Analyst el 2 de Nov. de 2021
@yanqi liu, I don't know what that means. I'm not an expert in chaos. I merely implemented the formula @george korris gave. I'm not even sure I did it correctly and don't know what an "inverse transfer" is or means in this situation.
george korris
george korris el 3 de Nov. de 2021
@Image Analyst thank you for your time! Your code is great but is there a way to use those pi and theta in an image and scramble it just like you would do with the arnolds cat map?
Image Analyst
Image Analyst el 3 de Nov. de 2021
@george korris do you mean you want to burn those lines into a digital image instead of being lines on a graph? If so, I'd need more info, like what resolution of image do you want. Do you want the lines to be colored? If so, how? And how many lines should be drawn etc. Just imagine I asked you to do it. What questions would you have for me? Well I have the same questions for you.
george korris
george korris el 3 de Nov. de 2021
@Image Analyst No i mean lets say i have an image of a cat (in parallel with arnolds cat map) there i use the arnolds cat map transformation in order to take the pixels of my image (the cat) and scramble them with the iteration. Can i somehow do the same thong here ?

Iniciar sesión para comentar.

yanqi liu
yanqi liu el 4 de Nov. de 2021
Editada: yanqi liu el 9 de Nov. de 2021

5 comentarios

george korris
george korris el 4 de Nov. de 2021
Editada: Image Analyst el 5 de Nov. de 2021
@yanqi liu thank you but what does the previous code you uploaded do?
I mean this one:
% Logistic混沌序列1
% 分支参数
u1 = 3.9999;
% 初值设置
x1 = 1/sqrt(2);
% 保留4位小数
x1 = str2num(sprintf('%.4f', x1));
xn1(1)=x1;
for i=1 : num+1e3
% 迭代计算
xn1(i+1)=u1*xn1(i)*(1-xn1(i));
end
Unrecognized function or variable 'num'.
% 取指定长度的序列
xn1 = xn1(length(xn1)-num+1:end);
% 对应到位置序列
[~, ind1]=sort(xn1,'descend');
% Logistic混沌序列2
% 分支参数
u2 = 3.7777;
% 初值设置
x2 = 1/sqrt(3);
% 保留4位小数
x2 = str2num(sprintf('%.4f', x2));
xn2(1)=x2;
for i=1 : num+1e3
% 迭代计算
xn2(i+1)=u2*xn2(i)*(1-xn2(i));
end
% 取指定长度的序列
xn2 = xn2(length(xn2)-num+1:end);
% 对应到符号序列
ind2 = xn2>0.5;
xn2(ind2)=1;
xn2(~ind2)=-1;
% 循环进行置乱及符号加密
loop = 1e3;
coef_vec1 = coef_vec;
coef_vec2 = coef_vec;
for i = 1:loop
for j = 1: num
% 置换加密
coef_vec2(j)=coef_vec1(ind1(j));
end
% 符号加密
coef_vec1 = coef_vec2.*xn2;
end
yanqi liu
yanqi liu el 5 de Nov. de 2021
yes,sir,this is a demo for logistics chaos,just for watermark application
Image Analyst
Image Analyst el 5 de Nov. de 2021
The code does not run.
>> test
Unrecognized function or variable 'num'.
Error in test5 (line 9)
for i=1 : num+1e3
Plus I don't see any image being read in and watermarked and shown.
yanqi liu
yanqi liu el 5 de Nov. de 2021
Editada: yanqi liu el 9 de Nov. de 2021
% like
yanqi liu
yanqi liu el 6 de Nov. de 2021
i use it in watermark、encrypt、compress,so it must can transfer and inverse transfer

Iniciar sesión para comentar.

Preguntada:

el 30 de Oct. de 2021

Editada:

el 9 de Nov. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by