How to Find MSE and PSNR ?
2 ビュー (過去 30 日間)
古いコメントを表示
Please help me, an error occurred when I was calculating the score of MSE and PSNR
“Error using -
Integers can only be combined with integers of the same class, or scalar doubles.”
I use an MSE and PSNR function like the following:
function [nilaiMSE, nilaiPSNR] = MSE_PSNR(citra_Prepro,citra_Process);
%MSE
[m, n] = size(citra_Process);
nilaiMSE = sum(sum(citra_Prepro - (citra_Process .^2))/(m*n));
%PSNR
nilaiPSNR = 10*log10(255*255/(nilaiMSE));
end
And I used to look for the following value:
citra_Prepro= getimage(handles.axes_Preview);
citra_Process= getimage(handles.axes_IHPF);
[nilaiMSE, nilaiPSNR]= MSE_PSNR(citra_Prepro,citra_Process);
set(handles.MSE_IHPF,'String', nilaiMSE);
set(handles.PSNR_IHPF,'String', nilaiPSNR);
where my "citra_Prepro" variables gets from histogram equalization and my "citra_Process" variables gets from Ideal High Pass Filter.
0 件のコメント
回答 (1 件)
Yash
2023 年 12 月 2 日
Hi Akbar,
The error message you are getting suggests that there is a type mismatch between the citra_Prepro and citra_Process variables. Specifically, it seems that one of the variables is an integer and the other is a double. To fix this, you can convert both variables to the same data type using the double function. Here's an updated version of the MSE_PSNR function:
function [nilaiMSE, nilaiPSNR] = MSE_PSNR(citra_Prepro,citra_Process)
%MSE
c_Prepro = double(citra_Prepro);
citra_Process = double(citra_Process);
[m, n] = size(citra_Process);
nilaiMSE = sum(sum((citra_Prepro - citra_Process).^2))/(m*n);
%PSNR
nilaiPSNR = 10*log10(255*255/(nilaiMSE));
end
This version of the function converts both input variables to doubles using the double function, which should resolve the type mismatch error.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!