Skip to content

Commit

Permalink
2.6.4: Research: correct UM model: all metrics.
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed Feb 14, 2023
1 parent d850c2e commit 0f1c95e
Show file tree
Hide file tree
Showing 12 changed files with 1,572 additions and 1,038 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```
Expand Down
14 changes: 7 additions & 7 deletions man/man1/jpeg-compare.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion man/man1/jpeg-hash.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions man/man1/jpeg-recompress.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion man/man1/jpeg-zfpoint.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions man/man1/webp-compress.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2,487 changes: 1,514 additions & 973 deletions plot_um.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 20 additions & 32 deletions src/jmetrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
{
Expand All @@ -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)
Expand All @@ -945,7 +942,6 @@ float RescaleMetric(int currentmethod, float value)
value = sqrt(value);
value -= 1.0f;
k1 = 0.5f;
k0 = 0.0f;
}
else
{
Expand All @@ -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)
Expand All @@ -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
{
Expand All @@ -1000,7 +989,6 @@ float RescaleMetric(int currentmethod, float value)
break;
}
value *= k1;
value += k0;

return value;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/jmetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/jpeg-recompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/webp-compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0f1c95e

Please sign in to comment.