From 0f1c95ece916ad585223fb68d36133056f790334 Mon Sep 17 00:00:00 2001 From: zvezdochiot Date: Tue, 14 Feb 2023 11:57:29 +0300 Subject: [PATCH] 2.6.4: Research: correct UM model: all metrics. --- CHANGELOG | 5 + README.md | 12 +- man/man1/jpeg-compare.1 | 14 +- man/man1/jpeg-hash.1 | 2 +- man/man1/jpeg-recompress.1 | 14 +- man/man1/jpeg-zfpoint.1 | 2 +- man/man1/webp-compress.1 | 14 +- plot_um.svg | 2487 ++++++++++++++++++++++-------------- src/jmetrics.c | 52 +- src/jmetrics.h | 4 +- src/jpeg-recompress.c | 2 +- src/webp-compress.c | 2 +- 12 files changed, 1572 insertions(+), 1038 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8086fdd..398423d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,11 @@ JPEG Recompress https://github.com/ImageProcessing-ElectronicPublications/jpeg-recompress +2.6.4 "um" + + Research: correct UM model: all metrics. + 2023, zvezdochiot + 2.6.3 "um" Research: correct UM model. diff --git a/README.md b/README.md index e801db2..bc01e2a 100644 --- a/README.md +++ b/README.md @@ -90,16 +90,16 @@ SUMMARY | `-m sum` | `(ssim + vipf1 + smallfry + shbad + nhw) / 5` **DE ``` Trends: ``` - UM = 0.25 * (sqrt(sqrt(255.0 / MPE)) - 1.0) - UM = 0.87 * sqrt(PNSR) - 4.70 + UM = 0.29 * (sqrt(sqrt(255.0 / MPE)) - 1.0) + UM = 0.557 * (sqrt(PNSR) - 5.0) UM = 0.5 * (sqrt(sqrt(1.0 / MSEF)) - 1.0) UM = 1.0 * cor_sigma(cor_sigma(COR)) - UM = 1.51 * cor_sigma(cor_sigma(cor_sigma(SSIM))) + UM = 1.57 * cor_sigma(cor_sigma(cor_sigma(SSIM))) UM = 1.59 * cor_sigma(cor_sigma(MS_SSIM)) - UM = 1.06 * cor_sigma(cor_sigma(VIFP1)) + UM = 1.10 * cor_sigma(cor_sigma(VIFP1)) UM = 3.0 * (SMALLFRY * 0.01 - 0.8) - UM = 1.0 * cor_sigma(sqrt(SHARPENBAD)) - UM = 0.333 * (sqrt(sqrt(1.0 / NHW)) - 1.0) + UM = 1.46 * cor_sigma(SHARPENBAD) + UM = 0.342 * (sqrt(sqrt(1.0 / NHW)) - 1.0) cor_sigma(M) = 1.0 - sqrt(1.0 - M * M) ``` diff --git a/man/man1/jpeg-compare.1 b/man/man1/jpeg-compare.1 index f2632e7..344b4aa 100644 --- a/man/man1/jpeg-compare.1 +++ b/man/man1/jpeg-compare.1 @@ -1,4 +1,4 @@ -.TH "jpeg-compare" 1 2.6.3 "09 Feb 2023" "User manual" +.TH "jpeg-compare" 1 2.6.4 "14 Feb 2023" "User manual" .SH NAME jpeg-compare @@ -74,16 +74,16 @@ jpeg-compare --method ssim image1.jpg image2.jpg .PP Trends: - UM = 0.25 * (sqrt(sqrt(255.0 / MPE)) - 1.0) - UM = 0.87 * sqrt(PNSR) - 4.70 + UM = 0.29 * (sqrt(sqrt(255.0 / MPE)) - 1.0) + UM = 0.557 * (sqrt(PNSR) - 5.0) UM = 0.5 * (sqrt(sqrt(1.0 / MSEF)) - 1.0) UM = 1.0 * cor_sigma(cor_sigma(COR)) - UM = 1.51 * cor_sigma(cor_sigma(cor_sigma(SSIM))) + UM = 1.57 * cor_sigma(cor_sigma(cor_sigma(SSIM))) UM = 1.59 * cor_sigma(cor_sigma(MS_SSIM)) - UM = 1.06 * cor_sigma(cor_sigma(VIFP1)) + UM = 1.10 * cor_sigma(cor_sigma(VIFP1)) UM = 3.0 * (SMALLFRY * 0.01 - 0.8) - UM = 1.0 * cor_sigma(sqrt(SHARPENBAD)) - UM = 0.333 * (sqrt(sqrt(1.0 / NHW)) - 1.0) + UM = 1.46 * cor_sigma(SHARPENBAD) + UM = 0.342 * (sqrt(sqrt(1.0 / NHW)) - 1.0) cor_sigma(M) = 1.0 - sqrt(1.0 - M * M) .SH COPYRIGHT diff --git a/man/man1/jpeg-hash.1 b/man/man1/jpeg-hash.1 index 0d94496..8d3c6c1 100644 --- a/man/man1/jpeg-hash.1 +++ b/man/man1/jpeg-hash.1 @@ -1,4 +1,4 @@ -.TH "jpeg-hash" 1 2.6.3 "09 Feb 2023" "User manual" +.TH "jpeg-hash" 1 2.6.4 "14 Feb 2023" "User manual" .SH NAME jpeg-hash diff --git a/man/man1/jpeg-recompress.1 b/man/man1/jpeg-recompress.1 index 700399c..05d29a8 100644 --- a/man/man1/jpeg-recompress.1 +++ b/man/man1/jpeg-recompress.1 @@ -1,4 +1,4 @@ -.TH "jpeg-recompress" 1 2.6.3 "09 Feb 2023" "User manual" +.TH "jpeg-recompress" 1 2.6.4 "14 Feb 2023" "User manual" .SH NAME jpeg-recompress @@ -145,16 +145,16 @@ jpeg-recompress --quiet image.jpg compressed.jpg .PP Trends: - UM = 0.25 * (sqrt(sqrt(255.0 / MPE)) - 1.0) - UM = 0.87 * sqrt(PNSR) - 4.70 + UM = 0.29 * (sqrt(sqrt(255.0 / MPE)) - 1.0) + UM = 0.557 * (sqrt(PNSR) - 5.0) UM = 0.5 * (sqrt(sqrt(1.0 / MSEF)) - 1.0) UM = 1.0 * cor_sigma(cor_sigma(COR)) - UM = 1.51 * cor_sigma(cor_sigma(cor_sigma(SSIM))) + UM = 1.57 * cor_sigma(cor_sigma(cor_sigma(SSIM))) UM = 1.59 * cor_sigma(cor_sigma(MS_SSIM)) - UM = 1.06 * cor_sigma(cor_sigma(VIFP1)) + UM = 1.10 * cor_sigma(cor_sigma(VIFP1)) UM = 3.0 * (SMALLFRY * 0.01 - 0.8) - UM = 1.0 * cor_sigma(sqrt(SHARPENBAD)) - UM = 0.333 * (sqrt(sqrt(1.0 / NHW)) - 1.0) + UM = 1.46 * cor_sigma(SHARPENBAD) + UM = 0.342 * (sqrt(sqrt(1.0 / NHW)) - 1.0) cor_sigma(M) = 1.0 - sqrt(1.0 - M * M) .SH COPYRIGHT diff --git a/man/man1/jpeg-zfpoint.1 b/man/man1/jpeg-zfpoint.1 index 9232be9..567d821 100644 --- a/man/man1/jpeg-zfpoint.1 +++ b/man/man1/jpeg-zfpoint.1 @@ -1,4 +1,4 @@ -.TH "jpeg-zfpoint" 1 2.6.3 "09 Feb 2023" "User manual" +.TH "jpeg-zfpoint" 1 2.6.4 "14 Feb 2023" "User manual" .SH NAME jpeg-zfpoint diff --git a/man/man1/webp-compress.1 b/man/man1/webp-compress.1 index 579e160..70fe1be 100644 --- a/man/man1/webp-compress.1 +++ b/man/man1/webp-compress.1 @@ -1,4 +1,4 @@ -.TH "webp-compress" 1 2.6.3 "09 Feb 2023" "User manual" +.TH "webp-compress" 1 2.6.4 "14 Feb 2023" "User manual" .SH NAME webp-compress @@ -109,16 +109,16 @@ webp-compress --quiet image.jpg compressed.webp .PP Trends: - UM = 0.25 * (sqrt(sqrt(255.0 / MPE)) - 1.0) - UM = 0.87 * sqrt(PNSR) - 4.70 + UM = 0.29 * (sqrt(sqrt(255.0 / MPE)) - 1.0) + UM = 0.557 * (sqrt(PNSR) - 5.0) UM = 0.5 * (sqrt(sqrt(1.0 / MSEF)) - 1.0) UM = 1.0 * cor_sigma(cor_sigma(COR)) - UM = 1.51 * cor_sigma(cor_sigma(cor_sigma(SSIM))) + UM = 1.57 * cor_sigma(cor_sigma(cor_sigma(SSIM))) UM = 1.59 * cor_sigma(cor_sigma(MS_SSIM)) - UM = 1.06 * cor_sigma(cor_sigma(VIFP1)) + UM = 1.10 * cor_sigma(cor_sigma(VIFP1)) UM = 3.0 * (SMALLFRY * 0.01 - 0.8) - UM = 1.0 * cor_sigma(sqrt(SHARPENBAD)) - UM = 0.333 * (sqrt(sqrt(1.0 / NHW)) - 1.0) + UM = 1.46 * cor_sigma(SHARPENBAD) + UM = 0.342 * (sqrt(sqrt(1.0 / NHW)) - 1.0) cor_sigma(M) = 1.0 - sqrt(1.0 - M * M) .SH COPYRIGHT diff --git a/plot_um.svg b/plot_um.svg index a62a43f..55b9d72 100644 --- a/plot_um.svg +++ b/plot_um.svg @@ -1,974 +1,1515 @@ - - - Gnuplot - Produced by GNUPLOT 5.4 patchlevel 1 - - - - - - - - - - - - - - - - 0 - - - - 0.2 - - - - 0.4 - - - - 0.6 - - - - 0.8 - - - - 1 - - - - 1.2 - - - - 10 - - - - 20 - - - - 30 - - - - 40 - - - - 50 - - - - 60 - - - - 70 - - - - 80 - - - - 90 - - - - 100 - - - - UM - - - quality - - - - Correlation - - - Correlation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MPE - - - MPE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MSEF - - - MSEF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NHW - - - NHW - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SHARPENBAD - - - SHARPENBAD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SMALLFRY - - - SMALLFRY - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SSIM - - - SSIM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - VIFP1 - - - VIFP1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SUM - - - SUM - - - - - - - - Universal Scale of Metrics (UM) - - - + + + +Gnuplot +Produced by GNUPLOT 5.4 patchlevel 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -0.2 + + + + + 0 + + + + + 0.2 + + + + + 0.4 + + + + + 0.6 + + + + + 0.8 + + + + + 1 + + + + + 1.2 + + + + + 1.4 + + + + + 10 + + + + + 20 + + + + + 30 + + + + + 40 + + + + + 50 + + + + + 60 + + + + + 70 + + + + + 80 + + + + + 90 + + + + + 100 + + + + + + + + + UM + + + + + quality + + + + + Correlation + + + Correlation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MPE + + + MPE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSEF + + + MSEF + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSE + + + MSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MS-SSIM + + + MS-SSIM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NHW + + + NHW + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PSNR + + + PSNR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SHARPENBAD + + + SHARPENBAD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SMALLFRY + + + SMALLFRY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SSIM + + + SSIM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + VIFP1 + + + VIFP1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SUM + + + + + SUM + + + + + + + + + + + + + + + + Universal Scale of Metrics (UM) + + + + + + diff --git a/src/jmetrics.c b/src/jmetrics.c index f6fd0ea..02b33f9 100644 --- a/src/jmetrics.c +++ b/src/jmetrics.c @@ -901,12 +901,11 @@ enum METHOD parseMethod(const char *s) return UNKNOWN; } -float RescaleMetric(int currentmethod, float value) +float MetricRescale(int currentmethod, float value) { - float k1, k0; - + float k1; + k1 = 1.0f; - k0 = 0.0f; switch (currentmethod) { case MSE: @@ -918,8 +917,7 @@ float RescaleMetric(int currentmethod, float value) value = sqrt(value); value = sqrt(value); value -= 1.0f; - k1 = 0.25f; - k0 = 0.0f; + k1 = 0.29f; } else { @@ -928,14 +926,13 @@ float RescaleMetric(int currentmethod, float value) break; case PSNR: value = sqrt(value); - k1 = 0.87f; - k0 = -4.70f; + value -= 5.0f; + k1 = 0.557f; break; case COR: value = MetricSigma(value); value = MetricSigma(value); k1 = 1.0f; - k0 = 0.0f; break; case MSEF: if (value > 0.0f) @@ -945,7 +942,6 @@ float RescaleMetric(int currentmethod, float value) value = sqrt(value); value -= 1.0f; k1 = 0.5f; - k0 = 0.0f; } else { @@ -956,32 +952,26 @@ float RescaleMetric(int currentmethod, float value) value = MetricSigma(value); value = MetricSigma(value); value = MetricSigma(value); - k1 = 1.51f; - k0 = 0.0f; + k1 = 1.57f; break; case MS_SSIM: value = MetricSigma(value); value = MetricSigma(value); k1 = 1.59f; - k0 = 0.0f; break; case VIFP1: value = MetricSigma(value); value = MetricSigma(value); - k1 = 1.06f; - k0 = 0.0f; + k1 = 1.10f; break; case SMALLFRY: value *= 0.01f; value -= 0.8f; k1 = 3.0f; - k0 = 0.0f; break; case SHARPENBAD: - value = sqrt(value); value = MetricSigma(value); - k1 = 1.0f; - k0 = 0.0f; + k1 = 1.46f; break; case NHW: if (value > 0.0f) @@ -990,8 +980,7 @@ float RescaleMetric(int currentmethod, float value) value = sqrt(value); value = sqrt(value); value -= 1.0f; - k1 = 0.333f; - k0 = 0.0f; + k1 = 0.342f; } else { @@ -1000,7 +989,6 @@ float RescaleMetric(int currentmethod, float value) break; } value *= k1; - value += k0; return value; } @@ -1120,30 +1108,30 @@ float MetricCalc(int method, unsigned char *image1, unsigned char *image2, int w break; case SSIMFRY: tmetric = iqa_ssim(image1, image2, width, height, width * components, 0, 0); - diff = RescaleMetric(SSIM, tmetric); + diff = MetricRescale(SSIM, tmetric); tmetric = metric_smallfry(image1, image2, width, height); - diff += RescaleMetric(SMALLFRY, tmetric); + diff += MetricRescale(SMALLFRY, tmetric); diff *= 0.5f; break; case SSIMSHBAD: tmetric = iqa_ssim(image1, image2, width, height, width * components, 0, 0); - diff = RescaleMetric(SSIM, tmetric); + diff = MetricRescale(SSIM, tmetric); tmetric = metric_sharpenbad(image1, image2, width, height, 1); - diff += RescaleMetric(SHARPENBAD, tmetric); + diff += MetricRescale(SHARPENBAD, tmetric); diff *= 0.5f; break; case SUMMET: default: tmetric = iqa_ssim(image1, image2, width, height, width * components, 0, 0); - tm[0] = RescaleMetric(SSIM, tmetric); + tm[0] = MetricRescale(SSIM, tmetric); tmetric = metric_smallfry(image1, image2, width, height); - tm[1] = RescaleMetric(SMALLFRY, tmetric); + tm[1] = MetricRescale(SMALLFRY, tmetric); tmetric = metric_sharpenbad(image1, image2, width, height, 1); - tm[2] = RescaleMetric(SHARPENBAD, tmetric); + tm[2] = MetricRescale(SHARPENBAD, tmetric); tmetric = metric_nhw(image1, image2, width, height); - tm[3] = RescaleMetric(NHW, tmetric); + tm[3] = MetricRescale(NHW, tmetric); tmetric = iqa_vifp1(image1, image2, width, height, width * components, 0, 0); - tm[4] = RescaleMetric(VIFP1, tmetric); + tm[4] = MetricRescale(VIFP1, tmetric); diff = waverage(tm, 5); break; } @@ -1246,7 +1234,7 @@ int compareFromBuffer(int method, unsigned char *imageBuf1, long bufSize1, unsig // Calculate and print comparison diff = MetricCalc(method, image1, image2, width1, height1, components); if (umscale) - diff = RescaleMetric(method, diff); + diff = MetricRescale(method, diff); if (printPrefix) printf("%s: ", MetricName(method)); printf("%f", diff); diff --git a/src/jmetrics.h b/src/jmetrics.h index 94fa45a..16d1d0b 100644 --- a/src/jmetrics.h +++ b/src/jmetrics.h @@ -21,7 +21,7 @@ #define JMETRICS_H #ifndef JMVERSION -#define JMVERSION "2.6.3" +#define JMVERSION "2.6.4" #endif #define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -203,7 +203,7 @@ int parseSubsampling(const char *s); enum QUALITY_PRESET parseQuality(const char *s); float setTargetFromPreset(int preset); enum METHOD parseMethod(const char *s); -float RescaleMetric(int currentmethod, float value); +float MetricRescale(int currentmethod, float value); char* MetricName(int currentmethod); float MetricCalc(int method, unsigned char *image1, unsigned char *image2, int width, int height, int components); float MetricSigma(float cor); diff --git a/src/jpeg-recompress.c b/src/jpeg-recompress.c index 39511c7..11d2f2e 100644 --- a/src/jpeg-recompress.c +++ b/src/jpeg-recompress.c @@ -326,7 +326,7 @@ int main (int argc, char **argv) // Measure quality difference metric = MetricCalc(method, originalGray, compressedGray, width, height, 1); - umetric = RescaleMetric(method, metric); + umetric = MetricRescale(method, metric); info(quiet, MetricName(method)); if (attempt) diff --git a/src/webp-compress.c b/src/webp-compress.c index 2386047..6a259c1 100644 --- a/src/webp-compress.c +++ b/src/webp-compress.c @@ -315,7 +315,7 @@ int main (int argc, char **argv) // Measure quality difference metric = MetricCalc(method, originalGray, compressedGray, width, height, 1); - umetric = RescaleMetric(method, metric); + umetric = MetricRescale(method, metric); info(quiet, MetricName(method)); if (attempt)