Skip to content

Commit 0f1c95e

Browse files
committed
2.6.4: Research: correct UM model: all metrics.
1 parent d850c2e commit 0f1c95e

12 files changed

+1572
-1038
lines changed

CHANGELOG

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
JPEG Recompress
22
https://github.com/ImageProcessing-ElectronicPublications/jpeg-recompress
33

4+
2.6.4 "um"
5+
6+
Research: correct UM model: all metrics.
7+
2023, zvezdochiot
8+
49
2.6.3 "um"
510

611
Research: correct UM model.

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ SUMMARY | `-m sum` | `(ssim + vipf1 + smallfry + shbad + nhw) / 5` **DE
9090
```
9191
Trends:
9292
```
93-
UM = 0.25 * (sqrt(sqrt(255.0 / MPE)) - 1.0)
94-
UM = 0.87 * sqrt(PNSR) - 4.70
93+
UM = 0.29 * (sqrt(sqrt(255.0 / MPE)) - 1.0)
94+
UM = 0.557 * (sqrt(PNSR) - 5.0)
9595
UM = 0.5 * (sqrt(sqrt(1.0 / MSEF)) - 1.0)
9696
UM = 1.0 * cor_sigma(cor_sigma(COR))
97-
UM = 1.51 * cor_sigma(cor_sigma(cor_sigma(SSIM)))
97+
UM = 1.57 * cor_sigma(cor_sigma(cor_sigma(SSIM)))
9898
UM = 1.59 * cor_sigma(cor_sigma(MS_SSIM))
99-
UM = 1.06 * cor_sigma(cor_sigma(VIFP1))
99+
UM = 1.10 * cor_sigma(cor_sigma(VIFP1))
100100
UM = 3.0 * (SMALLFRY * 0.01 - 0.8)
101-
UM = 1.0 * cor_sigma(sqrt(SHARPENBAD))
102-
UM = 0.333 * (sqrt(sqrt(1.0 / NHW)) - 1.0)
101+
UM = 1.46 * cor_sigma(SHARPENBAD)
102+
UM = 0.342 * (sqrt(sqrt(1.0 / NHW)) - 1.0)
103103
104104
cor_sigma(M) = 1.0 - sqrt(1.0 - M * M)
105105
```

man/man1/jpeg-compare.1

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH "jpeg-compare" 1 2.6.3 "09 Feb 2023" "User manual"
1+
.TH "jpeg-compare" 1 2.6.4 "14 Feb 2023" "User manual"
22

33
.SH NAME
44
jpeg-compare
@@ -74,16 +74,16 @@ jpeg-compare --method ssim image1.jpg image2.jpg
7474
.PP
7575
Trends:
7676

77-
UM = 0.25 * (sqrt(sqrt(255.0 / MPE)) - 1.0)
78-
UM = 0.87 * sqrt(PNSR) - 4.70
77+
UM = 0.29 * (sqrt(sqrt(255.0 / MPE)) - 1.0)
78+
UM = 0.557 * (sqrt(PNSR) - 5.0)
7979
UM = 0.5 * (sqrt(sqrt(1.0 / MSEF)) - 1.0)
8080
UM = 1.0 * cor_sigma(cor_sigma(COR))
81-
UM = 1.51 * cor_sigma(cor_sigma(cor_sigma(SSIM)))
81+
UM = 1.57 * cor_sigma(cor_sigma(cor_sigma(SSIM)))
8282
UM = 1.59 * cor_sigma(cor_sigma(MS_SSIM))
83-
UM = 1.06 * cor_sigma(cor_sigma(VIFP1))
83+
UM = 1.10 * cor_sigma(cor_sigma(VIFP1))
8484
UM = 3.0 * (SMALLFRY * 0.01 - 0.8)
85-
UM = 1.0 * cor_sigma(sqrt(SHARPENBAD))
86-
UM = 0.333 * (sqrt(sqrt(1.0 / NHW)) - 1.0)
85+
UM = 1.46 * cor_sigma(SHARPENBAD)
86+
UM = 0.342 * (sqrt(sqrt(1.0 / NHW)) - 1.0)
8787
cor_sigma(M) = 1.0 - sqrt(1.0 - M * M)
8888

8989
.SH COPYRIGHT

man/man1/jpeg-hash.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH "jpeg-hash" 1 2.6.3 "09 Feb 2023" "User manual"
1+
.TH "jpeg-hash" 1 2.6.4 "14 Feb 2023" "User manual"
22

33
.SH NAME
44
jpeg-hash

man/man1/jpeg-recompress.1

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH "jpeg-recompress" 1 2.6.3 "09 Feb 2023" "User manual"
1+
.TH "jpeg-recompress" 1 2.6.4 "14 Feb 2023" "User manual"
22

33
.SH NAME
44
jpeg-recompress
@@ -145,16 +145,16 @@ jpeg-recompress --quiet image.jpg compressed.jpg
145145
.PP
146146
Trends:
147147

148-
UM = 0.25 * (sqrt(sqrt(255.0 / MPE)) - 1.0)
149-
UM = 0.87 * sqrt(PNSR) - 4.70
148+
UM = 0.29 * (sqrt(sqrt(255.0 / MPE)) - 1.0)
149+
UM = 0.557 * (sqrt(PNSR) - 5.0)
150150
UM = 0.5 * (sqrt(sqrt(1.0 / MSEF)) - 1.0)
151151
UM = 1.0 * cor_sigma(cor_sigma(COR))
152-
UM = 1.51 * cor_sigma(cor_sigma(cor_sigma(SSIM)))
152+
UM = 1.57 * cor_sigma(cor_sigma(cor_sigma(SSIM)))
153153
UM = 1.59 * cor_sigma(cor_sigma(MS_SSIM))
154-
UM = 1.06 * cor_sigma(cor_sigma(VIFP1))
154+
UM = 1.10 * cor_sigma(cor_sigma(VIFP1))
155155
UM = 3.0 * (SMALLFRY * 0.01 - 0.8)
156-
UM = 1.0 * cor_sigma(sqrt(SHARPENBAD))
157-
UM = 0.333 * (sqrt(sqrt(1.0 / NHW)) - 1.0)
156+
UM = 1.46 * cor_sigma(SHARPENBAD)
157+
UM = 0.342 * (sqrt(sqrt(1.0 / NHW)) - 1.0)
158158
cor_sigma(M) = 1.0 - sqrt(1.0 - M * M)
159159

160160
.SH COPYRIGHT

man/man1/jpeg-zfpoint.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH "jpeg-zfpoint" 1 2.6.3 "09 Feb 2023" "User manual"
1+
.TH "jpeg-zfpoint" 1 2.6.4 "14 Feb 2023" "User manual"
22

33
.SH NAME
44
jpeg-zfpoint

man/man1/webp-compress.1

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH "webp-compress" 1 2.6.3 "09 Feb 2023" "User manual"
1+
.TH "webp-compress" 1 2.6.4 "14 Feb 2023" "User manual"
22

33
.SH NAME
44
webp-compress
@@ -109,16 +109,16 @@ webp-compress --quiet image.jpg compressed.webp
109109
.PP
110110
Trends:
111111

112-
UM = 0.25 * (sqrt(sqrt(255.0 / MPE)) - 1.0)
113-
UM = 0.87 * sqrt(PNSR) - 4.70
112+
UM = 0.29 * (sqrt(sqrt(255.0 / MPE)) - 1.0)
113+
UM = 0.557 * (sqrt(PNSR) - 5.0)
114114
UM = 0.5 * (sqrt(sqrt(1.0 / MSEF)) - 1.0)
115115
UM = 1.0 * cor_sigma(cor_sigma(COR))
116-
UM = 1.51 * cor_sigma(cor_sigma(cor_sigma(SSIM)))
116+
UM = 1.57 * cor_sigma(cor_sigma(cor_sigma(SSIM)))
117117
UM = 1.59 * cor_sigma(cor_sigma(MS_SSIM))
118-
UM = 1.06 * cor_sigma(cor_sigma(VIFP1))
118+
UM = 1.10 * cor_sigma(cor_sigma(VIFP1))
119119
UM = 3.0 * (SMALLFRY * 0.01 - 0.8)
120-
UM = 1.0 * cor_sigma(sqrt(SHARPENBAD))
121-
UM = 0.333 * (sqrt(sqrt(1.0 / NHW)) - 1.0)
120+
UM = 1.46 * cor_sigma(SHARPENBAD)
121+
UM = 0.342 * (sqrt(sqrt(1.0 / NHW)) - 1.0)
122122
cor_sigma(M) = 1.0 - sqrt(1.0 - M * M)
123123

124124
.SH COPYRIGHT

plot_um.svg

+1,514-973
Loading

src/jmetrics.c

+20-32
Original file line numberDiff line numberDiff line change
@@ -901,12 +901,11 @@ enum METHOD parseMethod(const char *s)
901901
return UNKNOWN;
902902
}
903903

904-
float RescaleMetric(int currentmethod, float value)
904+
float MetricRescale(int currentmethod, float value)
905905
{
906-
float k1, k0;
907-
906+
float k1;
907+
908908
k1 = 1.0f;
909-
k0 = 0.0f;
910909
switch (currentmethod)
911910
{
912911
case MSE:
@@ -918,8 +917,7 @@ float RescaleMetric(int currentmethod, float value)
918917
value = sqrt(value);
919918
value = sqrt(value);
920919
value -= 1.0f;
921-
k1 = 0.25f;
922-
k0 = 0.0f;
920+
k1 = 0.29f;
923921
}
924922
else
925923
{
@@ -928,14 +926,13 @@ float RescaleMetric(int currentmethod, float value)
928926
break;
929927
case PSNR:
930928
value = sqrt(value);
931-
k1 = 0.87f;
932-
k0 = -4.70f;
929+
value -= 5.0f;
930+
k1 = 0.557f;
933931
break;
934932
case COR:
935933
value = MetricSigma(value);
936934
value = MetricSigma(value);
937935
k1 = 1.0f;
938-
k0 = 0.0f;
939936
break;
940937
case MSEF:
941938
if (value > 0.0f)
@@ -945,7 +942,6 @@ float RescaleMetric(int currentmethod, float value)
945942
value = sqrt(value);
946943
value -= 1.0f;
947944
k1 = 0.5f;
948-
k0 = 0.0f;
949945
}
950946
else
951947
{
@@ -956,32 +952,26 @@ float RescaleMetric(int currentmethod, float value)
956952
value = MetricSigma(value);
957953
value = MetricSigma(value);
958954
value = MetricSigma(value);
959-
k1 = 1.51f;
960-
k0 = 0.0f;
955+
k1 = 1.57f;
961956
break;
962957
case MS_SSIM:
963958
value = MetricSigma(value);
964959
value = MetricSigma(value);
965960
k1 = 1.59f;
966-
k0 = 0.0f;
967961
break;
968962
case VIFP1:
969963
value = MetricSigma(value);
970964
value = MetricSigma(value);
971-
k1 = 1.06f;
972-
k0 = 0.0f;
965+
k1 = 1.10f;
973966
break;
974967
case SMALLFRY:
975968
value *= 0.01f;
976969
value -= 0.8f;
977970
k1 = 3.0f;
978-
k0 = 0.0f;
979971
break;
980972
case SHARPENBAD:
981-
value = sqrt(value);
982973
value = MetricSigma(value);
983-
k1 = 1.0f;
984-
k0 = 0.0f;
974+
k1 = 1.46f;
985975
break;
986976
case NHW:
987977
if (value > 0.0f)
@@ -990,8 +980,7 @@ float RescaleMetric(int currentmethod, float value)
990980
value = sqrt(value);
991981
value = sqrt(value);
992982
value -= 1.0f;
993-
k1 = 0.333f;
994-
k0 = 0.0f;
983+
k1 = 0.342f;
995984
}
996985
else
997986
{
@@ -1000,7 +989,6 @@ float RescaleMetric(int currentmethod, float value)
1000989
break;
1001990
}
1002991
value *= k1;
1003-
value += k0;
1004992

1005993
return value;
1006994
}
@@ -1120,30 +1108,30 @@ float MetricCalc(int method, unsigned char *image1, unsigned char *image2, int w
11201108
break;
11211109
case SSIMFRY:
11221110
tmetric = iqa_ssim(image1, image2, width, height, width * components, 0, 0);
1123-
diff = RescaleMetric(SSIM, tmetric);
1111+
diff = MetricRescale(SSIM, tmetric);
11241112
tmetric = metric_smallfry(image1, image2, width, height);
1125-
diff += RescaleMetric(SMALLFRY, tmetric);
1113+
diff += MetricRescale(SMALLFRY, tmetric);
11261114
diff *= 0.5f;
11271115
break;
11281116
case SSIMSHBAD:
11291117
tmetric = iqa_ssim(image1, image2, width, height, width * components, 0, 0);
1130-
diff = RescaleMetric(SSIM, tmetric);
1118+
diff = MetricRescale(SSIM, tmetric);
11311119
tmetric = metric_sharpenbad(image1, image2, width, height, 1);
1132-
diff += RescaleMetric(SHARPENBAD, tmetric);
1120+
diff += MetricRescale(SHARPENBAD, tmetric);
11331121
diff *= 0.5f;
11341122
break;
11351123
case SUMMET:
11361124
default:
11371125
tmetric = iqa_ssim(image1, image2, width, height, width * components, 0, 0);
1138-
tm[0] = RescaleMetric(SSIM, tmetric);
1126+
tm[0] = MetricRescale(SSIM, tmetric);
11391127
tmetric = metric_smallfry(image1, image2, width, height);
1140-
tm[1] = RescaleMetric(SMALLFRY, tmetric);
1128+
tm[1] = MetricRescale(SMALLFRY, tmetric);
11411129
tmetric = metric_sharpenbad(image1, image2, width, height, 1);
1142-
tm[2] = RescaleMetric(SHARPENBAD, tmetric);
1130+
tm[2] = MetricRescale(SHARPENBAD, tmetric);
11431131
tmetric = metric_nhw(image1, image2, width, height);
1144-
tm[3] = RescaleMetric(NHW, tmetric);
1132+
tm[3] = MetricRescale(NHW, tmetric);
11451133
tmetric = iqa_vifp1(image1, image2, width, height, width * components, 0, 0);
1146-
tm[4] = RescaleMetric(VIFP1, tmetric);
1134+
tm[4] = MetricRescale(VIFP1, tmetric);
11471135
diff = waverage(tm, 5);
11481136
break;
11491137
}
@@ -1246,7 +1234,7 @@ int compareFromBuffer(int method, unsigned char *imageBuf1, long bufSize1, unsig
12461234
// Calculate and print comparison
12471235
diff = MetricCalc(method, image1, image2, width1, height1, components);
12481236
if (umscale)
1249-
diff = RescaleMetric(method, diff);
1237+
diff = MetricRescale(method, diff);
12501238
if (printPrefix)
12511239
printf("%s: ", MetricName(method));
12521240
printf("%f", diff);

src/jmetrics.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define JMETRICS_H
2222

2323
#ifndef JMVERSION
24-
#define JMVERSION "2.6.3"
24+
#define JMVERSION "2.6.4"
2525
#endif
2626

2727
#define MIN(a, b) ((a) < (b) ? (a) : (b))
@@ -203,7 +203,7 @@ int parseSubsampling(const char *s);
203203
enum QUALITY_PRESET parseQuality(const char *s);
204204
float setTargetFromPreset(int preset);
205205
enum METHOD parseMethod(const char *s);
206-
float RescaleMetric(int currentmethod, float value);
206+
float MetricRescale(int currentmethod, float value);
207207
char* MetricName(int currentmethod);
208208
float MetricCalc(int method, unsigned char *image1, unsigned char *image2, int width, int height, int components);
209209
float MetricSigma(float cor);

src/jpeg-recompress.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ int main (int argc, char **argv)
326326

327327
// Measure quality difference
328328
metric = MetricCalc(method, originalGray, compressedGray, width, height, 1);
329-
umetric = RescaleMetric(method, metric);
329+
umetric = MetricRescale(method, metric);
330330
info(quiet, MetricName(method));
331331

332332
if (attempt)

src/webp-compress.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ int main (int argc, char **argv)
315315

316316
// Measure quality difference
317317
metric = MetricCalc(method, originalGray, compressedGray, width, height, 1);
318-
umetric = RescaleMetric(method, metric);
318+
umetric = MetricRescale(method, metric);
319319
info(quiet, MetricName(method));
320320

321321
if (attempt)

0 commit comments

Comments
 (0)