correlation analysis of two adjacent pixels

13 visualizaciones (últimos 30 días)
SNEHA P S
SNEHA P S el 25 de Jul. de 2017
Respondida: Hyderkkk el 26 de Sept. de 2021
I had an color image and an encrypted version of the same. I need to find the horizontal vertical and diagonal correlation coefficient of each channels R G and B of both plain image and cipher image. Help me with code for the same.
  1 comentario
omar A.alghafoor
omar A.alghafoor el 11 de Jul. de 2020
are there any solution ?
if yes , I want this code .

Iniciar sesión para comentar.

Respuestas (2)

KSSV
KSSV el 11 de Jul. de 2020
  1 comentario
omar A.alghafoor
omar A.alghafoor el 11 de Jul. de 2020
I have this code
% Finding correlation analysis of an image
% ----------------------------------------------
function corr(a,b)
a=imresize(a,[512,512]);
% Decompose in to R,G,B
%---------------------------------------
R=a(:,:,1);
G=a(:,:,2);
B=a(:,:,3);
%---------------------------------------
% Finding the correlation of adjacent pixels-------------Red
%----------------------------------------
A=double(R);
% Horizontal
x1 = A(:,1:end-1);
y1 = A(:,2:end);
fprintf(sprintf('%s Red:',b));
horizontal_values=corrcoef(x1,y1);
pause(1);
% Vertical
x2 = A(1:end-1,:);
y2 = A(2:end,:);
fprintf(sprintf('%s Red:',b));
vertical_vlaues=corrcoef(x2,y2)
pause(1);
% Diagonal,
x3 = A(1:end-1,1:end-1);
y3 = A(2:end,2:end);
fprintf(sprintf('%s Red:',b));
Diagonal_values=corrcoef(x3,y3)
%----------------------------------------
pause(4);
%----------------------------------------
% Correlation Figures
figure;
% plot(1,1),cor_figure(x1,y1,1),title(sprintf('%s Horizontal Red',b));
% plot(1,1),cor_figure(x2,y2,1),title(sprintf('%s Vertical Red',b));
% plot(1,1),cor_figure(x3,y3,1),title(sprintf('%s Diagonal Red',b));
subplot(131)
plot(x1,y1,'r'), title(sprintf('%s Horizontal Red',b));
subplot(132)
plot(x2,y2,'r'),title(sprintf('%s Vertical Red',b));
subplot(133)
plot(x3,y3,'r'),title(sprintf('%s Diagonal Red',b));
%----------------------------------------
pause(2);
%---------------------------------------
% Finding the correlation of adjacent pixels-------------Green
%----------------------------------------
A=double(G);
% Horizontal
x1 = A(:,1:end-1);
y1 = A(:,2:end);
fprintf(sprintf('%s Green:',b));
horizontal_values=corrcoef(x1,y1)
pause(1);
% Vertical
x2 = A(1:end-1,:);
y2 = A(2:end,:);
fprintf(sprintf('%s Green:',b));
vertical_vlaues=corrcoef(x2,y2)
pause(1);
% Diagonal,
x3 = A(1:end-1,1:end-1);
y3 = A(2:end,2:end);
fprintf(sprintf('%s Green:',b));
Diagonal_values=corrcoef(x3,y3)
%----------------------------------------
pause(1);
%----------------------------------------
% Correlation Figures
figure;
% plot(1,1),cor_figure(x1,y1,2),title(sprintf('%s Horizontal Green',b));
% plot(1,1),cor_figure(x2,y2,2),title(sprintf('%s Vertical Green',b));
% plot(1,1),cor_figure(x3,y3,2),title(sprintf('%s Diagonal Green',b));
subplot(131)
plot(x1,y1,'g'),title(sprintf('%s Horizontal Green',b));
subplot(132)
plot(x2,y2,'g'),title(sprintf('%s Vertical Green',b));
subplot(133)
plot(x3,y3,'g'),title(sprintf('%s Diagonal Green',b));
%----------------------------------------
pause(2);
%---------------------------------------
% Finding the correlation of adjacent pixels-------------Blue
%----------------------------------------
A=double(B);
% Horizontal
x1 = A(:,1:end-1);
y1 = A(:,2:end);
fprintf(sprintf('%s Blue:',b));
horizontal_values=corrcoef(x1,y1)
pause(1);
% Vertical
x2 = A(1:end-1,:);
y2 = A(2:end,:);
fprintf(sprintf('%s Blue:',b));
vertical_vlaues=corrcoef(x2,y2)
pause(1);
% Diagonal,
x3 = A(1:end-1,1:end-1);
y3 = A(2:end,2:end);
fprintf(sprintf('%s Blue:',b));
Diagonal_values=corrcoef(x3,y3)
%----------------------------------------
pause(1);
%----------------------------------------
% Correlation Figures
figure;
% plot(1,1),cor_figure(x1,y1,3),title(sprintf('%s Horizontal Blue',b));
% plot(1,1),cor_figure(x2,y2,3),title(sprintf('%s Vertical Blue',b));
% plot(1,1),cor_figure(x3,y3,3),title(sprintf('%s Diagonal Blue',b));
subplot(131)
plot(x1,y1,'b'),title(sprintf('%s Horizontal Blue',b));
subplot(132)
plot(x2,y2,'b'),title(sprintf('%s Vertical Blue',b));
subplot(133)
plot(x3,y3,'b'),title(sprintf('%s Diagonal Blue',b));
%----------------------------------------
end
%----------------------------------------
but plot for image encryption not accept

Iniciar sesión para comentar.


Hyderkkk
Hyderkkk el 26 de Sept. de 2021
IA=rgb2gray(im2double(A));
c_diag = corrcoef(IA(1:end-1, 1:end-1), IA(2:end, 2:end));
c_vert = corrcoef(IA(1:end-1, :), IA(2:end, :));
c_horz = corrcoef(IA(:, 1:end-1, :), IA(:, 2:end));
figure;
subplot(3,3,1)
plot(IA(1:end-1, 1:end-1), IA(2:end, 2:end),'b'),title(sprintf('%s Horizontal Orginal image',b));
subplot(3,3,2)
plot(IA(1:end-1, :), IA(2:end, :),'b'),title(sprintf('%s Vertical Orginal image',b));
subplot(3,3,3)
plot(IA(:, 1:end-1, :), IA(:, 2:end),'b'),title(sprintf('%s Diagonal Orginal image',b));
IAA=rgb2gray(im2double(im12));
c_diage = corrcoef(IAA(1:end-1, 1:end-1), IAA(2:end, 2:end))
c_verte = corrcoef(IAA(1:end-1, :), IAA(2:end, :))
c_horze = corrcoef(IAA(:, 1:end-1, :), IAA(:, 2:end))
subplot(3,3,4)
plot(IAA(1:end-1, 1:end-1), IAA(2:end, 2:end),'r'),title(sprintf('%s Horizontal chiphered image ',b));
subplot(3,3,5)
plot(IAA(1:end-1, :), IA(2:end, :),'r'),title(sprintf('%s Vertical chiphered image',b));
subplot(3,3,6)
plot(IAA(:, 1:end-1, :), IA(:, 2:end),'r'),title(sprintf('%s Diagonal chiphered image',b));

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by