Understanding super fast blur algorithm

后端 未结 3 685
情书的邮戳
情书的邮戳 2021-02-03 11:47

I\'m trying to understand the algorithm behind the super fast blur algorithm. Below is the port to java that works with android as a test. Looks like this version makes some opt

3条回答
  •  误落风尘
    2021-02-03 12:38

    Hints when using CompoundBlur

    You will notice from the gradient tables that the blur is going to build from the outside inward, so it will blur the edges first and then blur the center. In order to blur from the center towards the edges just take all the values in the mul_table and subtract 255 from them: This inverts the bitmap- you can imagine the brightness of a pixel in your gradient map is equivalent to the blur radius used there - white pixel big blur, black pixel small blur.

    Method for Quick Inverting:

    Using Sublime Text and Microsoft Excel you can easily invert the values...

    Sublime Text:

    Get all the values into columns with the commas lined up vertically, then by clicking and dragging with the mousewheel you can select downward and hit enter to put a single number on a single line. Now click and drag with mousewheel again and insert a "- 255" after every value, and a "=" before every value (Also click and drag to select all commas and delete them). Now select all lines and copy.

    Final format for Excel should be: = (original mul_table value) - 255 ... i.e. = 512 - 255

    Excel: After copying formatted values in Sublime, paste to the top-left most cell in Excel, and Excel will evaluate "=512-255" for you and instantly create new inverted values. Copy all cells and paste back into your js file and insert commas back in.

    Your CompoundBlur will now blur from the center towards the edges..

提交回复
热议问题