How to find NPCR and UAIC values of an image

4 views (last 30 days)
How to find NPCR and UAIC values of an image

Accepted Answer

Parveiz Lone
Parveiz Lone on 25 Nov 2021
%% 3. NCPR score and UACI values for image data
function [n1 n2 n3 u1 u2 u3]=npcr_uaci(A,B)
[M N C]=size(A);
[M N C]=size(B);
A=uint8(A);
B=uint8(B);
A255=double(A)/double(255);
B255=double(B)/double(255);
D_R=0;
D_G=0;
D_B=0;
%
C_R=0;
C_G=0;
C_B=0;
for i=1:M
for j=1:N
if A(i,j,1)~=B(i,j,1)
D_R=D_R+1;
C_R=C_R+abs(A255(i,j,1)-B255(i,j,1));
% C_R=C_R+abs(double(A(i,j,1))-double(B(i,j,1)))/double(255);%or
end
if A(i,j,2)~=B(i,j,2)
D_G=D_G+1;
C_G=C_G+abs(A255(i,j,2)-B255(i,j,2));
end
if A(i,j,3)~=B(i,j,3)
D_B=D_B+1;
C_B=C_B+abs(A255(i,j,3)-B255(i,j,3));
end
end
end
n1=D_R*100/(M*N);
n2=D_G*100/(M*N);
n3=D_B*100/(M*N);
u1=C_R*100/(M*N);
u2=C_G*100/(M*N);
u3=C_B*100/(M*N);
end

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!