Apply a Gauss filter to an image with Python Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report A Gaussian Filter is a low-pass filter used for reducing noise (high-frequency components) and for blurring regions of an image. This filter uses an odd-sized, symmetric kernel that is convolved with the image. The kernel weights are highest at the center and decrease as you move towards the periphery, this makes the filter less sensitive to drastic changes (edges), allowing a smooth blur effect. The 2D Gaussian function is defined as:where:x, y are the coordinatesMathematical Constant PI (value = 3.13)σ is the Standard DeviationUsing this formula, you can calculate the Gaussian kernel of any size by providing appropriate values. Example: 3*3 gaussian kernal(σ =1)Implementing gaussian blur in PythonExample 1: In this example, we will blur the entire image using Python's PIL (Pillow) library. The Gaussian blur is a commonly used effect in image processing to reduce image noise and detail. Python from PIL import Image, ImageFilter img = Image.open(r"IMAGE_PATH") blur = image.filter(ImageFilter.GaussianBlur()) blur.show() OutputBlurred ImageExplanation:Open the image file from "IMAGE_PATH" using Image.open().Apply a default blur using .filter(ImageFilter.GaussianBlur()).Display the blurred image using .show().Example 2: Instead of blurring the entire image, sometimes we only want to blur a specific region (like faces or private information). This can be achieved by:Cropping the region.Applying Gaussian blur.Pasting it back on the original image. Python from PIL import Image, ImageFilter img = Image.open(r"IMAGE_PATH") # Load image crop = img.crop((0, 0, 150, 150)) # Crop top-left region blur = crop.filter(ImageFilter.GaussianBlur(3)) img.paste(blur, (0, 0)) img.save("output.png") OutputOnly the top left region of the image blurredExplanation:Open the image from "IMAGE_PATH" using Image.open().Extract the top-left 150x150 pixel region using .crop((0, 0, 150, 150)).Apply Gaussian blur with radius 3 to the cropped region.Replace the original region with the blurred one using .paste(). Comment More info V vasudev4 Follow Improve Article Tags : Python Image-Processing Python-pil Explore Python FundamentalsPython Introduction 3 min read Input and Output in Python 4 min read Python Variables 5 min read Python Operators 5 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 7 min read Python Functions 5 min read Recursion in Python 6 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 5 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 2 min read Python MySQL 9 min read Python Packages 12 min read Python Modules 7 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 6 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 15+ min read StatsModel Library- Tutorial 4 min read Learning Model Building in Scikit-learn 8 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 7 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 7 min read Python | Build a REST API using Flask 3 min read How to Create a basic API using Django Rest Framework ? 4 min read Python PracticePython Quiz 3 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like