-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YCoCg Heuristics #258
Comments
Sounds interesting! I think lossless WebP optionally does a SubtractGreen transform, which transforms R,G,B to R-G,G,B-G. Maybe that also makes sense to do. |
I analyzed the 3 transforms on dice: R-G,G,B-G seems good because it eliminates the white dots on the dice from the R and B components. It seems that there is quite a room for improvement here for some specific images, even more than what I originally expected! EDIT: I made a mistake in the G,R-G,B-G test, leading to a invalid file. Corrected now! |
I'm implementing a PlanePermute transformation with optional "subtract one channel from the others". For now, the encoder will not use it by default (just use YCoCg), unless you manually disable YCoCg, then it transforms R,G,B to G,R-G,B-G. Subtracting green usually seems to be a good idea (compared to just keeping RGB in whatever order), and encoding green first makes sense since it contributes most to luma. If on some particular image, something like B, G-B, R-B turns out to be better, the bitstream will support that (and the decoder can decode it), but the encoder for now just never does that. (This transform could also be useful to reorder the planes in RGBG images) |
plane permute/subtract (cf #258) some decoder fuzzing
Yeah, the plane ordering might be useful for RGGB purpose. Also, the subtract green light might be useful too but I'm not sure because average value between RGB planes are not the same. |
So, the format supports everything we want: RGB, YCoCg, channel permutation and subtracting one channel from the others. From the decoder / format spec perspective, this is "done". From the encoder perspective, there's the matter of deciding which color transform(s) to apply; currently it just always does YCoCg except if you specify |
@DarkZeros Do you have an idea of a simple encoder heuristic to decide which color transform to use? Suppose it's OK to actually do a few different transforms (e.g. YCoCg, G(R-G)(B-G), GRB), but it's not OK to do any real encoding. Is there some kind of cheap way to estimate the amount of decorrelation? Perhaps just compare the total of the absolute values of the pixels in the 'chroma' channels, the idea being that values close to zero mean better compression / better decorrelation? |
@jonsneyers Hi, I didn't have enough time to invest in this proyect, sry for that... Maybe the most simple way forward is performing a downscaled R0 encoding as a quick test of the best transform. |
@jonsneyers Ok found out a very good YCoCg heuristic. The predictor heuristic. The predictor seems to be accurate most of the time. And when is not is in those "close cases". I have a dataset clearly biased towards YCoCg (kodak dataset + icons), even though: Images best YCoCg: 1365/2181 I will keep on investigating on the best predictor, and supply a Pull request. |
I noticed some images are compressed further by disabling the YCoCg transform. A clear example https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png
My analysis lead me to the correlation between colours as the culprit. YCoCg is useful because it achieves decorrelation for most real life images. Leading to a efficient MANIAC compresion later on. However artificial images tend to have pure colours in RGB space. Therefore RGB space is more "decorrelated" than YCoCg.
IE:
Dice histogram:
http://i.snag.gy/bChdw.jpg
Kodim1 histogram:
http://i.snag.gy/k0ZnR.jpg
I am in the process of writing some heuristics based on image color histograms/correlations. Just made this issue to notify you about it, and any comment or suggestions are also welcome.
The text was updated successfully, but these errors were encountered: