Image encryption using chaotic map ,, what does this code mean ?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
please this code is apart from a code which used to encrypt an image using logistic map key
i just want to know what does this line " [so , in ] = sort (x)" mean ??
and also i want explaination of the confusion step ,, please i need a help ,
tic
timg = img;
r = 3.62;
x(1) = 0.7;
row = size(img,1);
col = size(img,2);
s = row*col;
for n=1:s-1
x(n+1) = r*x(n)*(1-x(n));
end
[so,in] = sort(x);
%Start of Confusion
timg = timg(:);
for m = 1:size(timg,1)
t1 = timg(m);
timg(m)=timg(in(m));
timg(in(m))=t1;
end
3 comentarios
Amr Muhammad
el 4 de Sept. de 2021
Editada: Amr Muhammad
el 4 de Sept. de 2021
The complete program used to confuse and reconfuse an image:
close all;
clear all;
clc;
tic
img = imread('cameraman.jpg');
timg=rgb2gray(img);
r = 3.62;
x(1) = 0.7;
row = size(timg,1);
col = size(timg,2);
s = row*col;
for n=1:s-1
x(n+1) = r*x(n)*(1-x(n));
end
[so,in] = sort(x);
tencr=reshape(timg,s,1);
%Start of Encryption
encrimg=[];
for m = 1:s
encrimg(m)=tencr(in(m));
end
ImageEncr=reshape(encrimg,row,col);
figure
imshow(ImageEncr/255)
%Start of Decryption
tdecr=reshape(ImageEncr,s,1);
decrimg=[];
for m = 1:s
decrimg(in(m))=tdecr(m);
end
ImageDecr=reshape(decrimg,row,col);
figure
imshow(ImageDecr/255)
sajjad
el 15 de Dic. de 2024
Its very nice code. I am als working on cryptography (Image Encryption and Decryption).
Respuestas (2)
Walter Roberson
el 25 de Abr. de 2021
[so,in] = sort(x);
means that the vector x is to be sorted in ascending order, and that the sorted values are to be stored in the variable named "so". Furthermore, the variable named "in" is to be assigned indices. in(1) is to be assigned the index in x that so(1) came from, in(2) is where so(2) came from. The output is such that x(in)==so.
We cannot explain encryption algorithms here for legal reasons.
Image Analyst
el 25 de Abr. de 2021
It means that the author never learned professional code writing techniques. Techniques like using descriptive variable names and putting in comments. If he had, you would have seen something like
% Sort x in ascending order and return the sorted x values and
% the original location of the values in the unsorted, original vector.
[sortedValues, sortOrder] = sort(x, 'ascend');
and you probably would not have had to ask your question. Don't be like that bad programmer. Read these:
0 comentarios
Ver también
Categorías
Más información sobre Encryption / Cryptography en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!