Skip to content
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

Dump image prediction #116

Closed
franfcunha opened this issue Jun 7, 2021 · 7 comments
Closed

Dump image prediction #116

franfcunha opened this issue Jun 7, 2021 · 7 comments
Labels
encoder Related to the libjxl encoder question Further information is requested

Comments

@franfcunha
Copy link

Dear all,

Can anyone clarify me which class code should I change in order to dump/write to file the predicted image by JPEG-XL in modular mode for lossless compression?

Kind regards,
F

@jonsneyers
Copy link
Member

Do you mean the visualization of the predictors that were chosen, as shown on slide 71 of https://docs.google.com/presentation/d/1LlmUR0Uoh4dgT3DjanLjhlXrk_5W2nJBDqDAMbhe8v8/edit#slide=id.ga352fd7e04_0_12 ?

You can get something like that by setting kWantDebug = true in the beginning of jxl/modular/encoding/enc_encoding.cc, and then doing something like benchmark_xl --input=image.png --codec=jxl:m:tortoise:g3 --debug_image_dir=outputdir. This produces debug images per group and per channel (setting g3 makes the groups larger so you don't get too many of them), so you'll have to figure out a way to combine them into a big image.

@jonsneyers jonsneyers added encoder Related to the libjxl encoder question Further information is requested labels Jun 8, 2021
@franfcunha
Copy link
Author

thanks for your answer @jonsneyers! In fact, I am trying to extract the predicted value by JPEG-XL for each pixel, and not the predictor choice itself. According to the overview paper, "(..) when predicting a value in position (x, y), the adaptive predictor looks at the maximum error that each prediction mode would have produced on pixels (x−1, y), (x, y−1) and (x−1, y−1), and chooses the prediction mode that is expected to produce the least amount of error." Based on this, is it possible to access the predicted value at each position?
Thanks

@jonsneyers
Copy link
Member

There's currently no code to dump that, but it could be done. I'm not sure what exactly you would want to see though: the predicted value at every pixel would usually be quite close to the actual value since the prediction happens per pixel (so it sees the corrected values on the top and left). It might be more interesting to do something like "show how the predictor would have completed this subrectangle without further information" (i.e. setting all residuals to zero there).

Also: I don't know what paper you're looking at, but the "adaptive predictor" is not in the spec anymore. There's the weighted predictor, and there are a bunch of other predictors, and the predictor to be used is part of the context model (the MA tree leaf nodes).

@jonsneyers
Copy link
Member

I added a slide (slide number 77) to show some examples of how some of the predictors would work: https://docs.google.com/presentation/d/1LlmUR0Uoh4dgT3DjanLjhlXrk_5W2nJBDqDAMbhe8v8/edit#slide=id.gde87dfbe27_0_140

@franfcunha
Copy link
Author

I really appreciate your feedback and effort on this question. I am now sure that I will be able to extract what I want and I will dig into the code in the next days to dump those predicted samples! :-)

@jonsneyers
Copy link
Member

OK, closing this issue, feel free to reopen if you have further questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
encoder Related to the libjxl encoder question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants