NPCR Error

조회 수: 1 (최근 30일)
LOKESH
LOKESH 2012년 4월 25일
댓글: Parveiz Lone 2020년 5월 12일
For Image Quality Parameters I need to find NPCR for 2 images after encryption whose original image have 1 pixel difference. The code is:
% For Grayscale Jpeg Images
C=Cipher Image
C2c=Cipher Image after 1 Pixel difference in Original Image.
siz=M*M;
NPCR=0;
SSS=0;
for i=1:M
for j=1:M
if (C2(i,j)==C2c(i,j))
SSS=SSS;
else
SSS=SSS+1;
end
end
end
SSS=SSS/siz;
NPCR=SSS*100;
I get NPCR value=0.0015. Is my code not OK or the method for Cipher image. I should get a value around 99.67%
Suggest any solutions or error
  댓글 수: 4
LOKESH
LOKESH 2018년 6월 6일
This will always give 99.99% result..SSS=siz/(siz+1) will never need the loop..please check
Parveiz Lone
Parveiz Lone 2020년 5월 12일
%% 3. NCPR score and p_value
npcr_score = sum( double( img_a(:) ~= img_b(:) ) ) / num_of_pix;
npcr_mu = ( largest_allowed_val ) / ( largest_allowed_val+ 1 );
npcr_var = ( ( largest_allowed_val) / ( largest_allowed_val+ 1 )^2 ) / num_of_pix;
npcr_pVal = normcdf(npcr_score, npcr_mu, sqrt( npcr_var ) );
npcr_dist = [ npcr_mu, npcr_var ];

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2012년 4월 25일
The best encryption schemes would show no correlation between the encrypted versions of two original images that were nearly the same but not identical.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Encryption / Cryptography에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by