webp best fit algorithm

61 views
Skip to first unread message

Supratik Banerjee

unread,
May 14, 2016, 8:29:47 PM5/14/16
to WebP Discussion
Hi,

I am studying the webp compression method and am not able to figure out the best way to select the best intra prediction mode. I think it is sum of square of errors. Kindly help me out in better understanding the technique.

Thank-you

Pascal Massimino

unread,
May 16, 2016, 2:05:07 AM5/16/16
to WebP Discussion
Hi,

On Sat, May 14, 2016 at 5:29 PM, Supratik Banerjee <supratikb...@gmail.com> wrote:
Hi,

I am studying the webp compression method and am not able to figure out the best way to select the best intra prediction mode. I think it is sum of square of errors. Kindly help me out in better understanding the technique.

sum of squared errors (SSE) is only one part of the equation. It's good to try to minimize it, but you also have to count how many bits it will cost to do so. That's why functions like PickBestIntra16() in libwebp use Rate-Distortion optimization (RD-opt for short): for each possible intra mode candidates, the block is reconstructed with quantized coefficients. Its distortion (SSE16x16) is measured, along with the number of bits (VP8GetCostLuma16) it will take to code. The best combination is eventually picked.

hope it helps,
skal/

 

Thank-you

--
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 post to this group, send email to webp-d...@webmproject.org.
Visit this group at https://groups.google.com/a/webmproject.org/group/webp-discuss/.
For more options, visit https://groups.google.com/a/webmproject.org/d/optout.

Supratik Banerjee

unread,
May 16, 2016, 11:42:48 PM5/16/16
to webp-d...@webmproject.org

Hi,

Thank-you for sharing your time and helping me with my concern. 
I have worked out a good part of the webp prediction in Python over the night, understanding it's working and looking at the source code. Before moving on to the RD-OPT, I'm stuck at a point of where I'm not very sure whether I'm in the right direction or not.

I have taken an image and applied 4x4 luma prediction using all 10 pred mode and constructed the predicted luma image just based on SSE for now, as I'm just checking the quality of the predicted image. I'm not very sure whether my implementation is correct or not, even though I feel it is but the predicted image doesn't look all that good.

So I'm attaching my small piece of code, few sample original and predicted images. It would be very helpful if you could guide me in the right direction with my journey into image compression, as I wish to improvise the compression technology for which it is very crucial for me to understand the working properly.

Regards,
Supratik

WebP.py
figure_5_original.png
figure_5_predicted.png
figure_6_original.png
figure_6_predicted.png
figure_7_original.png
figure_7_predicted.png
figure_1_original.png
figure_1_predicted.png
figure_2_original.png
figure_2_predicted.png
figure_3_original.png
figure_3_predicted.png
figure_4_original.png
figure_4_predicted.png

Pascal Massimino

unread,
May 18, 2016, 1:08:45 AM5/18/16
to WebP Discussion
Supratik,

On Mon, May 16, 2016 at 8:42 PM, Supratik Banerjee <supratikb...@gmail.com> wrote:

Hi,

Thank-you for sharing your time and helping me with my concern. 


I have worked out a good part of the webp prediction in Python over the night, understanding it's working and looking at the source code. Before moving on to the RD-OPT, I'm stuck at a point of where I'm not very sure whether I'm in the right direction or not.

I have taken an image and applied 4x4 luma prediction using all 10 pred mode and constructed the predicted luma image just based on SSE for now, as I'm just checking the quality of the predicted image. I'm not very sure whether my implementation is correct or not, even though I feel it is but the predicted image doesn't look all that good.


Code doesn't look particularly wrong to me. I'd check the x/y ordering though. You're using some unusual notation (x for vertical, y for horizontal, etc.), so it's easy to make confusions. Just try to force all the 10 modes one by one for the whole image and verify the output looks reasonable.

just my 2c.
skal/

Supratik Banerjee

unread,
May 18, 2016, 6:24:08 PM5/18/16
to webp-d...@webmproject.org
Hi  Skal,

As you asked me to check all 10 modes, i did so and am compiling all mode predictions. Kindly have a look at it and if possible please do share a predicted image from the original image in the Archive. Also regarding the x/y ordering, it is arranged as matrix index(x representing rows and y representing columns).
Thank-you

Regards,
Supratik
predWebP.rar

Pascal Massimino

unread,
May 25, 2016, 11:12:56 AM5/25/16
to WebP Discussion
Hi,

On Thu, May 19, 2016 at 12:24 AM, Supratik Banerjee <supratikb...@gmail.com> wrote:
Hi  Skal,

As you asked me to check all 10 modes, i did so and am compiling all mode predictions. Kindly have a look at it and if possible please do share a predicted image from the original image in the Archive. Also regarding the x/y ordering, it is arranged as matrix index(x representing rows and y representing columns).

I'm absolutely unable to tell if the code is correct or not by just looking at it, especially with the strange ordering.
You need some reference values and unit-tests for your code.

Suggestion: add some printf() in libwebp (dsp/dec.c), to print the border pixels and the predicted values for each mode. Then, force the value of these border samples in your python code, form the predicted value, and see if they match what libwebp is having.

Supratik Banerjee

unread,
May 27, 2016, 3:20:06 AM5/27/16
to webp-d...@webmproject.org

Hi Skal,

I checked the source code (dsp/dec.c), added some counters to check pred mode. For all 4x4 blocks I only see HE4 DC4 HD4 and HU4 being used. None of the others are used, what am I missing?

Kindly revert at the earliest.

Regards,
Supratik

Pascal Massimino

unread,
May 30, 2016, 2:49:32 AM5/30/16
to WebP Discussion
Hi,

On Fri, May 27, 2016 at 12:20 AM, Supratik Banerjee <supratikb...@gmail.com> wrote:

Hi Skal,

I checked the source code (dsp/dec.c), added some counters to check pred mode. For all 4x4 blocks I only see HE4 DC4 HD4 and HU4 being used. None of the others are used, what am I missing?


Not sure about your code, but all modes should be used eventually.

Just add a "printf("%d\n", ymode);" at src/dec/tree.c:337. Then:

./examples/dwebp libwebp-test-data/bryce.webp | sort | uniq
File libwebp-test-data/bryce.webp can be decoded (dimensions: 11158 x 2156 . Format: lossy).
Nothing written; use -o flag to save the result as e.g. PNG.
0
1
2
3
4
5
6
7
8
9


shows that all modes are used in this file from the test suite (like in many other files). You can use it for unit-testing.

skal/
Reply all
Reply to author
Forward
0 new messages