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
June 2010

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

2010.06.11 21:39 "Class Y images with alpha channels", by Thomas Richter
2010.06.11 23:26 "Re: Class Y images with alpha channels", by Bob Friesenhahn
2010.06.14 05:59 "Re: Class Y images with alpha channels", by Joris Van Damme
2010.06.14 06:36 "Re: Class Y images with alpha channels", by Thomas Richter
2010.06.14 07:51 "Re: Class Y images with alpha channels", by Joris Van Damme
2010.06.14 14:57 "Re: Class Y images with alpha channels", by Bob Friesenhahn

2010.06.14 07:51 "Re: Class Y images with alpha channels", by Joris Van Damme

Thomas,

>>> is there a possibility to add an alpha channel to a class Y (YCbCr) tiff
>>> image? I don't see this in the rev.6 specs.
>>
>> Nor does the spec mention 12 bit per channel YCbCr, nor does the spec
>> mention RGB with alpha and two unspecified channels, nor does it
>> mention 20 bit per channel grayscale, etc. We ought to understand the
>> 'class' concept in the spec as a (misleading) enumeration of 'typical
>> usage', whilst the tag system makes perfect sense as to allow just any
>> variation.
>
> Well, but then how it's done if it is not specified?
>
> Here are two concrete questions I cannot answer from the specs:
>
> *) Given by bits/component is not divisible by 8, how do I pack the
> samples? Given my understanding of the "RGB" class, I suppose I need to
> bit-pack the samples
> as tightly as possible, that is, if I have a 9 bit YCbCr (let's assume
> this for a moment) with 420 subsampling, then I write 9 bits Y, 9 bits
> Y, 9 bits Y, 9 bits Y, 9 bits Cb,
> 9 bits Cr, making a total of 6*9 = 54 bits. Now, the specs furthermore
> say that I need to flush to the end of the byte at the end of a row.
> What is the end of the row
> here exactly? Actually, I'm writing not a single row, but two rows at
> once. I suppose I need to flush at the end of the "row pair" in 420?

Packing issue is as you expect. Pack as tightly as possible, leaving no 
padding bits. Pad lines, which is in this case not lines of pixels but lines 
of 'subsampling blocks', and pad them to a byte boundary. I believe the spec 
is clear on this, though it's been some years since I last reread it so I 
cannot quote the exact section(s).

> *) Given I have an alpha channel, how is it interleaved with the
> remaining channels? Is the alpha channel subsampled (I suppose not, but
> I don't know). Is it
> YYYYCbCrAAAA or is it YYYYAAAACbCr, or YYYYCbCrA?

This is another issue. Your original question was about adding alpha to 
YCbCr, and didn't mention subsampling (though I should have understood you 
meant to imply this). I'd strongly recommend against using subsampling on 
YCbCr plus alpha. I don't think there's a single codec on the planet that is 
going to make sense of it, my own proprietary codec included.

This being said, there is a single unambigious way to do it. Channel order 
is unambigious, alpha and undefined channels always follow the color 
channels and are defined by the TIFFTAG_EXTRASAMPLES tag. So in your case, 
the channel order should be Y-Cb-Cr-A. As to subsampling, it is clear from 
the subsampling concept it applies to chroma channels (the human eye having 
less resolution for chroma then it has for luma, subsampling is actually 
meant as a compression step, saving space by specifying Cb and Cr in lower 
resolutions). The single and unambigious way to do it, in my mind, would 
therefore be YYYYCbCrAAAA (assuming subsampling values [2,2]).


Best regards,

Joris