Calculate Histogram deviation or MDMF
조회 수: 8 (최근 30일)
이전 댓글 표시
I am trying to calculate the histogram deviation(H.D) or Maximum Deviation Measuring Factor(M.D.M.F) as mentioned in
and
Two coding,I have done.one is
clear all
close all
clc
plain = imread('lena.bmp');% Read the input image
[M N] = size(plain);
r = uint8(randi([0,256],M,N)); % Generate a random matrix for encryption
cipher = bitxor(plain,r); % Encryption
% x = double(plain);
% y = double(cipher);
x = plain;
y = cipher;
x1 = imhist(x);
y1 = imhist(y);
%then calculate the difference between the two
diff = abs(x1-y1);
%then calculate D as follows
D1 = 0;
for i = 2:255
D1 = D1+diff(i);
end;
D2 = (diff(1)+diff(256))/2;
MDMF = D1+D2/(M*N)
and the other is
clear all
close all
clc
plain = imread('lena.bmp');% Read the input image
[M N] = size(plain);
r = uint8(randi([0,256],M,N)); % Generate a random matrix for encryption
cipher = bitxor(plain,r); % Encryption
% x = double(plain);
% y = double(cipher);
x = plain;
y = cipher;
hi = imhist(x);
hr = imhist(y);
subplot(211)
imhist(x);
title('Histogram of Original Image')
subplot(212)
imhist(y);
title('Histogram of Encrypted Image')
diff = imabsdiff(hi,hr);
% z = abs(hi-hr);
d = ((diff(1)+diff(256))/2);
d1 = sum(diff(2:255));
histogram_deviation = (d+d1)/(256*256)
Please help me identify which code is correct according to the theoretical concepts
댓글 수: 0
답변 (1개)
Image Analyst
2017년 2월 13일
The Mathworks does not want us discussing encryption algorithms on their web site.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!