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

Error decode PPM #70

Closed
Jamaika1 opened this issue Sep 15, 2021 · 7 comments
Closed

Error decode PPM #70

Jamaika1 opened this issue Sep 15, 2021 · 7 comments

Comments

@Jamaika1
Copy link
Contributor

67fda0c

htj2k-cjph.exe -i image_21447_24bit.yuv -o image_21447_24bit-jph.j2c -dims {1563,1558} -num_comps 3 -signed false -bit_depth 10 -downsamp {1,1},{2,1},{2,1} -block_size {64,64} -precincts {128,128},{256,256} -prog_order CPRL -reversible true
htj2k-djph.exe -i image_21447_24bit-jph.j2c -o xxx.ppm

ojph error 0x20000003 at ojph_expand.cpp:235: To save an image to ppm, all the components must have the downsampling ratio

dopen_j2c.exe -i image_21447_24bit-jph.j2c -o xxx.ppm

[INFO] Start to read j2k main header (0).
[INFO] Main header has been correctly decoded.
[INFO] No decoded area parameters, set the decoded area to the whole image
[INFO] Header of tile 1 / 1 has been read.
[INFO] Generated Outfile xxx.ppm
decode time: 136 ms

@aous72
Copy link
Owner

aous72 commented Sep 15, 2021

Hi Lucas,

This images has two downsampled components. The only way to save them to ppm is if you interpolate these two components. Then, if you were to interpolate, where do these component sit relative to the first component (the one that is not downsampled); possible answers are: 0,0 or 1,1 or 0.5, 0.5 and many other locations.

We cannot expect a decoder to be able to do all possible imagined tasks. For these tasks, you have to write your own code.

Kind regards,
Aous

@Jamaika1
Copy link
Contributor Author

Jamaika1 commented Sep 15, 2021

Hi Aous
Maybe I'm doing something wrong. What should be sampling for 4: 2: 2?
I'm just thinking. Since openjpeg allows 4: 2: 2 sampling. Maybe there's no blockage there.

Edit: I used your latest grok codecs. Previously, jp2 exif files had blotches. Now I have a mistake, but I will not upset the grok. regards
https://github.com/GrokImageCompression/grok/issues/253
ojph warning 0x00010001 at ojph_block_decoder.cpp:1020: A malformed codeblock that has more than one coding pass, but zero length for 2nd and potential 3rd pass.

[2021-09-15 09:16:31.156] [error] Error in HT block coder
[2021-09-15 09:16:31.156] [error] Failed to decompress tile 0/1
[2021-09-15 09:16:31.156] [error] Failed to decompress JP2 file

@aous72
Copy link
Owner

aous72 commented Sep 15, 2021

You setting is correct. -downsamp {1,1},{2,1},{2,1}.
When YUV is used, OpenJPH store image components as images, no color transform is employed. Also, the .j2c file tells the decoder not use color transform.

I do not know what happens in OpenJPEG; when you save to ppm, II think the result would still be in YUV, not in RGB.
Also not sure if the up-sampling is correct.

@Jamaika1
Copy link
Contributor Author

Jamaika1 commented Sep 15, 2021

When YUV is used, OpenJPH store image components as images, no color transform is employed. Also, the .j2c file tells the decoder not use color transform.

OK. And it generally keeps some subsamling data. For RGB24/yuv444 I have red photos when decoding.

@aous72
Copy link
Owner

aous72 commented Sep 15, 2021

It keeps the sub-sampling data. Like you discovered, it does not perform color transform.

@Jamaika1
Copy link
Contributor Author

OK. Right. There is no info. I should only decode to PPM.

@aous72
Copy link
Owner

aous72 commented Sep 15, 2021

If you encode ppm, decode to ppm. If you encode yuv, decode to yuv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants