One thing I noticed is that the lsqr fit really doesn't do much other than shift an end point by one. That is, the end points are in 565 already, you can do this nice optimization in floats, but when you quantize back to 565 you pretty much always hit the point you started with or at most a step of 1.
So the new "CB" modes are :
CB 1 = just 4 means then lsqr fit , faster than Squish, a bit slower than ryg. Quality is roughly competitive with Squish, but they have different strengths and weakness, so taking the best of the two might be reasonable. Squish never beats "CB 1" by a lot, but "CB 1" kills it on the weird "frymire" image.
CB 2 = CB 1 followed by simulated annealing.
CB 3 = Very slow heavy optimization. This is an attempt to see what "optimal" would get you. It tries "CB 2" and then it also tries using all 16 colors in the block as end points, so 16*16 trials, does the lsqr optimization on each trial, and then anneals the best of those. There are still various other things to try that might find a better result, but this is already pretty crazy slow. This is too slow to use in real production, the idea is simply to get an idea of how close "CB 2" is to optimal. Of course "CB 3" could still be far off optimal, I'm only conjecturing that it's close.
One of the interesting things to look at is the curve of diminishing returns from CB1 to 2 to 3. In most cases there's only a small improvement from 2 to 3, but there are exceptions, mainly in the weird degenerate images. kodim02 is one case (this is a photo but it's almost all red), and frymire of course. That meets expectations. On noisy natural images, the cluster of colors is pretty close to Gaussian noise, which works well with the PCA single line fit and the least-squares contiuous distribution approximation. On weird images with degenerate cases there can be stranger optimal solutions (for example : putting one of the color end points outside of the volume of original colors, so that one of the interpolated 1/3 colors can hit a certain value more precisely).
ADDENDUM : you might validly object and ask why the annealing is not getting closer to the global optimum. There are some approximations in the annealing that are hurting. For one thing I only try wiggling the ends by 1 step in 565. Then I don't really run it for very long, so it doesn't have a chance to make big walks and get to really different solutions. All it can really do is local optimizations with small steps to tunnel past local barriers to find better minima - it's not trying huge steps to other parts of the solution space. Theoretically if I ran a much longer annealing schedule with more time spent at higher temperatures it would do a better job of finding the global minimum. But I'm happy with this approach - the annealing is just an improved local optimization that steps bast small barriers, and to find drastically different global solutions I have to seed the trial differently.
The new numbers : (RMSE per pixel)
file | CB 1 | CB 2 | CB 3 | Squish opt | Squish | ryg | D3DX8 | FastDXT |
kodim01.bmp | 8.447 | 8.3145 | 8.2678 | 8.2829 | 8.3553 | 8.9185 | 9.8466 | 9.9565 |
kodim02.bmp | 5.6492 | 5.4759 | 5.2864 | 6.1079 | 6.2876 | 6.8011 | 7.4308 | 8.456 |
kodim03.bmp | 4.7533 | 4.6776 | 4.6591 | 4.7869 | 4.9181 | 5.398 | 6.094 | 6.4839 |
kodim04.bmp | 5.5234 | 5.4286 | 5.3967 | 5.6978 | 5.8116 | 6.3424 | 7.1032 | 7.3189 |
kodim05.bmp | 9.7619 | 9.6171 | 9.5654 | 9.6493 | 9.7223 | 10.2522 | 11.273 | 12.0156 |
kodim06.bmp | 7.2524 | 7.1395 | 7.1086 | 7.15 | 7.2171 | 7.6423 | 8.5195 | 8.6202 |
kodim07.bmp | 5.7557 | 5.6602 | 5.634 | 5.784 | 5.8834 | 6.3181 | 7.2182 | 7.372 |
kodim08.bmp | 10.3879 | 10.2587 | 10.2056 | 10.2401 | 10.3212 | 10.8534 | 11.8703 | 12.2668 |
kodim09.bmp | 5.3242 | 5.2477 | 5.2247 | 5.2935 | 5.3659 | 5.7315 | 6.5332 | 6.6716 |
kodim10.bmp | 5.2564 | 5.1818 | 5.1657 | 5.2478 | 5.3366 | 5.7089 | 6.4601 | 6.4592 |
kodim11.bmp | 6.7614 | 6.6503 | 6.6139 | 6.731 | 6.8206 | 7.3099 | 8.1056 | 8.2492 |
kodim12.bmp | 4.8159 | 4.747 | 4.7308 | 4.7968 | 4.8718 | 5.342 | 6.005 | 6.0748 |
kodim13.bmp | 11.0183 | 10.8489 | 10.7894 | 10.8684 | 10.9428 | 11.6049 | 12.7139 | 12.9978 |
kodim14.bmp | 8.4325 | 8.3105 | 8.2723 | 8.3062 | 8.3883 | 8.8656 | 9.896 | 10.8481 |
kodim15.bmp | 5.6871 | 5.5891 | 5.548 | 5.8304 | 5.9525 | 6.3297 | 7.3085 | 7.4932 |
kodim16.bmp | 5.1351 | 5.0439 | 5.0274 | 5.065 | 5.1629 | 5.5526 | 6.3361 | 6.1592 |
kodim17.bmp | 5.5999 | 5.5146 | 5.4976 | 5.509 | 5.6127 | 6.0357 | 6.7395 | 6.8989 |
kodim18.bmp | 8.1345 | 8.0103 | 7.9791 | 7.9924 | 8.0897 | 8.6925 | 9.5357 | 9.7857 |
kodim19.bmp | 6.6903 | 6.5979 | 6.5645 | 6.5762 | 6.652 | 7.2684 | 7.9229 | 8.0096 |
kodim20.bmp | 5.4532 | 5.3825 | 5.3582 | 5.4568 | 5.5303 | 5.9087 | 6.4878 | 6.8629 |
kodim21.bmp | 7.2207 | 7.1046 | 7.0718 | 7.1351 | 7.2045 | 7.6764 | 8.4703 | 8.6508 |
kodim22.bmp | 6.52 | 6.4191 | 6.3933 | 6.4348 | 6.5127 | 7.0705 | 8.0046 | 7.9488 |
kodim23.bmp | 4.9599 | 4.8899 | 4.8722 | 4.9063 | 5.0098 | 5.3789 | 6.3057 | 6.888 |
kodim24.bmp | 8.5761 | 8.4633 | 8.4226 | 8.4299 | 8.5274 | 8.9206 | 9.9389 | 10.5156 |
clegg.bmp | 14.8934 | 14.8017 | 14.6102 | 14.9736 | 15.2566 | 15.7163 | 21.471 | 32.7192 |
FRYMIRE.bmp | 7.4898 | 7.3461 | 6.0851 | 10.7105 | 12.541 | 12.681 | 16.7308 | 28.9283 |
LENA.bmp | 7.1286 | 7.0286 | 6.9928 | 7.1432 | 7.2346 | 7.6053 | 8.742 | 9.5143 |
MONARCH.bmp | 6.6617 | 6.5616 | 6.5281 | 6.5567 | 6.6292 | 7.0313 | 8.1053 | 8.6993 |
PEPPERS.bmp | 6.0418 | 5.9523 | 5.8026 | 6.4036 | 6.5208 | 6.9006 | 8.1855 | 8.8893 |
SAIL.bmp | 8.4339 | 8.3077 | 8.2665 | 8.3254 | 8.3903 | 8.9823 | 9.7838 | 10.5673 |
SERRANO.bmp | 6.7347 | 6.2445 | 5.9454 | 6.3524 | 6.757 | 7.0722 | 9.0549 | 18.3631 |
TULIPS.bmp | 7.6491 | 7.5406 | 7.5065 | 7.5805 | 7.656 | 8.0101 | 9.3817 | 10.5873 |
lena512ggg.bmp | 4.8961 | 4.8395 | 4.8241 | 4.8426 | 4.915 | 5.1986 | 6.0059 | 5.5247 |
lena512pink.bmp | 4.6736 | 4.5922 | 4.5767 | 4.5878 | 4.6726 | 5.0987 | 5.8064 | 5.838 |
lena512pink0g.bmp | 3.7992 | 3.7523 | 3.7455 | 3.7572 | 3.8058 | 4.2756 | 5.0732 | 4.8933 |
linear_ramp1.BMP | 1.5607 | 1.348 | 1.3513 | 1.4035 | 2.1243 | 2.0939 | 2.6317 | 3.981 |
linear_ramp2.BMP | 1.5097 | 1.2772 | 1.2772 | 1.3427 | 2.3049 | 1.9306 | 2.5396 | 4.0756 |
orange_purple.BMP | 2.9842 | 2.9048 | 2.9074 | 2.9125 | 3.0685 | 3.2684 | 4.4123 | 7.937 |
pink_green.BMP | 3.2837 | 3.2041 | 3.2031 | 3.2121 | 3.3679 | 3.7949 | 4.5127 | 7.3481 |
sum : | 250.8565 | 246.2747 | 243.2776 | 252.3828 | 259.7416 | 275.5826 | 318.5562 | 370.8691 |
No comments:
Post a Comment