Root mean square error of two images
11 ビュー (過去 30 日間)
古いコメントを表示
What is the function to calculate RSME of two images in matlab? i use:
I = imread('C:\Users\teymo\Desktop\New folder\CPU\rgray8.bmp');
J = imread('C:\Users\teymo\Desktop\New folder\CPU\blur.bmp');
result = sqrt(mean((J-I).^2));
message = sprintf('The Root mean square error is %.3f.', result);
msgbox(message);
but i get a error string error computing that, but the message box variable does show the root square but there are more than 1 number ?
"'The Root mean square error is 0.000.The Root mean square error is 2.848.The Root mean square error is 3.040.The Root mean square error is 3.056.The Root mean square error is 3.183.The Root mean square error is 3.350." It goes on forever so im not sure how to do it correctly
0 件のコメント
採用された回答
Rik
2020 年 4 月 28 日
Imagen in Matlab are either 2D or 3D. Assuming your images are already 2D, the subtraction will be element-wise, after which you have an element-wise square, followed by mean. The mean function only reduces by 1 dimension, so you end up with a vector. That means sqrt will be an element-wise operation, so pog is a vector.
If you want a single number, you need to convert your images to a vector:
I = imread('C:\Users\teymo\Desktop\New folder\CPU\rgray8.bmp');
J = imread('C:\Users\teymo\Desktop\New folder\CPU\blur.bmp');
pog = sqrt(mean((J(:)-I(:)).^2));
% ^^^ ^^^ add this
message = sprintf('The Root mean square error is %.3f.', pog);
msgbox(message);
3 件のコメント
DGM
2022 年 5 月 2 日
編集済み: DGM
2022 年 5 月 2 日
Calculating RMSE (or MSE or MAD) directly on imported image data will likely be incorrect unless precautions are taken.
Most images are going to be integer-class, so the limited range of the numeric class will result in truncation when taking the difference and when squaring.
A = imread('peppers.png'); % these are both uint8
B = imnoise(A);
rmse1 = sqrt(mean((A(:)-B(:)).^2)) % direct calculation with integers
rmse2 = sqrt(mean((double(A(:))-double(B(:))).^2)) % convert to floats
rmse3 = sqrt(immse(A,B)) % or if you have IPT, you can just use immse()
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!