GammaUNC / FasTC

A fast texture compressor for various formats
Apache License 2.0
248 stars 46 forks source link

Investigate difference between PVRTexTool PSNR calculation and ours. #7

Open Mokosha opened 11 years ago

Mokosha commented 11 years ago

For example:

[pavel@Zombie-MBP ~/Projects/TexComp/build]$ CLTool/tc -q 0 -t 32 -j 32 ../test/kodim05.png
Compression time: 3666.615 ms
PSNR: 42.140

However, in PVRTexTool, we get:

Red Green Blue All
PSNR: 45.15 45.40 45.02 44.18
Ethatron commented 10 years ago

He calculates the euclidean distance of the 3D vector and then 1D PSNR on that: diff_for_psnr=sqrt(diff_r^2+diff_g^2+diff_b^2)

Mokosha commented 10 years ago

I'm having a hard time reproducing the results even using that method. If I understand you correctly, I need to change my PSNR code from this to:

double t = 0;
for(uint32 c = 0; c < 3; c++) {
  double diff = (r[3] * r[c] - u[3] * u[c]);
  t += diff * diff;
}
mse += sqrt(t);

...?

Mokosha commented 10 years ago

Here are the two images in question, I fixed a small bug in my PSNR calculation, so that it now reports RGB PSNR weighted by alpha. The two images from the example above are the following:

Raw: kodim05

BPTC Compressed: kodim05-bptc

The results from FasTC and the Mali ASTC encoder are:

$ ./astcenc -compare kodim05.png kodim05-bptc.png -showpsnr
PSNR (LDR-RGBA): 43.378936 dB
Alpha-Weighted PSNR: 43.378936 dB
PSNR (LDR-RGB): 42.159781 dB

$ CLTool/compare kodim05-bptc.png ../test/kodim05.png 
PSNR: 42.140
SSIM: 0.996602052

This makes sense since kodim05-bptc.png has a few non max-alpha pixels (since it provided better compression overall), and we're using a slightly different algorithm than the ASTC encoder. However, it doesn't account for the multiple dBs of error vs. PVRTexTool.