AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
April 2012

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2012.04.24 16:26 "YCbCr/JPEG issue in 4.0.1", by John Evans
2012.04.24 16:44 "Re: YCbCr/JPEG issue in 4.0.1", by Frank Warmerdam
2012.04.24 19:03 "Re: YCbCr/JPEG issue in 4.0.1", by John Evans
2012.04.24 19:19 "Re: YCbCr/JPEG issue in 4.0.1", by Even Rouault
2012.04.27 15:35 "Re: YCbCr/JPEG issue in 4.0.1", by Charles Auer
2012.04.27 17:07 "Re: YCbCr/JPEG issue in 4.0.1", by Joris Van Damme
2012.04.27 18:57 "Re: YCbCr/JPEG issue in 4.0.1", by John Evans
2012.04.28 01:58 "Re: YCbCr/JPEG issue in 4.0.1", by Charles Auer
2012.05.02 09:51 "Re: YCbCr/JPEG issue in 4.0.1", by Charles Auer
2012.05.03 21:58 "Re: YCbCr/JPEG issue in 4.0.1", by Joris Van Damme
2012.04.28 09:28 "Re: YCbCr/JPEG issue in 4.0.1", by Joris Van Damme
2012.04.28 09:46 "Re: YCbCr/JPEG issue in 4.0.1", by Joris Van Damme
2012.04.28 15:10 "Re: YCbCr/JPEG issue in 4.0.1", by Charles Auer
2012.04.28 16:26 "Re: =?windows-1256?q?YCbCr/JPEG_issue_in_4=2E0=2E1=FE?=", by Charles Auer
2012.05.01 12:52 "Re: YCbCr/JPEG issue in 4.0.1", by Joris Van Damme

2012.04.28 15:10 "Re: YCbCr/JPEG issue in 4.0.1", by Charles Auer

Joris: Well, back to the bug reading JPEG
(compression = 6) compressed images using Libtiff 4.0, the problem is
only evident if you read the subsampled YCbCr data directly, doing
resampling and color conversion yourself.

For example, subsampling = [ 2, 2 ]
data should look like this:

Y Y Y Y Cb Cr Y Y Y Y Cb Cr Y Y Y Y Cb
Cr
Y Y Y Y Cb Cr Y Y Y Y Cb Cr Y Y Y Y Cb
Cr
Y Y Y Y Cb Cr Y Y Y Y Cb Cr Y Y Y Y Cb
Cr

but instead you get this:

Y Y Y Y Cb Cr Y Y Y Y Cb Cr Y Y Y Y Cb
Cr 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Y Y Y Y Cb Cr Y Y Y Y Cb Cr Y Y Y Y Cb
Cr 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Y Y Y Y Cb Cr Y Y Y Y Cb Cr Y Y Y Y Cb
Cr 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

You can still recover the image by
ignoring the zeroes and the error message.

As a matter of interest, Joris, OJPEG
(compression = 7) data are read correctly.  Rewriting tif_ojpeg.c was
a tremendous contribution that you made to Libtiff, by the way. Also, I made
a set of YCbCr test images with all possible subsampling values ( [ 1, 1 ],
[ 1 , 2 ], [ 1, 4 ], [ 2, 1 ], [ 2, 2 ], [2, 4 ], [ 4, 1 ], [ 4, 2 ], and [
4, 4 ] ), both uncompressed and LZW compressed, and all of these images are
read correctly.  The problem appears isolated to JPEG (compression = 6)
compressed images.

The easiest work-around right now to
handle JPEG compressed images with Libtiff 4.0 is either:

1. Use TIFFReadRGBAImage

2. Use TIFFReadEncodedStrip or
TIFFReadEncodedTile with JPEGCOLORMODE = 1

Of course, both of these methods output
RGB colors.

Charles







 > Date: Sat, 28 Apr 2012 11:46:15 +0200
> Subject: Re: [Tiff] YCbCr/JPEG issue in 4.0.1
> From: info@awaresystems.be
> To: bumble731@msn.com
> CC: john.evans@mathworks.com; tiff@lists.maptools.org
> 
> Charles,
> 
> > All required support for
> > subsampling and desubsampling as well as any color conversions, is
> > merely part of this.
> 
> I'd like to add this was not meant to be library bashing or trolling,
> though thinking about it, it may have seemed as such...
> 
> In fact, it's meant to be constructive. Since subsampling and color
> conversions are on the outer rim (i.e. they are some of the first
> independent features in the encoding pipeline, and some of the last
> independent features in the decoding pipeline), it should actually be
> very feasible to add proper and full and consistent support for this
> to the existing LibTiff library, with minimum code change.
> 
> 
> Best regards,
> 
> Joris