Post · 8 min read· pp. 354–358

06-17-09 - DXTC More Followup

I finally came back to DXTC and implemented some of the new slightly different techniques. ( summary of my old posts )

See the : NVidia Article or NVTextureTools Wiki for details.

Briefly :

DXT1 = my DXT1 encoder with annealing. (version reported here is newer and has some more small improvements; the RMSE's are slightly better than last time). DXT1 is 4 bits per pixel (bpp)

Humus BC4BC5 = Convert to YCoCg, Put Y in a single-channel BC4 texture (BC4 = the alpha part of DXT5, it's 4 bpp). Put the CoCg in a two-channel BC5 texture - downsampled by 2X. BC5 is two BC4's stuck together; BC5 is 8 bpp, but since it's downsampled 2x, this is 2bpp per original pixel. The net is a 6 bpp format

DXT5 YCoCg = the method described by JMP and Ignacio. This is 8 bpp. I use arbitrary CoCg scale factors, not the limited ones as in the previously published work.


Here are the results in RMSE (per pixel) : (modified 6-19 with new better results for Humus from improved down filter)

nameDXT1HumusDXT5 YCoCg
kodim01.bmp8.26693.95763.8355
kodim02.bmp5.28262.73562.643
kodim03.bmp4.6442.39532.2021
kodim04.bmp5.38892.56192.4477
kodim05.bmp9.57394.68234.5595
kodim06.bmp7.10533.45433.2344
kodim07.bmp5.62572.68392.6484
kodim08.bmp10.21655.05814.8709
kodim09.bmp5.21422.5192.4175
kodim10.bmp5.15472.54532.3435
kodim11.bmp6.6153.12462.9944
kodim12.bmp4.71842.28112.1411
kodim13.bmp10.80095.25255.0037
kodim14.bmp8.27393.98593.7621
kodim15.bmp5.53882.84152.5636
kodim16.bmp5.01532.30282.2064
kodim17.bmp5.48832.79812.5511
kodim18.bmp7.98094.02733.8166
kodim19.bmp6.56023.29193.204
kodim20.bmp5.35343.08382.6225
kodim21.bmp7.06913.50693.2856
kodim22.bmp6.38773.52223.0243
kodim23.bmp4.85593.0452.4027
kodim24.bmp8.42615.0463.8599
clegg.bmp14.653923.541210.4535
FRYMIRE.bmp6.093320.09765.806
LENA.bmp7.01775.54424.5596
MONARCH.bmp6.55163.20123.4715
PEPPERS.bmp5.85964.40643.4824
SAIL.bmp8.34673.75143.731
SERRANO.bmp5.94417.41413.9181
TULIPS.bmp7.6023.67934.119
lena512ggg.bmp4.81372.08572.0857
lena512pink.bmp4.56072.63872.3724
lena512pink0g.bmp3.72973.85343.1756
linear_ramp1.BMP1.34880.86261.1199
linear_ramp2.BMP1.28430.77671.0679
orange_purple.BMP2.88413.70191.9428
pink_green.BMP3.18171.5042.7461

And here are the results in SSIM :

Note this is an "RGB SSIM" computed by doing :

SSIM_RGB = ( SSIM_R * SSIM_G ^2 * SSIM_B ) ^ (1/4)

That is, G gets 2X the weight of R & B. The SSIM is computed at a scale of 6x6 blocks which I just randomly picked out of my ass.

I also convert the SSIM to a "percent similar". The number you see below is a percent - 100% means perfect, 0% means completely unrelated to the original (eg. random noise gets 0%). This percent is :

SSIM_Percent_Similar = 100.0 * ( 1 - acos( ssim ) * 2 / PI )

I do this because the normal "ssim" is like a dot product, and showing dot products is not a good linear way to show how different things are (this is the same reason I show RMSE instead of PSNR like other silly people). In particular, when two signals are very similar, the "ssim" gets very close to 0.9999 very quickly even though the differences are still pretty big. Almost any time you want to see how close two vectors are using a dot product, you should do an acos() and compare the angle.

nameDXT1HumusDXT5 YCoCg
kodim01.bmp84.085192.625392.7779
kodim02.bmp82.202991.723990.5396
kodim03.bmp85.267892.904293.2512
kodim04.bmp83.491492.571492.784
kodim05.bmp83.607592.277992.4083
kodim06.bmp85.060892.667493.2357
kodim07.bmp85.370493.255193.5276
kodim08.bmp84.582792.430392.7742
kodim09.bmp84.727992.991293.5035
kodim10.bmp84.651392.8193.3999
kodim11.bmp84.032992.524892.9252
kodim12.bmp84.855892.827293.4733
kodim13.bmp83.614992.268992.505
kodim14.bmp82.644192.150192.1635
kodim15.bmp83.69392.002892.8509
kodim16.bmp85.128693.16293.6118
kodim17.bmp85.178693.178893.623
kodim18.bmp82.981792.114192.1309
kodim19.bmp84.475692.770293.0441
kodim20.bmp87.054990.525393.2088
kodim21.bmp84.254992.223692.8971
kodim22.bmp82.649791.030291.9512
kodim23.bmp84.283492.441792.4611
kodim24.bmp84.657192.370493.2055
clegg.bmp77.496470.153383.8049
FRYMIRE.bmp91.329472.252787.6232
LENA.bmp77.155680.791285.2508
MONARCH.bmp83.928292.510691.6676
PEPPERS.bmp81.601188.788789.0931
SAIL.bmp83.235992.497492.4144
SERRANO.bmp89.09575.755990.7327
TULIPS.bmp81.553590.830289.6292
lena512ggg.bmp86.683695.006395.0063
lena512pink.bmp86.370192.184392.9524
lena512pink0g.bmp89.999579.946184.3601
linear_ramp1.BMP92.162994.923193.5861
linear_ramp2.BMP92.833896.139794.335
orange_purple.BMP89.070791.637292.1934
pink_green.BMP87.458993.570288.4219

Conclusion :

DXT5 YCoCg and "Humus" are both significantly better than DXT1.

Note that DXT5-YCoCg and "Humus" encode the luma in exactly the same way. For gray images like "lena512ggg.bmp" you can see they produce identical results. The only difference is how the chroma is encoded - either a DXT1 block (+scale) at 4 bpp, or a downsampled 2X BC4 block at 2 bpp.

In RGB RMSE , DXT5-YCoCg is measurably better than Humus-BC4BC5 , but in SSIM they are are nearly identical. This is because almost all of the RMSE loss in Humus comes from the YCoCg lossy color conversion and the CoCg downsampling. The actual BC4BC5 compression is very near lossless. (as much as I hate DXT1, I really like BC4 - it's very easy to produce near optimal output, unlike DXT1 where you have to run a really fancy compressor to get good output). The CoCg loss hurts RMSE a lot, but doesn't hurt actual visual quality or SSIM much in most cases.

In fact on an important class of images, Humus actually does a lot better than DXT5-YCoCg. That class is simple smooth ramp images, which we use very often in the form of lightmaps. The test images at the bottom of the table (linear_ramp and pink_green) show this.

On a few images where the CoCg downsample kills you, Humus does very badly. It's bad on orangle_purple because that image is specifically designed to be primarily in Chroma not Luma ; same for lena512pink0g.bmp ; note that normal chroma downsampling compressors like JPEG have this same problem. You could in theory choose a different color space for these images and use a different reconstruction shader.

Since Humus is only 6 bpp, size is certainly not a reason to prefer DXT1 over it. However, it does require two texture fetches in the shader, which is a pretty big hit. (BTW the other nice thing about Humus is that it's already down-sampled in CoCg, so if you are using something like a custom JPEG in YCoCg space with downsampled CoCg - you can just directly transcode that into Humus BC4BC5, and there's no scaling up or down or color space changes in the realtime recompress). I think this is probably what will be in Oodle because I really can't get behind any other realtime recompress.


I also tried something else, which is DXT1 optimized for SSIM. The idea is to use a little bit of neighbor information. The thing is, in my crazy DXT1 encoder, I'm just trying various end points and measuring the quality of each choice. The normal thing to do it to just take the MSE vs the original, but of course you could do other error metrics.

One such error metric is to decompress the block you're working on into its context - decompress into a chunk of neighbors that have already been DXT1 compressed & decompressed as well. Then compare that block and its neighbors to the original image in that neighborhood. In my case I used 2 pixels around the block I was working on, making a total region of 8x8 pixels (with the 4x4 DXT1 block in the middle).

You then compare the 8x8 block to the original image and try to optimize that. If you just used MSE in this comparison, it would be the same as before, but you can use other things. For example, you could add a term that penalizes not changes in values, but changes in *slope*.

Another approach would be to take the DCT of the 8x8 block and the DCT of the 8x8 original. If you then just take the L2 difference in DCT domain, that's no different than the original method, because the DCT is unitary. But you can apply non-uniform quantizers at this step using the JPEG visual quantization weights.

The approach I used was to use SSIM (using a 4x4 SSIM block) on the 8x8 windows. This means you are checking the error not just on your block, but on how your block fits into the neighborhood.

For example if the original image is all flat color - you want the output to be all flat color. Just using MSE won't give you that, eg. MSE considers 4444 -> 3535 to be just as good as 4444 -> 5555 , but we know the latter is better.

This does in fact produce slightly better looking images - it hurts RMSE of course because you're no longer optimizing for RMSE.