uclouvain / openjpeg

Official repository of the OpenJPEG project
Other
976 stars 456 forks source link

Tif to JPEG2000 : issue with colours on opj_compress ? #1040

Open symac opened 7 years ago

symac commented 7 years ago

Trying to convert files from tiff to jpeg2000 using opj_compress I have an issue regarding the colours produced. My source file is B335222107_10_13_10_05_001.tif (~19Mo) and I am running the following command :

opj_compress -i B335222107_10_13_10_05_001.tif -o B335222107_10_13_10_05_001.jp2

The file I get, B335222107_10_13_10_05_001.jp2 (~12Mo) seems to be different than the original even if I expect a lossless conversion by using this command. When looking at both images (left is JP2, right is TIFF), one is darker than the other:

capture du 2017-11-03 17-13-55

Is this an issue with the software or an issue with the way I am running it? My original tiff seems not to be well formatted as it produces an issue with opj_compress : TIFFFetchNormalTag: Warning, Incompatible type for "RichTIFFIPTC"; tag ignored so that might be an explanation but I can't understand the link between this message and my colour error.

szukw000 commented 6 years ago

@symac ,

I used GraphicsMagick and ImageMagick for both the JP2 and the TIFF file. I am fairly sure that both images have the same 'dark' color. Or I am 'color-blind'.

The first difference might be: I used openjpeg of today (2017-11-05). The second difference might be: tiffinfo B335222107_10_13_10_05_001.tif

<?xpacket end="w"?> Photoshop Data: , 2244 bytes EXIFIFDOffset: 0x128a11c ICC Profile: , 560 bytes TIFF Directory at offset 0x128a11c (19439900) ExifVersion: 0x30,0x32,0x33,0x30 ColorSpace: 65535 PixelXDimension: 2112 PixelYDimension: 3064

'converttif.c' ignores an ICC Profile in TIFF files.

Q1. Which openjpeg library did you use? Q2. Which image program did you use for the TIFF file, the JP2 file and the PNG files?

winfried

Jamaika1 commented 6 years ago

Hi symac

_Is this an issue with the software or an issue with the way I am running it? My original tiff seems not to be well formatted as it produces an issue with opjcompress : TIFFFetchNormalTag: Warning, Incompatible type for "RichTIFFIPTC"; tag ignored so that might be an explanation but I can't understand the link between this message and my colour error. It all depends on how you use the viewer. Does the viewer recalculate the ICC parameters or call the colormatrix sRGB constant. This is particularly noticeable for 16bit photo files with colormatrix larger than bt709. As for Exif, XMP, IPTC data. Errors are in the free software libtiff. When you buy a paid converter for JPEG2000, all this data will be transferred to JP2, and the ICC profile will be converted to info colormatrix in the JP2 container.

symac commented 6 years ago

@szukw000 :

@Jamaika1 this project is my first try with JP2, I am not aware of all these details and that might explain what is wrong then. Is there no way to get a JP2 picture that is exactly the same as my TIFF source file using only Open source tools?

szukw000 commented 6 years ago

@symac , I try to use always the latest library version (bug repair). This means I use openjpeg-2.3.0.

Using gimp-2.8.22 with LINUX I get:

gimp B335222107_10_13_10_05_001.jp2

WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! YOUR CODE IS RELYING ON DEPRECATED FUNCTIONALTIY IN THE JASPER LIBRARY. THIS FUNCTIONALITY WILL BE REMOVED IN THE NEAR FUTURE. PLEASE FIX THIS PROBLEM BEFORE YOUR CODE STOPS WORKING! The specific problem is as follows: negative buffer size for jas_stream_memopen

Using IrfanView with WIN7 it seems there is no difference between TIF and JP2.

winfried

comstock commented 6 years ago

The problem is that the TIFF image has an embedded ICC color profile (Adobe RGB) and opj_compress fails to transfer the display profile from the source image (the TIFF with the Adobe RGB profile) to the output JP2 image.

Instead, _opjcompress mistakenly tags the output JP2 file with an sRGB profile -- JPEG2000's default, 'enumerated', color profile.

I just posted an issue on this same topic. See: 1058