Opened 11 years ago
Closed 10 years ago
#5328 closed defect (fixed)
JP2KAK plugin does not handle some 12 bit images correctly
Reported by: | bugbuster | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.11.0 |
Component: | GDAL_Raster | Version: | 1.10.1 |
Severity: | normal | Keywords: | 12bit jp2k |
Cc: |
Description
I just upgraded to GDAL 1.10.1.
I try to convert a 4-band, 12-bit unsigned , tiled, Cycc JP2K image to GTiff.
I observe some discrepancies in the final image with GDAL 1.10.1.
In fact, the problem comes from the JP2KAK plugin, which does not read my 12-bit image correctly.
The JP2K image histogram is not computed in the same way when comparing V1.8.0 and V1.10.1.
In particular, the statistic values given by GDAL V1.10.1 are wierd for a 12 bit image :
Min = 0 Max = 65520
I found a patch in method JP2KAKDataset::DirectRasterIO() (changeset #25136) which modifies the number of bits :
if (precisions[i] == 12) { precisions[i] = 16; }
I commented out these few lines of code and the problem disappeared.
Below are detailled informations about the JP2K image from different GDAL versions.
Gdal V1.8.0 : gdalinfo -hist Snafu.jp2
D:\Data>gdalinfo -hist Snafu.jp2 Driver: JP2KAK/JPEG-2000 (based on Kakadu) Files: Snafu.jp2 Size is 10500, 11098 Coordinate System is `' Corner Coordinates: Upper Left ( 0.0, 0.0) Lower Left ( 0.0,11098.0) Upper Right (10500.0, 0.0) Lower Right (10500.0,11098.0) Center ( 5250.0, 5549.0) Band 1 Block=1024x1024 Type=UInt16, ColorInterp=Red 256 buckets from -4.125 to 2116.13: 7162796 1 2 4 1 5 9 5 ... 117 116 107 108 3395 Overviews: 5250x5549, 2625x2775, 1313x1388, 657x694, 329x347 Image Structure Metadata: NBITS=12 COMPRESSION=JP2000 ...
Gdal V1.10.1 : gdalinfo -hist Snafu.jp2
D:\Data>gdalinfo -hist Snafu.jp2 Driver: JP2KAK/JPEG-2000 (based on Kakadu) Files: Snafu.jp2 Snafu.jp2.aux.xml Size is 10500, 11098 Coordinate System is `' Metadata: Corder=RPCL Corner Coordinates: Upper Left ( 0.0, 0.0) Lower Left ( 0.0,11098.0) Upper Right (10500.0, 0.0) Lower Right (10500.0,11098.0) Center ( 5250.0, 5549.0) Band 1 Block=1024x1024 Type=UInt16, ColorInterp=Red Min=0.000 Max=65520.000 Minimum=0.000, Maximum=65520.000, Mean=4929.701, StdDev=2792.112 256 buckets from -128.471 to 65648.5: 7162797 5 3 14 18 15473 509125 ... 8 5 3 11 2 171 Overviews: 5250x5549, 2625x2775, 1313x1388, 657x694, 329x347 Metadata: STATISTICS_MAXIMUM=65520 STATISTICS_MEAN=4929.7008042976 STATISTICS_MINIMUM=0 STATISTICS_STDDEV=2792.1120699711 Image Structure Metadata: COMPRESSION=JP2000 NBITS=12 .............
Attachments (2)
Change History (5)
comment:1 by , 11 years ago
Summary: | JP2KAK plugin does not handle some 12 bit images → JP2KAK plugin does not handle some 12 bit images correctly |
---|
by , 10 years ago
comment:2 by , 10 years ago
It took me some time to make a small example, as I was working on other stuff.
Attached is a TGZ containing :
- image.jp2 : a small 3-band 12-bit JPEG2000 image
- image.jp2.aux.xml.NOK : image statistics from original gdal V1.10.1 (MAX values are over 212)
- image.jp2.aux.xml.OK : image statistics with patched gdal version
Another attached file contains my proposed patch.
comment:3 by , 10 years ago
Milestone: | → 1.11.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
JPEG2000 image and aux. files