请输入您要查询的百科知识:

 

词条 Box blur
释义

  1. Implementation

  2. See also

  3. References

A box blur (also known as a box linear filter) is a spatial domain linear filter in which each pixel in the resulting image has a value equal to the average value of its neighboring pixels in the input image. It is a form of low-pass ("blurring") filter. A 3 by 3 box blur can be written as matrix

Due to its property of using equal weights, it can be implemented using a much simpler accumulation algorithm, which is significantly faster than using a sliding-window algorithm.[1]

Box blurs are frequently used to approximate a Gaussian blur.[2] By the central limit theorem, repeated application of a box blur will approximate a Gaussian blur.

In the frequency domain, a box blur has zeros and negative components. That is, a sine wave with a period equal to the size of the box will be blurred away entirely, and wavelengths shorter than the size of the box may be phase-reversed, as seen when two bokeh circles touch to form a bright spot where there would be a dark spot between two bright spots in the original image.

Implementation

A box blur can be implemented as an image effect that affects the whole screen.

The blurred color of the current pixel is the average of the current pixel's color and its 8 neighboring pixels.

The following pseudocode shows how to implement such an image effect.

For each iteration do:

{
    For each pixel on the screen do:    {        uv = sample coordinates of the current pixel        texel = screen texel size                //  X X X   > upperRow        //  X P X   > centerRow        //  X X X   > bottomRow        // Final value is average of the three rows                upperRow = sample(screen, uv + (-texel.x, texel.y))     //Top left                 + sample(screen, uv + (0, texel.y))             //Top center                + sample(screen, uv + (texel.x, texel.y));      //Top right                        centerRow = sample(screen, uv + (-texel.x, 0))          //Middle left                 + sample(screen, uv)                            //Current pixel                + sample(screen, uv + (texel.x, 0));            //Middle right                        bottomRow = sample(screen, uv + (-texel.x, -texel.y))   //Bottom left                 + sample(screen, uv + (0, -texel.y))            //Bottom center                + sample(screen, uv + (texel.x, -texel.y));     //Bottom right                        return (upperRow + centerRow + bottomRow) / 9;    }

}

See also

  • Gaussian blur
  • Gaussian filter
  • Median filter

References

1. ^Wojciech Jarosz. 2001. [https://web.archive.org/web/20060718054020/http://www.acm.uiuc.edu/siggraph/workshops/wjarosz_convolution_2001.pdf Fast Image Convolutions].
2. ^W3C SVG1.1 specification, 15.17 Filter primitive 'feGaussianBlur'.
{{DEFAULTSORT:Box Blur}}{{photography-stub}}

1 : Image processing

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/13 9:54:10