AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2006.09.26 04:45 "[Tiff] Tiffcrop beta available for testing", by Richard Nolde
2006.09.26 04:55 "Re: [Tiff] Tiffcrop beta available for testing", by Bob Friesenhahn
2006.09.26 05:17 "Re: [Tiff] Tiffcrop beta available for testing", by Joris Van Damme
2006.09.26 05:43 "Re: [Tiff] Tiffcrop beta available for testing", by Joris Van Damme
2006.09.27 04:21 "[Tiff] YCbCr data in tiffcrop", by Richard Nolde
2006.09.27 12:50 "Re: [Tiff] YCbCr data in tiffcrop", by Joris Van Damme

2006.09.26 05:17 "Re: [Tiff] Tiffcrop beta available for testing", by Joris Van Damme

Richard, Bob,

Your program sounds pretty neat.

I second that!

Do you think it feasable to include this new tiffcrop in the distribution as a new tool or contrib?

Does anyone have any information on how YCbCr images are handled by the read[Separate/Contig][Strips/Tiles]IntoBuffer routines in tiffcp that would be different for YCbCr data rather than RGBA data?

I don't know the details as pertain to TIFF, but YCbCr is often subsampled, which could mean (e.g. for 4:2:2) there are two Y samples for every pair of CbCr samples. For example Cb,Y,Cr,Y,Cb,Y,Cr,Y so each pixel position is represented by two samples rather than three and at least two pixel positions need to be decoded in order to know (approximately) the color of a pixel.

You're confusing TIFF with JPEG here and switching some stuff around.

TIFF has subsampling values in the YCbCrSubsampling tag (see http://www.awaresystems.be/imaging/tiff/tifftags/ycbcrsubsampling.html). These contain horizontal and vertical subsampling values. If you represent horizontal subsampling value by h+1, and vertical subsampling value by v+1, you can visualize the data organisation inside TIFF as follows.

Y00,Y01,...Y0h,
Y10,Y11,...Y1h,
...
Yv0,Yv1,...Yvh,
Cb,Cr

So that's a matrix of Y, left to right, top to bottom, horizontal subsampling wide and vertical subsampling high, followed by a single Cb value, followed by a single Cr value. This applies to all forms of subsampled YCbCr, uncompressed, LZW compressed, flate compressed, whatever. Unfortunately, the LibJpeg library returns another organisation, and a convertion needs to be made, but the issue with JPEG compression is further mudded by the ugly JPEGCOLORMODE thing that makes JPEG compression different from all other compressed subsampled YCbCr, thus seemingly offering an easy way out but in fact making it only more difficult and confusing to support full subsampled YCbCr that is independent of compression mode.

Additionally, tiffcp may internally represent and handle data in any other way, I don't know.

Best regards,

Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html