how can I write the MSE in matlab??

13 vues (au cours des 30 derniers jours)
Nicola
Nicola le 28 Juin 2014
Commenté : Image Analyst le 28 Juin 2014
Dear All, can anyone help me in implementing this formula on matlab? where aX(λ,k) is the true (clean) magnitude spectrum at frame λ and bin k; a^X(λ,k) is the estimated magnitude spectrum (following enhancement), M is the total number of frames in a sentence, and N is the number of frequency bins. The signal are complex column vectors and both size Mx1. Thanks you.

Réponses (1)

Image Analyst
Image Analyst le 28 Juin 2014
See my attached demo below. Here's a snippet from it:
%------ PSNR CALCULATION ----------------------------------------------------------
% Now we have our two images and we can calculate the PSNR.
% First, calculate the "square error" image.
% Make sure they're cast to floating point so that we can get negative differences.
% Otherwise two uint8's that should subtract to give a negative number
% would get clipped to zero and not be negative.
squaredErrorImage = (double(grayImage) - double(noisyImage)) .^ 2;
% Display the squared error image.
subplot(2, 2, 3);
imshow(squaredErrorImage, []);
title('Squared Error Image', 'FontSize', fontSize);
% Sum the Squared Image and divide by the number of elements
% to get the Mean Squared Error. It will be a scalar (a single number).
mse = sum(squaredErrorImage(:)) / (rows * columns);
% Calculate PSNR (Peak Signal to Noise Ratio) from the MSE according to the formula.
PSNR = 10 * log10( 256^2 / mse);
% Alert user of the answer.
message = sprintf('The mean square error is %.2f.\nThe PSNR = %.2f', mse, PSNR);
msgbox(message);
  2 commentaires
Nicola
Nicola le 28 Juin 2014
thanks for the reply, but my signals are audio signals. Is it the same?
Image Analyst
Image Analyst le 28 Juin 2014
Yes, it's the same, though you could simplify a bit by getting rid of the (:) since your signal is already a 1D signal
mse = sum(squaredErrorImage) / numel(squaredErrorImage);

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by