-
Notifications
You must be signed in to change notification settings - Fork 57
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
Can't read gray jpg2000 file #9
Comments
Not sure if this bug is related to these warnings I get from openjpg-tools from your file:
|
This is happening inside FileFormatReader as it is accessing the Debugging for your file I get that it has read the arrays:
so something looks not right there.. back in Any idea of what could be wrong? To the untrained eye it seems to think it is not truly grayscale, but still with 3 components, but they are not the usual RGB, but rather |
If I convert your picture with |
According to IrfanView it is fully white. It makes sense that it is white: in the PDF that contains the problem file (file 001131 from the digitalcorpora size) a shape is created and then that image is rendered with this shape as clipping path. This appears white with Adobe Reader. |
which is consistent with a grayscale picture.. so something is wrong early on in the call to readComponentMappingBox() with for some reason |
No, the length is still 12.. but the second and third component mappings are bogus in the file. I think something is wrong with that map as it's read from the file.. if I replace it with the map |
Checking with Python (or a hex editor) you will find your file says: >>> j = open("350c3f9c-d395-11e6-880f-bbd8fedda5c2.jp2").read(1024)
>>> j.find("\x63\x6d\x61\x70") # COMPONENT_MAPPING_BOX
136
>>> j[135]
'\x14'
>>> length = 0x14
>>> length
20
>>> j[135:135+length]
'\x14cmap\x00\x00\x01\x00\x00\x00\xff6pp\x80\xdd\x00\x00\x00'
>>> cmap = j[135:135+length][8:]
>>> cmap
'\x00\x00\x00\xff6pp\x80\xdd\x00\x00\x00'
>>> len(cmap)
12
>>> struct.unpack(">HBB", cmap[0:4])
(0, 0, 255)
>>> struct.unpack(">HBB", cmap[4:8])
(13936, 112, 128)
>>> struct.unpack(">HBB", cmap[8:])
(56576, 0, 0) (I unpacked according to section 1.5.3.5 [in ISO/IEC 15444-1:2002 T.800](http://www.itu.int/rec/T-REC-T.800-200208-S/en this then defines the
So this means component index
Only value 0 and 1 are defined as types for
Yet it is written as I'm afraid I'm not an expert in JPEG 2000 and get a bit confused.. |
What is confusing is the reference implementation uses signed shorts when the spec says unsigned shorts.. and same for bytes. So there could be multiple sign errors somewhere going unnoticed. |
Best bet is that the JP2 file you sent are written with C code for 3 channels - but as just 1 component is used the mapping for channel 2 and 3 was written with unintialized (e.g. ~random) data. This reference implementation parses according to spec, which says the number of components is defined by the size of the (The spec does not say what to do if there's a mismatch) |
my code:
The output:
`
I'm using version 1.3.0.
(file is a renamed JPEG20000)
According to IrfanView, the file is a JPEG2000 - Wavelet, Grayscale.
The text was updated successfully, but these errors were encountered: