How to find NPCR and UAIC values of an image

4 次查看(过去 30 天)
How to find NPCR and UAIC values of an image

采纳的回答

Parveiz Lone
Parveiz Lone 2021-11-25
%% 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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by