Encoding of binary images

172 views
Skip to first unread message

Ritwik Ghosal

unread,
Jul 10, 2023, 7:20:41 AM7/10/23
to WebP Discussion
Hey

Does the hashchain gets any value filled in the case of encoding binary images( single bit plane having 0 and 255) . 
If no then how are the histogram image set and histo_bins made? and as a result how do we get the huffman code for the encoded image?
Is it just that the palette has two colors, 0xffffffff and 0xff000000, so when we use 'Mapimagefrompalette', the image gets encoded in zeros and ones (I mean the indices of the palette )?

Thanks

Vincent Rabaud

unread,
Jul 10, 2023, 7:44:40 AM7/10/23
to webp-d...@webmproject.org
Hi.
It depends ...
With binary images, you can end up packing pixels if it is more efficient:
https://chromium.googlesource.com/webm/libwebp/+/refs/heads/main/doc/webp-lossless-bitstream-spec.txt#551
It is done here:
Up to 8 pixels can then be stored into 1.


--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
To view this discussion on the web visit https://groups.google.com/a/webmproject.org/d/msgid/webp-discuss/5481798e-6bb6-4802-80f0-fe48a2ba7451n%40webmproject.org.

Ritwik Ghosal

unread,
Jul 10, 2023, 8:03:05 AM7/10/23
to WebP Discussion, Vincent Rabaud
Thanks I got that! 
But the thing I was specifically asking for was about this function: https://chromium.googlesource.com/webm/libwebp/+/refs/heads/main/src/enc/vp8l_enc.c#858
What role does this have with the encoding of 8-bit packed-binary images.

Thanks

Vincent Rabaud

unread,
Jul 10, 2023, 8:17:46 AM7/10/23
to Ritwik Ghosal, WebP Discussion
Its role is the same as with any images: it tries to find sequences of
byteswhether they represent ARGB or packed pixels) that repeat
themselves so that they can be compressed better using LZ77. It does
not care whether your image is binary or palettized or not.

On Mon, Jul 10, 2023 at 2:03 PM Ritwik Ghosal

Ritwik Ghosal

unread,
Jul 12, 2023, 3:33:49 AM7/12/23
to Vincent Rabaud, webp-d...@webmproject.org
Hi

What does the size, max_size fields represent in the VP8LHistogramset. 
Additionally, how is the histogram_image made? Is it subsampled blocks over the image? 

My image size was 512 x 512 and it was binary so the image after bit packed got into a size of 64 x 512. 

Now I get my histogram_image having a size of 32. What does this 32 mean? Additionally when this histogram_image is given as an argument to " Gethufffbitlengthsandcodes " the present size field of the histogram_image is being shown to be 2.
Please let me know.

Thanks

Vincent Rabaud

unread,
Jul 21, 2023, 9:52:35 AM7/21/23
to Ritwik Ghosal, webp-d...@webmproject.org
Hi,

The image to process after transforms (64 x 512 in your case) is
subsampled into blocks (I guess by 2 hence 32 x 256 in your case) and
for each block (2 x 2 here) of the original image, a histogram of
symbols is computed. Those are stored in a VP8LHistogramSet. At first,
there are 'max_size' histograms (the number of blocks, hence 32*256)
but they are then merged to reduce the overall entropy, getting to
'size' histograms (2 apparently in your case).

James Zern

unread,
Jul 21, 2023, 12:37:42 PM7/21/23
to webp-d...@webmproject.org
On Fri, Jul 21, 2023 at 6:52 AM 'Vincent Rabaud' via WebP Discussion <webp-d...@webmproject.org> wrote:
Hi,

The image to process after transforms (64 x 512 in your case) is
subsampled into blocks (I guess by 2 hence 32 x 256 in your case) and
for each block (2 x 2 here) of the original image, a histogram of
symbols is computed. Those are stored in a VP8LHistogramSet. At first,
there are 'max_size' histograms (the number of blocks, hence 32*256)
but they are then merged to reduce the overall entropy, getting to
'size' histograms (2 apparently in your case).


Any places in the code that can be updated with some comments to make the process clearer?
 
Reply all
Reply to author
Forward
0 new messages