[ptx] 16 bit and float image support in nona/hugin
Terje Mathisen
terje.mathisen at hda.hydro.com
Tue May 4 08:31:53 BST 2004
ptx-bounces at email-lists.org wrote:
> On Mon, 03 May 2004, Kai-Uwe Behrmann wrote:
>
>
>>Am 03.05.04, 18:58 +0200 schrieb Pablo d'Angelo:
>>
>>
>>>Ok, I'll save the tiff files like that. Internally I'll use 8 bit alpha
>>>channels.
>>
>>This or the bit approach, You mentioned, seems to be an clever solution
>>internally.
>
>
> Hmm, bits are clumsy to access in C. However, an even better approach to
> store most masks would be a run length encoded image (RLE encoding every
> row separately). For the typical mask the storage would only cost a few
> bytes for every row.
>
> Now we just need vigra::RLEImage.
I suggest a very simple encoding:
[count][value] pairs stored as unsigned bytes. This could require a few
extra pairs for very long repeat counts, but at 128:1 compression, it
really doesn't matter.
If you want to be fancy, then you use the fact that a repeat count of
zero is impossible: Instead, this means that the next byte will be a
count of uncompressed bytes following:
[0][count][a,b,c,d,e,...]
I.e. you'd use this for graduated masks where the repeat count averages
less than two.
Decoding becomes really fast:
count = *i++;
mask = *i++;
if (count) {
memset(o, mask, count);
o += count;
}
else {
memcpy(i, o, mask);
i += mask;
o += mask;
}
(Add boundary error checking to taste!)
Terje
--
- <Terje.Mathisen at hda.hydro.com>
"almost all programming can be viewed as an exercise in caching"
More information about the ptX
mailing list