Calculating UACI, NPCR for 2 images
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
LOKESH
el 22 de Abr. de 2012
Comentada: Image Analyst
el 25 de En. de 2025 a las 15:17
Presently I have a problem in implementing the UACI and PSNR code for 2 images which are respectively Original & Cipher Images. I need the code for calculating it......
What would the Code? I don't have much idea about it.. Do I need to find UACI between 2 images or only 1 image will be sufficient
0 comentarios
Respuesta aceptada
Image Analyst
el 22 de Abr. de 2012
See my demo:
% Demo to calculate PSNR of a gray scale image.
% http://en.wikipedia.org/wiki/PSNR
% by ImageAnalyst
clc;
close all;
clearvars;
workspace;
% Read in standard MATLAB demo image.
grayImage = imread('cameraman.tif');
[rows columns] = size(grayImage);
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grey Scale Image');
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
% Add noise to it.
noisyImage = imnoise(grayImage, 'gaussian', 0, 0.003);
subplot(2, 2, 2);
imshow(noisyImage, []);
title('Noisy Image');
% Calculate mean square error.
mseImage = (double(grayImage) - double(noisyImage)) .^ 2;
subplot(2, 2, 3);
imshow(mseImage, []);
title('MSE Image');
mse = sum(sum(mseImage)) / (rows * columns);
% Calculate PSNR (Peak Signal to noise ratio).
PSNR = 10 * log10( 256^2 / mse);
message = sprintf('The mean square error is %.2f\nThe PSNR = %.2f', ...
mse, PSNR);
msgbox(message);
% set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
After this example you should be able to use similar code to easily calculate NPCR and UACI, according to http://www.cyberjournals.com/Papers/Apr2011/05.pdf. You need both images to calculate them since they are a measure of the differences between the two images.
2 comentarios
Walter Roberson
el 20 de Oct. de 2016
Image Analyst says "After this example you should be able to use similar code to easily calculate NPCR" -- in other words, he has not given the code here, but he has given a framework that can be adapted to calculate NPCR by anyone who looks up the formula for NPCR.
Más respuestas (1)
Hyderkkk
el 31 de Ag. de 2020
How do i get the NPCR and UACI of an original speech and encryption in matlab code ?
14 comentarios
sajjad
el 24 de En. de 2025 a las 4:13
I have almost completed the image encryption. Now how do i calculate the NPCR and UACI of an original image and encryption in matlab code ?
Please guide me in this regard.
Thank you.
Image Analyst
el 25 de En. de 2025 a las 15:17
@sajjad, did you see my comment above: https://www.mathworks.com/matlabcentral/answers/36171-calculating-uaci-npcr-for-2-images#comment_991829
That's about all I can offer, is that File Exchange entry. I don't have any code for it myself.
Ver también
Categorías
Más información sobre Encryption / Cryptography en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!