Prasad Naik

Prasad Naik

35 Articles Published

Articles by Prasad Naik

35 articles

Applying Gaussian Blur to an image using the Pillow library

Prasad Naik
Prasad Naik
Updated on 25-Mar-2026 1K+ Views

In this tutorial, we will learn how to apply a Gaussian blur effect to images using Python's Pillow library. The ImageFilter.GaussianBlur() function creates a smooth blur effect by applying a Gaussian filter with a specified radius parameter. What is Gaussian Blur? Gaussian blur is a widely-used image processing technique that reduces image noise and detail by applying a mathematical function called a Gaussian kernel. The radius parameter controls the blur intensity — higher values create more blur. Algorithm Step 1: Import Image and ImageFilter from Pillow Step 2: Open the target image file Step 3: ...

Read More

Applying MaxFilter on an image using Pillow library

Prasad Naik
Prasad Naik
Updated on 25-Mar-2026 587 Views

In this program, we will apply a maximum filter on an image using the Pillow library. In maximum filtering, the value of each pixel in a selected window of the image is replaced by the maximum pixel value of that window. This creates a dilation effect that brightens the image and expands bright regions. What is MaxFilter? The MaxFilter is a morphological operation that replaces each pixel with the maximum value found in its neighborhood window. It's commonly used for noise removal and feature enhancement in image processing. Syntax ImageFilter.MaxFilter(size) Parameters: size ...

Read More

Loading and displaying an image using the Pillow library

Prasad Naik
Prasad Naik
Updated on 25-Mar-2026 288 Views

In this program, we will read or load an image using the Pillow library. The Pillow library provides the Image.open() method that takes the file path or filename as a string parameter. To display the image, we use the show() function which opens the image in the default image viewer. Installing Pillow First, install the Pillow library if you haven't already ? pip install Pillow Basic Image Loading and Display Here's how to load and display an image using Pillow ? from PIL import Image import io import base64 # ...

Read More

Downsampling an image using OpenCV

Prasad Naik
Prasad Naik
Updated on 25-Mar-2026 8K+ Views

In this program, we will down sample an image. Downsampling is decreasing the spatial resolution while keeping the 2D representation of an image. It is typically used for zooming out of an image. We will use the pyrDown() function in the OpenCV library to complete this task. What is Image Downsampling? Image downsampling reduces the number of pixels in an image by decreasing its spatial resolution. OpenCV's pyrDown() function performs Gaussian pyramid downsampling, which smooths the image and reduces its size by half in each dimension. Algorithm Step 1: Read the image using cv2.imread() Step ...

Read More

Calculating the mean of all pixels for each band in an image using the Pillow library

Prasad Naik
Prasad Naik
Updated on 25-Mar-2026 2K+ Views

In this tutorial, we will calculate the mean pixel values for each color channel in an image using Python's Pillow library. RGB images have three channels (Red, Green, Blue), so we'll get a list of three mean values representing the average intensity of each color channel. Original Image Algorithm Step 1: Import the Image and ImageStat libraries from PIL Step 2: Open the target image file Step 3: Create an ImageStat.Stat object from the image Step 4: Use the mean property to get average pixel values for each channel Example Here's ...

Read More

Performing white TopHat operation on images using OpenCV

Prasad Naik
Prasad Naik
Updated on 25-Mar-2026 787 Views

In this tutorial, we will perform the TopHat operation on images using OpenCV. TopHat operation is a morphological transformation that extracts small elements and details from images by highlighting bright objects on dark backgrounds. We will use the cv2.morphologyEx() function with the cv2.MORPH_TOPHAT operation. What is TopHat Operation? TopHat (also called White TopHat) is defined as the difference between the input image and its opening. It highlights small bright details that are smaller than the structuring element ? TopHat = Original Image - Opening Original ...

Read More

Performing an opening operation on an image using OpenCV

Prasad Naik
Prasad Naik
Updated on 25-Mar-2026 779 Views

In this program, we will perform the opening operation on an image using OpenCV. Opening removes small objects from the foreground of an image, placing them in the background. This technique can also be used to find specific shapes in an image. Opening is mathematically defined as erosion followed by dilation. The function we use for this task is cv2.morphologyEx(image, cv2.MORPH_OPEN, kernel). Original Image Algorithm Step 1: Import cv2 and numpy Step 2: Read the image Step 3: Define the kernel (structuring element) Step 4: Pass the image and kernel to cv2.morphologyEx() function ...

Read More

Dilating images using the OpenCV function dilate()

Prasad Naik
Prasad Naik
Updated on 25-Mar-2026 894 Views

In this tutorial, we will learn how to dilate an image using the dilate() function in OpenCV. Dilation is a morphological operation that adds pixels to the boundaries of objects in an image, effectively expanding or thickening white regions and shrinking black regions. What is Image Dilation? Dilation expands the foreground objects in a binary or grayscale image. It uses a kernel (structuring element) that slides over the image, and for each position, it replaces the center pixel with the maximum value in the kernel's neighborhood. Syntax cv2.dilate(src, kernel, iterations=1, borderType=cv2.BORDER_CONSTANT, borderValue=0) Parameters ...

Read More

Eroding an image using the OpenCV function erode()

Prasad Naik
Prasad Naik
Updated on 25-Mar-2026 674 Views

In this program, we will erode an image using the OpenCV function erode(). Erosion of an image means to shrink the image by reducing the size of white regions or foreground objects. If any of the pixels in a kernel is 0, then all the pixels in the kernel are set to 0. One condition before applying an erosion function on an image is that the image should be a grayscale image. What is Image Erosion? Image erosion is a morphological operation that reduces the boundaries of foreground objects (white pixels). It works by sliding a structuring element ...

Read More

Blurring an image using the OpenCV function blur()

Prasad Naik
Prasad Naik
Updated on 25-Mar-2026 490 Views

In this tutorial, we will learn how to blur an image using the OpenCV blur() function. Blurring reduces image noise and detail by averaging pixel values in a neighborhood defined by a kernel. Algorithm Step 1: Import OpenCV and NumPy libraries Step 2: Load the input image Step 3: Define the kernel size for blurring Step 4: Apply the blur() function with image and kernel parameters Step 5: Display or save the blurred result Understanding the blur() Function The cv2.blur() function performs simple box filtering. It takes the average of all pixels in the ...

Read More
Showing 1–10 of 35 articles
« Prev 1 2 3 4 Next »
Advertisements