perform image encryption and verification with chaotic maps in matlab

To perform image encryption and verification using chaotic maps in MATLAB, we can follow the below steps:

  1. Load the image to be encrypted.
img = imread('image.png');
27 chars
2 lines
  1. Convert the image into grayscale image.
img = rgb2gray(img);
21 chars
2 lines
  1. Initialize the chaotic maps parameters.
x = 0.1;
y = 0.1;
z = 0.1;
a = 10;
b = 28;
c = 8/3;
n = numel(img);
68 chars
8 lines
  1. Generate the chaotic map.
X = zeros(1, n);
Y = zeros(1, n);
Z = zeros(1, n);

for i = 1:n
    X(i+1) = Y(i) + a*(Y(i) - X(i));
    Y(i+1) = X(i)*(b - Z(i)) - Y(i);
    Z(i+1) = X(i)*Y(i) - c*Z(i);
end

% Scaling
X = X./max(X);
Y = Y./max(Y);
Z = Z./max(Z);
231 chars
15 lines
  1. Encrypt the image using XOR operation with the chaotic map.
encrypted_img = bitxor(img, uint8(X(1:n)));
44 chars
2 lines
  1. Decrypt the encrypted image using the same chaotic map to verify the image.
decrypted_img = bitxor(encrypted_img, uint8(X(1:n)));
54 chars
2 lines
  1. Display the original, encrypted and decrypted images.
subplot(1, 3, 1);
imshow(img);
title('Original Image');

subplot(1, 3, 2);
imshow(encrypted_img);
title('Encrypted Image');

subplot(1, 3, 3);
imshow(decrypted_img);
title('Decrypted Image');
192 chars
12 lines

This is one way to perform image encryption and verification with chaotic maps in MATLAB. However, there are other methods as well which can be used depending on the specific requirements.

gistlibby LogSnag