The pixels in an image are represented as integers. After blurring each pixel ‘x’ of the resulting image has a value equal to the average of the pixels surrounding ‘x’ including ‘x’. For example, consider a 3 * 3 image as
Then, the resulting image after blur is blurred_image =
So, the pixel of blurred image is calculated as (1 + 1 + 1 + 1 + 7 + 1 + 1 + 1 + 1) / 9 = 1.66666 = 1
Box Blur Algorithm –
Box blur is also known as box linear filter. Box blurs are frequently used to approximate Gaussian blur.
A box blur is generally implemented as an image effect that affects the whole screen. The blurred colour of the current pixel is the average of the current pixel’s colour and its 8 neighbouring pixels.
Note: For each 3 * 3 pixel matrix there is one blurred pixel calculated as above.
FOr Example, Consider the below image.
It’s blurred image is given below:
There are four 3 * 3 matrix possible in the above image. So there are 4 blurred pixel in the resulting image. The four matrices are:
, , , and
Implementation in Python:
[[5, 4], [4, 4]]
Test case 2:
Further Read: Box Blur using PIL library | Python
- PyQt5 QLabel - Accessing blur radius of the blur effect
- PyQt5 QLabel - Setting blur radius to the blur effect
- OpenCV Python Program to blur an image
- OpenCV | Motion Blur in Python
- Python OpenCV | cv2.blur() method
- Python - Adaptive Blur in Wand
- Wand - blur() function in Python
- Python - Sharpen and blur filtering using pgmagick
- Wand blur() function - Python
- Pgmagick blur() method - Python
- PyQt5 - Check box checked state depending upon another check box
- PyQt5 - How to hide the items from drop down box in Combo Box
- OpenCV C++ Program to blur an image
- Node Jimp | Blur
- Nodejs | GM blur() Function
- PyQt5 Label - Setting blur radius to shadow
- PyQt5 Label - Accessing blur radius to shadow
- PyQt5 QLabel - Adding blur effect
- PyQt5 QLabel - Disabling the blur effect according to the user
- PyQt5 - Checking if the blur effect is disabled or not
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.