aous72 / OpenJPH

Open-source implementation of JPEG2000 Part-15 (or JPH or HTJ2K)
BSD 2-Clause "Simplified" License
196 stars 47 forks source link

ojph error 0x20000003 #29

Closed Jamaika1 closed 4 years ago

Jamaika1 commented 4 years ago

What is this message? How to bypass it when converting with file YUV to JPH and then to PPM? ojph error 0x20000003 at ojph_expand.cpp:145: To save an image to ppm, all the components must have the downsampling ratio

aous72 commented 4 years ago

Hi Jamaika1,

Thank you for your post.

The main reason is that I did not want to fiddle with the subsampling in YUV files; so the code currently expects YUV and supplies back YUV if 4:2:2 and 4:2:0 subsampling is used. For 4:4:4 YUV to ppm, there is the issue of color transform; with small changes to code, it might work.

The reasons are:

  1. It is not clear what the relative position of the UV components on the canvas; in other words, what is location of the top-left sample of U? is it (0,0), (0.5, 0.5), or (0.5, 0), or even (1,1). This influences the design of the downsampling and interpolation filters; see next. The location has to be recorded in the CRG marker of JPEG2000, which I do not support.
  2. if the location is known, there are many ways to design these downsampling and interpolation filters. There is also the possibility of using more sophisticated approaches for interpolation, such as bilateral or guided filtering that are edge-aware (interpolation does not cross image edges), using the Y component as a guide. This should produce better results around image discontinuities (i.e., strong edges).

The main objective is to provide something that is correct, avoiding wrong decisions about YUV.

I know you have been using the code to test new technologies. I am happy to help with technical information. For visual comparison, I suggest using Kakadu because it employs visual weighting, which makes images look better by a small amount, especially at lower bit rates; the PSNR is reduced as a result. Let me know if you need help there. I plan to add visual weighting at some point, but it is not that straight forward.

Hope this is useful.

Kind regards, Aous.

Jamaika1 commented 4 years ago

The main reason is that I did not want to fiddle with the subsampling in YUV files; so the code currently expects YUV and supplies back YUV if 4:2:2 and 4:2:0 subsampling is used. For 4:4:4 YUV to ppm, there is the issue of color transform; with small changes to code, it might work.

Thanks for the quick reply I don't understand something. I'm amateur.

When the input file is a YUV file, these arguments need to be
 supplied:
 -dims      {x,y} x is image width, y is height
 -num_comps number of components
 -signed    a list of true or false parameters, one for each component
 -bit_depth a list of bit depth values, one per component
 -downsamp  {x,y},{x,y},...,{x,y} a list of x,y points, one for each
            component

I use command and understand that receive yuv422p. Decoder doesn't have to convert rgb24. cjpegHTJ2K_j2c.exe -i image_yuv422p.yuv -o image_yuv422p.j2c -dims {1563,1558} -num_comps 3 -signed false -bit_depth 8 -downsamp {1,1},{2,2},{2,2} -block_size {64,64} -precincts {128,128},{256,256} -prog_order CPRL -qstep 0.048

aous72 commented 4 years ago

I guess you figured out the answer on your own. Good!

ojph_expand -i image_yuv422p.j2c -o recon.yuv