Here We give the matlab code for Normalized Cross Correlation ,Normalized Mean Error and RMSE Calculations.
Normalized Cross Correlation matlab code
NormalizedMeanError matlab code
Root Mean Square Error (RMSE) Matlab code
Normalized Cross Correlation matlab code
function NK = NormalizedCrossCorrelation(origImg, distImg)
if size(origImg,3)==1
origImg = double(origImg);
distImg = double(distImg);
NK = sum(sum(origImg .* distImg)) / sum(sum(origImg^2));
else
r_rm = NormalizedCrossCorrelation(origImg(:,:,1),distImg(:,:,1));
g_rm = NormalizedCrossCorrelation(origImg(:,:,2),distImg(:,:,2));
b_rm = NormalizedCrossCorrelation(origImg(:,:,3),distImg(:,:,3));
NK = (r_rm+g_rm+b_rm)/3;
end
NormalizedMeanError matlab code
function NAE = NormalizedMeanError(origImg, distImg)
if size(origImg,3)==1
origImg = double(origImg);
distImg = double(distImg);
error = origImg - distImg;
NAE = sum(sum(abs(error))) / sum(sum(origImg));
else
r_rm = NormalizedMeanError(origImg(:,:,1),distImg(:,:,1));
g_rm = NormalizedMeanError(origImg(:,:,2),distImg(:,:,2));
b_rm = NormalizedMeanError(origImg(:,:,3),distImg(:,:,3));
NAE = (r_rm+g_rm+b_rm)/3;
end
Root Mean Square Error (RMSE) Matlab code
function rmse_val = RMSE_calc(r,f)
if size(r,3)==1
[m n] = size(r);
rmse_val = sqrt(sum(double(r(:))-double(f(:))).^2)/(m*n);
else
r_rm = RMSE_calc(r(:,:,1),f(:,:,1));
g_rm = RMSE_calc(r(:,:,2),f(:,:,2));
b_rm = RMSE_calc(r(:,:,3),f(:,:,3));
rmse_val = (r_rm+g_rm+b_rm)/3;
end
No comments:
Post a Comment