/* ------------------------------------------------------------ */ float32 psnr(uint8 **X, int i0, int i1, int j0, int j1, uint8 **Y) /* ------------------------------------------------------------ */ { float32 mse; float32 psnr; mse = mean_square_error(X, i0, i1, j0, j1, Y); if(mse != 0.0f) { psnr = 10 * (log10(255*255) / log10(mse)); } else { psnr = 0.0; } return psnr; }
static double imgerr(char *m, float *x, float *y, int n) { double r; if (false); else if (0 == strcmp(m, "MSE")) r = mean_square_error(x, y, n); else if (0 == strcmp(m, "RMSE")) r = root_mean_square_error(x, y, n); else if (0 == strcmp(m, "MAE")) r = mean_absolute_error(x, y, n); else if (0 == strcmp(m, "UIQI")) r = uiqi(x, y, n); else if (0 == strcmp(m, "SSIM")) r = ssim(x, y, n); else if (0 == strcmp(m, "PSNR")) r = psnr(x, y, n); else if (0 == strcmp(m, "NCC")) r = ncc(x, y, n); else if (string_is_lp(m, &r)) r = ell_pee_distance(x, y, n, r); else fail("unrecognized metric \"%s\"", m); return r; }