Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
124 views

Digital Image Processing Lab Manual Part-1

This manual contains the basic understanding of Digital Image Processing concepts, targeting very beginners. The manual start with the setup of the environment to run the experiments code and ended with the explanation of code chunks and output of sample input image.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views

Digital Image Processing Lab Manual Part-1

This manual contains the basic understanding of Digital Image Processing concepts, targeting very beginners. The manual start with the setup of the environment to run the experiments code and ended with the explanation of code chunks and output of sample input image.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Digital Image Processing Labo ratory

List of The Experiments

Exp. No. Experiment Name


To create an opencv-python program to get a gradient image from an
01
RGB/grayscale image.
To create an opencv-python program to show a histogram of an RGB/grayscale
02
image.
To create an opencv-python program in order to convert a given
03
RGB/grayscale image to a negative image.
To create an opencv-python program to enhance color of a given
04
RGB/grayscale image.
To create an opencv-python program to enhance brightness of a given
05
RGB/grayscale image.
To create an opencv-python program to enhance contrast of a given
06
RGB/grayscale image.
To create an opencv-python program to segment a given RGB/grayscale image
07
based on thresholding.
To create an opencv-python program to segment a given RGB/grayscale image
08
based on the contour detection algorithm.
To create an opencv-python program to segment a given RGB/grayscale image
09
based on K-means algorithm.
10 To create an opencv-python program to sharp a given RGB/grayscale image.
To create an opencv-python program to skeletonize a given RGB/grayscale
11
image.
To create an opencv-python program to smooth a given RGB/grayscale image
12
by a 2Dfilter.
To create an opencv-python program to smooth a given RGB/grayscale image
13
by an average filter.
To create an opencv-python program to smooth a given RGB/grayscale image
14
by a Gaussian filter.
To create an opencv-python program to smooth a given RGB/grayscale image
15
by a median filter.
To create an opencv-python program to smooth a given RGB/grayscale image
16
by a bilateral filter.

P age |2
Digital Image Processing Labo ratory

Table of Contents
List of The Experiments ..................................................................................................................... 2
INTRODUCTION ................................................................................................................................. 6
A. Background............................................................................................................................ 6
B. Required Knowledge .............................................................................................................. 6
C. Some Basic Concepts Need to Know Before Start ................................................................... 6
D. Environment Setup ................................................................................................................ 7
E. First Program to Test Environment......................................................................................... 8
EXPERIMENT NO. 01 .......................................................................................................................... 9
1.1. Some Key Terms Related to This Experiment ...................................................................... 9
1.2. Python Source Code ........................................................................................................... 9
1.3. Solution Procedure............................................................................................................. 9
1.4. Output Figure................................................................................................................... 10
EXPERIMENT NO. 02 ........................................................................................................................ 11
2.1. Some Key Terms Related to This Experiment .................................................................... 11
2.2. Python Source Code ......................................................................................................... 11
2.3. Solution Procedure........................................................................................................... 11
2.4. Output Figure................................................................................................................... 12
EXPERIMENT NO. 03 ........................................................................................................................ 13
3.1. Some Key Terms Related to This Experiment .................................................................... 13
3.2. Python Source Code ......................................................................................................... 13
3.3. Solution Procedure........................................................................................................... 13
3.4. Output Figure................................................................................................................... 14
EXPERIMENT NO. 04 ........................................................................................................................ 15
4.1. Some Key Terms Related to This Experiment .................................................................... 15
4.2. Python Source Code ......................................................................................................... 15
4.3. Solution Procedure........................................................................................................... 15
4.4. Output Figure................................................................................................................... 16
EXPERIMENT NO. 05 ........................................................................................................................ 17
5.1. Some Key Terms Related to This Experiment .................................................................... 17
5.2. Python Source Code ......................................................................................................... 17
5.3. Solution Procedure........................................................................................................... 17
5.4. Output Figure................................................................................................................... 18
EXPERIMENT NO. 06 ........................................................................................................................ 19
6.1. Some Key Terms Related to This Experiment .................................................................... 19

P age |3
Digital Image Processing Labo ratory

6.2. Python Source Code ......................................................................................................... 19


6.3. Solution Procedure........................................................................................................... 19
6.4. Output Figure................................................................................................................... 20
EXPERIMENT NO. 07 ........................................................................................................................ 21
7.1. Some Key Terms Related to This Experiment .................................................................... 21
7.2. Python Source Code ......................................................................................................... 21
7.3. Solution Procedure........................................................................................................... 22
7.4. Output Figure................................................................................................................... 22
EXPERIMENT NO. 08 ........................................................................................................................ 23
8.1. Some Key Terms Related to This Experiment .................................................................... 23
8.2. Python Source Code ......................................................................................................... 23
8.3. Solution Procedure........................................................................................................... 24
8.4. Output Figure................................................................................................................... 24
EXPERIMENT NO. 09 ........................................................................................................................ 25
9.1. Some Key Terms Related to This Experiment .................................................................... 25
9.2. Python Source Code ......................................................................................................... 25
9.3. Solution Procedure........................................................................................................... 25
9.4. Output Figure................................................................................................................... 26
EXPERIMENT NO. 10 ........................................................................................................................ 27
10.1. Some Key Terms Related to This Experiment ................................................................ 27
10.2. Python Source Code ..................................................................................................... 27
10.3. Solution Procedure ....................................................................................................... 28
10.4. Output Figure ............................................................................................................... 28
EXPERIMENT NO. 11 ........................................................................................................................ 29
11.1. Some Key Terms Related to This Experiment ................................................................ 29
11.2. Python Source Code ..................................................................................................... 29
11.3. Solution Procedure ....................................................................................................... 30
11.4. Output Figure ............................................................................................................... 30
EXPERIMENT NO. 12 ........................................................................................................................ 31
12.1. Some Key Terms Related to This Experiment ................................................................ 31
12.2. Python Source Code ..................................................................................................... 31
12.3. Solution Procedure ....................................................................................................... 31
12.4. Output Figure ............................................................................................................... 32
EXPERIMENT NO. 13 ........................................................................................................................ 33
13.1. Some Key Terms Related to This Experiment ................................................................ 33
13.2. Python Source Code ..................................................................................................... 33

P age |4
Digital Image Processing Labo ratory

13.3. Solution Procedure ....................................................................................................... 33


13.4. Output Figure ............................................................................................................... 34
EXPERIMENT NO. 14 ........................................................................................................................ 35
14.1. Some Key Terms Related to This Experiment ................................................................ 35
14.2. Python Source Code ..................................................................................................... 35
14.3. Solution Procedure ....................................................................................................... 35
14.4. Output Figure ............................................................................................................... 36
EXPERIMENT NO. 15 ........................................................................................................................ 37
15.1. Some Key Terms Related to This Experiment ................................................................ 37
15.2. Python Source Code ..................................................................................................... 37
15.3. Solution Procedure ....................................................................................................... 37
15.4. Output Figure ............................................................................................................... 38
EXPERIMENT NO. 16 ........................................................................................................................ 39
16.1. Some Key Terms Related to This Experiment ................................................................ 39
16.2. Python Source Code ..................................................................................................... 39
16.3. Solution Procedure ....................................................................................................... 39
16.4. Output Figure ............................................................................................................... 40
CONCLUSION ................................................................................................................................... 41
USEFULL LINKS ................................................................................................................................ 41

P age |5
Digital Image Processing Labo ratory

INTRODUCTION

A. Background
The study of digital image processing entails the analysis and alteration of digital images
through the use of computer algorithms. When computers first became strong enough to
process photos, in the 1960s, the history of digital image processing began. Digital image
processing first found use in the sciences of astronomy and medicine, where improved or
processed images were required for research. Digital image processing was increasingly used
in a range of industries, including photography, cinema, television, and video production, as
computers grew more powerful and accessible. With applications in industries like medicine,
remote sensing, and computer vision, digital image processing is now a significant academic
topic that is constantly developing and getting better.

B. Required Knowledge
We must have a fundamental understanding of picture attributes like resolution, color depth,
and image format in order to begin a basic Digital picture Processing Lab using OpenCV in
Python. Additionally, we should be familiar with the fundamentals of Python programming,
such as data types, control structures, and grammar.

C. Some Basic Concepts Need to Know Before Start


Python3: Python is a high-level, interpreted programming language that was first released in
1991 by Guido van Rossum. It is a general-purpose language that can be used for a wide variety
of tasks, including web development, data analysis, scientific computing, and artificial
intelligence.

Pip: Pip is the default package installer for Python. It is a command-line tool that allows
developers to easily install and manage third-party Python packages from the Python Package
Index (PyPI) and other package repositories.

OpenCV: OpenCV (Open Source Computer Vision) is an open-source library for computer
vision and image processing tasks, written in C++ and widely used in various industries and
research applications. OpenCV-Python is a Python wrapper for the OpenCV library, which
allows developers to use OpenCV in Python programs.
Matplotlib: Matplotlib is a plotting library for the Python programming language. It provides
an easy-to-use interface for creating high-quality static and interactive visualizations in
Python. Matplotlib was originally created to replicate the plotting capabilities of MATLAB, but
has since become a powerful tool for data visualization in its own right.
Numpy: NumPy (Numerical Python) is a Python library for scientific computing, particularly for
numerical operations on large arrays and matrices. It provides an array data structure that is

P age |6
Digital Image Processing Labo ratory

both more efficient and more convenient than Python's built-in data structures for numerical
operations.
VS Code: Visual Studio Code (VS Code) is a free and open-source code editor developed by
Microsoft for Windows, macOS, and Linux operating systems. It provides a modern and
powerful development environment that supports a wide range of programming languages
and frameworks.
RGB Image: The most popular color format for digital photos is RGB, which can produce a wide
range of colors by combining three color channels. Red, Green, and Blue are the three color
channels that make up RGB pictures. Each RGB image pixel contains a value for each of these
color channels, which establishes the pixel's overall color

Grayscale Image: Only shades of gray are present in grayscale photographs. In a grayscale
image, each pixel's brightness is determined by a single value. For simpler graphics that don't
need color, such black-and-white photos or straightforward line drawings, grayscale images
are frequently utilized. They can also be used to represent an RGB image more simply when
the color information is not required.
RGB Image Grayscale Image

D. Environment Setup
To set up a Digital Image Processing Lab using VS Code as the code editor and OpenCV,
Matplotlib, and Numpy libraries, should follow these steps for each operating system:
Windows:
1. Install Python: Download and install the latest version of Python from the official
website [1]. Make sure to add Python to the system PATH during installation.
2. Install pip: Open a command prompt and run the command python -m
ensurepip --default-pip.
3. Install OpenCV, Matplotlib, and Numpy: Open a command prompt and run the
following commands: pip install opencv-python, pip install
matplotlib, and pip install numpy.
4. Install VS Code: Download and install VS Code from the official website [4].
5. Configure VS Code: Open VS Code and install the Python extension. Set up your Python
interpreter by selecting it in the VS Code settings.

P age |7
Digital Image Processing Labo ratory

Linux (Ubuntu):
1. Install Python: Open a terminal and run the command sudo apt-get install python3
[2].
2. Install pip: Open a terminal and run the command sudo apt-get install python3-pip.
3. Install OpenCV, Matplotlib, and Numpy: Open a terminal and run the following
commands: pip install opencv-python, pip install matplotlib,
and pip install numpy.
4. Install VS Code: Download and install VS Code from the official website [5] or use the
following command: sudo snap install --classic code.
5. Configure VS Code: Open VS Code and install the Python extension. Set up your Python
interpreter by selecting it in the VS Code settings.

MacOS:
1. Install Python: Download and install the latest version of Python from the official
website [3]. Make sure to add Python to the system PATH during installation.
2. Install pip: Open a terminal and run the command sudo easy_install pip.
3. Install OpenCV, Matplotlib, and Numpy: Open a terminal and run the following
commands: pip install opencv-python, pip install matplotlib,
and pip install numpy.
4. Install VS Code: Download and install VS Code from the official website [6].
5. Configure VS Code: Open VS Code and install the Python extension. Set up your Python
interpreter by selecting it in the VS Code settings.
After completing these steps, we should be able to start using VS Code for Digital Image
Processing Lab. We can create Python files in VS Code and use the libraries to process images.
Make sure to import the necessary libraries at the beginning of our Python file.

E. First Program to Test Environment


A simple Python program to test if your environment is set up correctly for Digital Image
Processing using OpenCV, Matplotlib, and Numpy libraries,
Python Code,
1 import cv2
2 import numpy as np
3 import matplotlib.pyplot as plt
4 # Read the image from file
5 img = cv2.imread("example.jpg")
6 # Convert the image to grayscale
7 gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
8 # Show the grayscale image using Matplotlib
9 plt.imshow(gray_img, cmap="gray")
10 plt.show()
This program reads an image file named "example.jpg" using OpenCV and converts it to
grayscale. It then displays the grayscale image using Matplotlib.

P age |8
Digital Image Processing Labo ratory

1. EXPERIMENT NO. 01

To create an opencv-python program to get a gradient image from an


01 RGB/grayscale image.

1.1. Some Key Terms Related to This Experiment


Gradient Image: An image that depicts the gradient of an underlying image's intensity is known
as a gradient image. The gradient of an image is a measure of how quickly the intensity of the
image shifts in various directions. Numerous techniques, including the Sobel operator and the
Laplacian of Gaussian (LoG) operator, can be used to calculate the gradient.

1.2. Python Source Code


1 import cv2
2 import numpy as np
3 # Load the image
4 img = cv2.imread('original.jpg')
5 def convert_to_gradient_image(img):
6 # Convert the image to grayscale
7 gray = img[:, :, 0]
8 # Create a new image with the same size as the original image
9 gradient = np.zeros(gray.shape, gray.dtype)
10 height, width = gray.shape[:2]
11 # Loop through the image
12 for i in range(0, height):
13 for j in range(0, width - 1):
14 # Calculate the gradient
15 gradient[i, j] = abs(int(gray[i, j + 1]) - int(gray[i, j]))
16 # Save the gradient image
17 cv2.imwrite('gradient.jpg', gradient)
18 # Display Results
19 cv2.imshow('Original Image', img)
20 convert_to_gradient_image(img)
21 cv2.imshow('Gradient Image', cv2.imread('gradient.jpg'))
22 cv2.waitKey(0)

1.3. Solution Procedure


The convert_to_gradient_image() function first converts the input image to
grayscale using only the first channel (in case of an RGB image). It then creates a new image
called gradient that has the same size and data type as the input grayscale image.
The function then loops through each pixel of the input image and calculates the gradient
magnitude using the difference between the intensities of the current pixel and its neighbor
pixel to the right. The gradient magnitude is calculated using the absolute value of the
difference between the two intensities.

P age |9
Digital Image Processing Labo ratory

Finally, the gradient image is saved to disk using the cv2.imwrite() function and displayed
using the cv2.imshow() function. The input image and the gradient image are displayed
side by side for comparison.

1.4. Output Figure

P a g e | 10
Digital Image Processing Labo ratory

2. EXPERIMENT NO. 02

To create an opencv-python program to show a histogram of an


02 RGB/grayscale image.

2.1. Some Key Terms Related to This Experiment


Image Histogram: An image histogram is a graphical representation of the distribution of pixel
intensities in a digital image. It is a plot that shows the frequency distribution of pixel values in
an image, with the x-axis representing the pixel intensity values and the y-axis representing the
number of pixels with that intensity value.

2.2. Python Source Code


1 import cv2
2 import matplotlib.pyplot as plt
3 import numpy as np
4 # Load the image
5 img = cv2.imread('original.jpg')
6 def caluculate_histogram(img):
7 intensity_level = 256
8 intensity_counts = [0] * intensity_level
9 height, width = img.shape[:2]
10 num_of_pixels = height * width
11 # Loop through the image
12 for i in range(0, height):
13 for j in range(0, width):
14 intensity_counts[img[i, j]] += 1
15 # Plot the histogram with matplotlib
16 plt.bar(range(0, intensity_level), intensity_counts)
17 plt.title('Histogram')
18 plt.xlabel('Intensity Level')
19 plt.ylabel('Number of Pixels')
20 plt.show()
21 # Display Results
22 cv2.imshow('Original Image', img)
23 grayImg = img[:, :, 0]
24 cv2.imshow('Grayscale Image', grayImg)
25 caluculate_histogram(grayImg)
26 cv2.waitKey(0)

2.3. Solution Procedure


The calculate_histogram() function first initializes a list called
intensity_counts with 256 elements, one for each intensity level. It then loops through
each pixel in the input grayscale image and increments the corresponding element of the
intensity_counts list.

P a g e | 11
Digital Image Processing Labo ratory

Once the intensity_counts list has been computed, the function uses the plt.bar()
function from the Matplotlib library to create a bar chart of the histogram. The x-axis is the
intensity level and the y-axis is the number of pixels with that intensity level.

Finally, the original input image, the grayscale image, and the histogram are displayed using
the cv2.imshow() and plt.show() functions.

2.4. Output Figure

P a g e | 12
Digital Image Processing Labo ratory

3. EXPERIMENT NO. 03

To create an opencv-python program in order to convert a given


03 RGB/grayscale image to a negative image.

3.1. Some Key Terms Related to This Experiment


A negative image is an image where the colors of the original image are inverted so that the
darkest areas appear lightest and the lightest areas appear darkest. In other words, each pixel
value in the original image is subtracted from the maximum pixel value, resulting in a new
image with a "negative" appearance.

3.2. Python Source Code


1 import cv2
2 import numpy as np
3 # Load the image
4 img = cv2.imread('original.jpg')
5 def convert_to_negative_image(img):
6 # Create a new image with the same size as the original image
7 negative = np.zeros(img.shape, img.dtype)
8 height, width = img.shape[:2]
9 # Loop through the image
10 for i in range(0, height):
11 for j in range(0, width):
12 # Calculate the negative
13 negative[i, j] = 255 - img[i, j]
14 # Save the negative image
15 cv2.imwrite('negative.jpg', negative)
16 # Display Results
17 cv2.imshow('Original Image', img)
18 convert_to_negative_image(img)
19 cv2.imshow('Negative Image', cv2.imread('negative.jpg'))
20 cv2.waitKey(0)

3.3. Solution Procedure


This code defines a function convert_to_negative_image() that takes an image img
as input and converts it to its negative image. In a negative image, the brightness values of
each pixel are inverted, such that dark areas appear light and vice versa.
The convert_to_negative_image() function first initializes a new image called
negative with the same size and data type as the input image. It then loops through each pixel
in the input image and calculates the corresponding negative value by subtracting the current
pixel value from 255. The result is then stored in the corresponding pixel of the negative image.

P a g e | 13
Digital Image Processing Labo ratory

Once the negative image has been computed, the function uses the cv2.imwrite()
function to save the image as a file named "negative.jpg".

Finally, the original input image and the negative image are displayed using the
cv2.imshow() function.

3.4. Output Figure

P a g e | 14
Digital Image Processing Labo ratory

4. EXPERIMENT NO. 04

To create an opencv-python program to enhance color of a given


04 RGB/grayscale image.

4.1. Some Key Terms Related to This Experiment


Color Enhancement: Color enhancement of an image refers to the process of adjusting the
color balance, saturation, contrast, and other color-related attributes of an image to improve
its overall appearance and visual impact. The goal of color enhancement is to make the image
more visually appealing and to highlight specific details or features in the image.

4.2. Python Source Code


1 import cv2
2 import numpy as np
3 # Load the image
4 img = cv2.imread('original.jpg')
5 def enhance_color(img, saturation=50):
6 # Convert image to HSV color space
7 hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
8 # Split the channels
9 h, s, v = cv2.split(hsv)
10 # Adjust the value channel
11 s = cv2.add(s, saturation)
12 # Clamp the pixel values to the valid range of 0-255
13 s = np.clip(s, 0, 255)
14 # Merge the channels back together
15 hsv = cv2.merge((h, s, v))
16 # Convert back to BGR color space
17 result = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR)
18 # Save the enhanced image
19 cv2.imwrite('enhanced_color.jpg', result)
20 # Display Results
21 cv2.imshow('Original Image', img)
22 enhance_color(img)
23 cv2.imshow('Color Enhanced Image', cv2.imread('enhanced_color.jpg'))
24 cv2.waitKey(0)

4.3. Solution Procedure


This code defines a function called enhance_color() which takes an image and an
optional saturation parameter as inputs. It uses OpenCV to convert the input image from the
BGR color space to the HSV color space. It then splits the HSV image into its three channels
(hue, saturation, and value), and adds the saturation parameter to the saturation channel to
enhance the color. The pixel values in the saturation channel are then clipped to be within the
valid range of 0 to 255, and the channels are merged back together. Finally, the enhanced

P a g e | 15
Digital Image Processing Labo ratory

image is converted back to the BGR color space and saved as a new image file called
"enhanced_color.jpg". The code displays the original image and the color-enhanced
image using cv2.imshow().

4.4. Output Figure

P a g e | 16
Digital Image Processing Labo ratory

5. EXPERIMENT NO. 05

To create an opencv-python program to enhance brightness of a given


05 RGB/grayscale image.

5.1. Some Key Terms Related to This Experiment


Brightness Enhance: Enhancing the brightness of an image involves increasing the overall
luminance or brightness of the image to make it appear lighter or brighter. This can be done
to make the image easier to view or to highlight certain details or features in the image.

5.2. Python Source Code


1 import cv2
2 import numpy as np
3 # Load the image
4 img = cv2.imread('original.jpg')
5 def enhance_brightness(img, value=50):
6 # Convert image to HSV color space
7 hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
8 # Split the channels
9 h, s, v = cv2.split(hsv)
10 # Adjust the value channel
11 v = cv2.add(v, value)
12 # Clamp the pixel values to the valid range of 0-255
13 v = np.clip(v, 0, 255)
14 # Merge the channels back together
15 hsv = cv2.merge((h, s, v))
16 # Convert back to BGR color space
17 result = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR)
18 # Save the enhanced image
19 cv2.imwrite('enhanced_brightness.jpg', result)
20 # Display Results
21 cv2.imshow('Original Image', img)
22 enhance_brightness(img)
23 cv2.imshow('Brightness Enhanced Image', cv2.imread('enhanced_brightness.jpg'))
24 cv2.waitKey(0)

5.3. Solution Procedure


This code loads an image, defines a function to enhance the brightness of the image, applies
the function to the loaded image, and displays the original and enhanced images.
The enhance_brightness() function takes two arguments: the image to be enhanced
and the value of the brightness enhancement. The function converts the image from BGR color
space to HSV color space, splits the channels of the image, adjusts the value channel by adding
the value argument to each pixel, clamps the pixel values to the valid range of 0-255, merges

P a g e | 17
Digital Image Processing Labo ratory

the channels back together, converts the image back to BGR color space, and saves the
enhanced image.
The main program loads the image, displays the original image, applies the
enhance_brightness() function to the image, displays the enhanced image, and waits
for a key press before closing the windows.

5.4. Output Figure

P a g e | 18
Digital Image Processing Labo ratory

6. EXPERIMENT NO. 06

To create an opencv-python program to enhance contrast of a given


06 RGB/grayscale image.

6.1. Some Key Terms Related to This Experiment


Contrast Enhancement: Enhancing the contrast of an image involves increasing the difference
between the light and dark areas of the image, making the image appear sharper and more
defined. This can be done to improve the visual quality of the image and to make it easier to
view or analyze.

6.2. Python Source Code


1 import cv2
2 import numpy as np
3 # Load the image
4 img = cv2.imread('original.jpg')
5 def enhance_contrast(img, alpha=1.5):
6 # Create a new image with the same size as the original image
7 enhanced = np.zeros(img.shape, img.dtype)
8 height, width, channel = img.shape[:3]
9 # Loop through the image
10 for i in range(0, height):
11 for j in range(0, width):
12 for k in range(0, channel):
13 # Calculate the enhanced contrast
14 enhanced[i, j, k] = np.clip(alpha * img[i, j, k], 0, 255)
15 cv2.imwrite('enhanced_contrast.jpg', enhanced)
16 # Display Results
17 cv2.imshow('Original Image', img)
18 enhance_contrast(img)
19 cv2.imshow('Contrast Enhanced Image', cv2.imread('enhanced_contrast.jpg'))
20 cv2.waitKey(0)

6.3. Solution Procedure


This code defines a function enhance_contrast() which takes an image as input and
enhances its contrast by multiplying each pixel value by a factor alpha and then clipping the
result to the range of 0-255. The function uses nested for-loops to iterate over each pixel and
color channel of the input image, and performs the contrast enhancement on each element
separately.
The function saves the resulting image to a file named 'enhanced_contrast.jpg', and
then displays the original and enhanced images using OpenCV's cv2.imshow() function.
The user can press any key to close the display window.

P a g e | 19
Digital Image Processing Labo ratory

Note that this approach is not the most efficient way to enhance contrast, since it involves a
lot of unnecessary looping and calculation. There are other methods, such as histogram
equalization or adaptive contrast stretching, that can achieve similar results with much less
computation.

6.4. Output Figure

P a g e | 20
Digital Image Processing Labo ratory

7. EXPERIMENT NO. 07

To create an opencv-python program to segment a given


07 RGB/grayscale image based on thresholding.

7.1. Some Key Terms Related to This Experiment


Image Segmentation: Image segmentation is the process of dividing an image into multiple
regions or segments, each of which corresponds to a distinct object or part of the image. The
goal of image segmentation is to simplify or change the representation of an image into
something that is more meaningful and easier to analyze.

Thresholding: Thresholding is a common image processing technique used to separate the


pixels in an image into two groups: foreground pixels (object) and background pixels. This is
done by choosing a threshold value, which is a scalar value that separates the two groups of
pixels.

7.2. Python Source Code


1 import cv2
2 import numpy as np
3 # Load the image
4 img = cv2.imread('original.jpg')
5 def segment_image_based_on_thresholding(img):
6 # Convert the image to grayscale
7 gray = img[:, :, 0]
8 # Create a new image with the same size as the original image
9 threshold = np.zeros(gray.shape, gray.dtype)
10 height, width = gray.shape[:2]
11 # Loop through the image
12 for i in range(0, height):
13 for j in range(0, width):
14 # Calculate the threshold
15 if gray[i, j] > 100:
16 threshold[i, j] = 255
17 else:
18 threshold[i, j] = 0
19 # Save the threshold image
20 cv2.imwrite('threshold.jpg', threshold)
21 # Display Results
22 cv2.imshow('Original Image', img)
23 segment_image_based_on_thresholding(img)
24 cv2.imshow('Threshold Image', cv2.imread('threshold.jpg'))
25 cv2.waitKey(0)

P a g e | 21
Digital Image Processing Labo ratory

7.3. Solution Procedure


This code performs image segmentation based on thresholding. It takes an input image,
converts it to grayscale, and then applies a threshold to the pixel values. Pixels with values
greater than a certain threshold (in this case, 100) are set to white (255), while pixels with
lower values are set to black (0). The resulting binary image is then saved as a new image file.
The code uses nested loops to iterate over all the pixels in the image and apply the thresholding
operation. The final result is displayed using OpenCV's cv2.imshow() function.

7.4. Output Figure

P a g e | 22
Digital Image Processing Labo ratory

8. EXPERIMENT NO. 08

To create an opencv-python program to segment a given RGB /


08 grayscale image based on the contour detection algorithm.

8.1. Some Key Terms Related to This Experiment


Contour Detection Algorithm: Contour detection is a technique used in digital image processing
to identify the boundaries of objects or regions in an image. A contour is a curve or a set of
curves that represent the boundaries of an object or region. Contour detection algorithms
analyze the intensity or color gradients in the image to identify these boundaries.

There are various contour detection algorithms used in digital image processing, including:

• Canny edge detection: This algorithm detects the edges in the image by analyzing the
intensity gradient of each pixel. The edges are then linked to form closed contours.
• Sobel edge detection: This algorithm applies a Sobel filter to the image to detect the
intensity gradient in both horizontal and vertical directions. The edges are then
detected based on the magnitude of the gradient.
In this experiment we will use Canny edge detection algorithm to detect contour of an image.

8.2. Python Source Code


1 import cv2
2 import numpy as np
3 # Load the image
4 img = cv2.imread('original.jpg')
5 def segment_image_based_on_contour_detection(img):
6 # Convert the image to grayscale
7 gray = img[:, :, 0]
8 # Apply Gaussian Blur
9 blur = cv2.GaussianBlur(gray, (5, 5), 0)
10 # Apply Canny Edge Detection
11 canny = cv2.Canny(blur, 50, 150)
12 # Find the contours
13 contours, hierarchy = cv2.findContours(
14 canny, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
15 # Draw the contours
16 cv2.drawContours(img, contours, -1, (0, 0, 255), 1)
17 # Save the contour image
18 cv2.imwrite('contour.jpg', img)
19 # Display Results
20 cv2.imshow('Original Image', img)
21 segment_image_based_on_contour_detection(img)
22 cv2.imshow('Contour Detected Image', cv2.imread('contour.jpg'))
23 cv2.waitKey(0)

P a g e | 23
Digital Image Processing Labo ratory

8.3. Solution Procedure


This code segment loads an input image from defined file path and defines a function
segment_image_based_on_contour_detection() that performs contour
detection on the image using Canny edge detection and then finds and draws the contours
using OpenCV's findContours() and drawContours() functions. Finally, the resulting
image with detected contours is saved as ‘contour.jpg’ and displayed using
cv2.imshow(). The main part of the code loads the image, displays it using
cv2.imshow(), calls the segment_image_based_on_contour_detection()
function, saves the result as contour.jpg and displays the resulting image using
cv2.imshow(). The code waits until a key is pressed to close all windows.

8.4. Output Figure

P a g e | 24
Digital Image Processing Labo ratory

9. EXPERIMENT NO. 09

To create an opencv-python program to segment a given RGB /


09 grayscale image based on K-means algorithm.

9.1. Some Key Terms Related to This Experiment


K-means algorithm: K-means is a clustering algorithm used in digital image processing for
image segmentation and feature extraction. It is a popular unsupervised learning algorithm
that groups similar data points (pixels in an image) into clusters based on their feature
similarities.

9.2. Python Source Code


1 import cv2
2 import numpy as np
3 # Load the image
4 img = cv2.imread('original.jpg')
5 def segment_image_based_on_k_means(img):
6 pixels = img.reshape((-1, 3)).astype(np.float32)
7 # Define the k-means parameters
8 k = 3
9 attempts = 10
10 # Define criteria
11 criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 10, 1.0)
12 # Perform k-means clustering on the pixel values
13 ret, label, center = cv2.kmeans(
14 pixels, k, None, criteria, attempts, cv2.KMEANS_PP_CENTERS)
15 center = np.uint8(center)
16 res = center[label.flatten()]
17 result_image = res.reshape((img.shape))
18 # Save the segmented image
19 cv2.imwrite('kmeans.jpg', result_image)
20 # Display Results
21 cv2.imshow('Original Image', img)
22 segment_image_based_on_k_means(img)
23 cv2.imshow('K-Means Segmented Image', cv2.imread('kmeans.jpg'))
24 cv2.waitKey(0)

9.3. Solution Procedure


The given code is an implementation of image segmentation using the k-means clustering
algorithm. Image segmentation is the process of dividing an image into multiple segments or
regions, each of which corresponds to a different object or part of the image. The k-means
algorithm is a clustering algorithm that is used to group similar data points together.
The parameters for the k-means algorithm are defined next. The k parameter specifies the
number of clusters to create, while attempts specifies the number of times the algorithm

P a g e | 25
Digital Image Processing Labo ratory

should be run with different initial centroids. The criteria parameter defines the termination
criteria for the algorithm, which is set to stop when either the maximum number of iterations
(10) is reached or the minimum change in cluster centroids is less than 1.0.
The k-means algorithm is then run using the cv2.kmeans() function, which takes as input
the pixel array, the number of clusters (k), the initial centroids (None in this case), the
termination criteria (criteria), the number of times to run the algorithm (attempts), and the
method for selecting the initial centroids (cv2.KMEANS_PP_CENTERS).

The cv2.kmeans() function returns the final cluster centroids in the center variable, as well
as a label array that specifies which cluster each pixel belongs to. The center variable is
converted to an unsigned 8-bit integer array, and the label array is flattened and used to create
a new array ‘res’ of the same shape as the original pixel array, where each pixel is assigned
the RGB values of the cluster centroid it belongs to. Finally, the res array is reshaped into the
shape of the original image, and the resulting segmented image is saved to disk using the
cv2.imwrite() function.

9.4. Output Figure

P a g e | 26
Digital Image Processing Labo ratory

10. EXPERIMENT NO. 10

To create an opencv-python program to sharp a given RGB/grayscale


10 image.

10.1. Some Key Terms Related to This Experiment


Image Sharpening: Image sharpening is a technique used in digital image processing to
enhance the details and edges in an image to make it appear clearer and more defined. The
goal of image sharpening is to increase the contrast of the edges in an image to make them
stand out more.

There are various image sharpening techniques used in digital image processing, including:

• Unsharp masking: This technique involves creating a blurred version of the original
image and subtracting it from the original image to enhance the edges. This is achieved
by convolving the image with a Gaussian filter and subtracting the resulting image from
the original image.
• High-pass filtering: This technique involves filtering the image with a high-pass filter,
which emphasizes the high-frequency components of the image (i.e., the edges) and
suppresses the low-frequency components (i.e., the smooth areas).
• Laplacian filtering: This technique involves convolving the image with a Laplacian filter,
which highlights the areas of the image where the intensity changes rapidly (i.e., the
edges).
• Contrast enhancement: This technique involves increasing the contrast of the image to
make the edges more visible. This can be achieved by applying a histogram equalization
or contrast stretching technique.

10.2. Python Source Code


1 import cv2
2 import numpy as np
3 # Load the image
4 img = cv2.imread('original.jpg')
5 def sharpen_image(img):
6 # Define the kernel for sharpening
7 kernel = np.array([[-1,-1,-1],
8 [-1, 9,-1],
9 [-1,-1,-1]])
10 # Apply the kernel
11 output = cv2.filter2D(img, -1, kernel)
12 # Save the sharpened image
13 cv2.imwrite('sharpened.jpg', output)
14 # Display Results
15 cv2.imshow('Original Image', img)
16 sharpen_image(img)
17 cv2.imshow('Sharpened Image', cv2.imread('sharpened.jpg'))

P a g e | 27
Digital Image Processing Labo ratory

18 cv2.waitKey(0)

10.3. Solution Procedure


This code defines a function sharpen_image() that takes an image as input and applies a
sharpening kernel to it using the cv2.filter2D() function from the OpenCV library. The
sharpening kernel is defined as a numpy array with values that enhance the edges in the image.
The kernel is used to perform image sharpening, where the center element of the kernel has a
large positive value, and the surrounding elements have negative values.
This kernel is passed to the cv2.filter2D() function, which applies it to the image. The
cv2.filter2D() function performs a 2D convolution operation between the kernel and
the image. In the context of image processing, convolution is a mathematical operation that
modifies an image by applying a filter to it.
The cv2.filter2D() function takes three arguments:

• The first argument is the input image


• The second argument is the depth of the output image, which is set to -1 (the same as
the input image)
• The third argument is the kernel used for the convolution operation.
The resulting sharpened image is saved to disk using the cv2.imwrite() function and then
displayed using the cv2.imshow() function. The original image and the sharpened image
are displayed side by side in two separate windows.

10.4. Output Figure

P a g e | 28
Digital Image Processing Labo ratory

11. EXPERIMENT NO. 11

To create an opencv-python program to skeletonize a given


11 RGB/grayscale image.

11.1. Some Key Terms Related to This Experiment


Image Skeletonize: Image skeletonization is a technique used in digital image processing to
extract the essential shape or topological structure of an object in an image. The skeleton of
an object is a set of curves or lines that run through the center of the object and capture its
essential features while preserving its topology.

The process of skeletonization involves iteratively thinning the object until only its skeleton
remains. This is done by repeatedly eroding the object with a structuring element and
subtracting the result from the original object. The structuring element is a small binary matrix
that is used to scan the image and identify pixels that can be removed without changing the
topology of the object.

11.2. Python Source Code


1 import cv2
2 import numpy as np
3 def skeletonize(img):
4 element = cv2.getStructuringElement(cv2.MORPH_CROSS, (3, 3))
5 out = np.zeros(img.shape, np.uint8)
6 flag = 0
7 while (not flag):
8 eroded = cv2.erode(img, element)
9 opened = cv2.dilate(eroded, element)
10 opened = cv2.subtract(img, opened)
11 out = cv2.bitwise_or(out, opened)
12 img = eroded.copy()
13 zeros = img.size - cv2.countNonZero(img)
14 flag = 1 if (zeros == img.size) else 0
15 kernel = np.ones((3, 3), np.uint8)
16 output = cv2.dilate(out, kernel)
17 output = cv2.medianBlur(output, 5)
18 ret, thresh = cv2.threshold(output, 127, 255, cv2.THRESH_BINARY_INV)
19 cv2.imwrite('skeleton.jpg', thresh)
20 # Display Results
21 img_thumb = cv2.imread('thumb.png', 0)
22 ret, img_thumb = cv2.threshold(img_thumb, 127, 255, cv2.THRESH_BINARY)
23 skeletonize(img_thumb)
24 cv2.imshow('Original Image', cv2.resize(img_thumb, dsize=None, fx=0.3, fy=0.3))
25 cv2.imshow('Skeleton Image', cv2.resize(cv2.imread('skeleton.jpg'), dsize=None,
26 fx=0.3, fy=0.3))
27
28 cv2.waitKey(0)

P a g e | 29
Digital Image Processing Labo ratory

11.3. Solution Procedure


This code performs skeletonization on a binary image using morphological operations. The
image is first loaded and thresholded to create a binary image. Then, the function skeletonize
is called which takes the binary image as input.
The function uses a structuring element which is a cross-shaped kernel of size 3x3. The
skeletonization process involves iteratively eroding the image using the structuring element
and then dilating it back, and taking the difference between the eroded and dilated images.
This process continues until the image can no longer be eroded, i.e. it becomes a single-pixel
wide skeleton.
The resulting skeleton image is then dilated and a median blur is applied to smooth out any
rough edges. Finally, a threshold is applied to create a binary image, and the skeleton image is
saved to disk. The original binary image and the resulting skeleton image are then displayed
using OpenCV's cv2.imshow() function.

11.4. Output Figure

P a g e | 30
Digital Image Processing Labo ratory

12. EXPERIMENT NO. 12

To create an opencv-python program to smooth a given RGB /


12 grayscale image by a 2Dfilter.

12.1. Some Key Terms Related to This Experiment


Image Smoothing by 2D Filter: Image smoothing, also known as blurring or filtering, is a
technique used in digital image processing to reduce noise and enhance the overall
appearance of an image. The process involves convolving the image with a 2D filter kernel that
modifies the values of the pixels in the image.

The 2D filter kernel is a small matrix that contains a set of coefficients that determine how
the neighboring pixels contribute to the new pixel value. The most commonly used 2D filter
kernels for image smoothing are Gaussian, median, and mean filters.

12.2. Python Source Code


1 import cv2
2 import numpy as np
3 # Load the image
4 img = cv2.imread('original.jpg')
5 def smooth_image_2D_filter(img):
6 # Define the kernel
7 kernel = np.ones((5, 5), np.float32)/25
8 # Apply the kernel
9 output = cv2.filter2D(img, -1, kernel)
10 # Save the smoothed image
11 cv2.imwrite('smoothed_2D_filter.jpg', output)
12 # Display Results
13 cv2.imshow('Original Image', img)
14 smooth_image_2D_filter(img)
15 cv2.imshow('Smoothed Image Using 2D Filter',
16 cv2.imread('smoothed_2D_filter.jpg'))
17 cv2.waitKey(0)

12.3. Solution Procedure


The code defines a function smooth_image_2D_filter() that performs 2D filtering on
an input image using a predefined kernel of size 5x5. The function takes an image as input,
defines the kernel, applies the filter using cv2.filter2D(), and saves the output image in
a file named 'smoothed_2D_filter.jpg'. The code also includes commented out lines
for displaying the original and smoothed images using cv2.imshow() and
cv2.imread(). However, since cv2.waitKey() is missing, the image windows would
not be displayed until a key is pressed.

P a g e | 31
Digital Image Processing Labo ratory

12.4. Output Figure

P a g e | 32
Digital Image Processing Labo ratory

13. EXPERIMENT NO. 13

To create an opencv-python program to smooth a given RGB /


13 grayscale image by an average filter.

13.1. Some Key Terms Related to This Experiment


Image Smoothing by Average Filter: Image smoothing or blurring using an average filter, also
known as a box filter or a mean filter, is a technique used in digital image processing to reduce
noise and improve the overall appearance of an image. The process involves replacing each
pixel value in the image with the average of its neighboring pixels.

An average filter is a type of linear filter, where each output pixel value is calculated as the
average of the corresponding neighboring pixels within a defined kernel or window size. The
kernel size can vary depending on the level of smoothing desired.

13.2. Python Source Code


1 import cv2
2 import numpy as np
3 # Load the image
4 img = cv2.imread('original.jpg')
5 def smooth_image_average_filter(img):
6 # Define the kernel
7 kernel = np.ones((5, 5), np.float32)/25
8 # Apply the kernel
9 output = cv2.blur(img, (5, 5))
10 # Save the smoothed image
11 cv2.imwrite('smoothed_average_filter.jpg', output)
12 # Display Results
13 cv2.imshow('Original Image', img)
14 smooth_image_average_filter(img)
15 cv2.imshow('Smoothed Image Using Average Filter',
16 cv2.imread('smoothed_average_filter.jpg'))
17 cv2.waitKey(0)

13.3. Solution Procedure


This code reads an image file using OpenCV, then defines a function named
"smooth_image_average_filter()" to smooth the image using the average filter.

The function takes an image as input, defines a 5x5 averaging kernel, applies the kernel
to the input image using the "cv2.blur()" function, and saves the output image as a file
named "smoothed_average_filter.jpg".

The code then displays the original image and the smoothed image using the average filter.
Finally, it waits for a key event to exit the program.

P a g e | 33
Digital Image Processing Labo ratory

13.4. Output Figure

P a g e | 34
Digital Image Processing Labo ratory

14. EXPERIMENT NO. 14

To create an opencv-python program to smooth a given RGB /


14 grayscale image by a Gaussian filter.

14.1. Some Key Terms Related to This Experiment


Image Smoothing by Gaussian Filter: Image smoothing or blurring using a Gaussian filter is a
technique used in digital image processing to reduce noise and improve the overall appearance
of an image. The process involves convolving the image with a Gaussian kernel, which is a 2D
matrix with values sampled from a Gaussian distribution.

The Gaussian filter is a type of linear filter that is widely used for image smoothing because it
can effectively suppress high-frequency noise while preserving the edges and fine details in
the image. The amount of smoothing can be controlled by adjusting the standard deviation of
the Gaussian distribution, which determines the size of the filter kernel.

14.2. Python Source Code


1 import cv2
2 import numpy as np
3 # Load the image
4 img = cv2.imread('original.jpg')
5 def smooth_image_gaussian_filter(img):
6 # Define the kernel
7 kernel = np.ones((5, 5), np.float32)/25
8 # Apply the kernel
9 output = cv2.GaussianBlur(img, (5, 5), 0)
10 # Save the smoothed image
11 cv2.imwrite('smoothed_gaussian_filter.jpg', output)
12 # Display Results
13 cv2.imshow('Original Image', img)
14 smooth_image_gaussian_filter(img)
15 cv2.imshow('Smoothed Image Using Gaussian Filter',
16 cv2.imread('smoothed_gaussian_filter.jpg'))
17 cv2.waitKey(0)

14.3. Solution Procedure


This code demonstrates how to apply Gaussian blur to an image using OpenCV in Python.
Gaussian blur is a commonly used image smoothing technique that blurs an image while
preserving edges and details.
The code loads an image using cv2.imread(), defines a function called
smooth_image_gaussian_filter() that applies Gaussian blur to the image using the
cv2.GaussianBlur() function, and saves the output image using cv2.imwrite().

P a g e | 35
Digital Image Processing Labo ratory

The cv2.GaussianBlur() function takes three arguments: the input image, the size of
the kernel (specified as a tuple), and the standard deviation of the Gaussian distribution used
to generate the kernel. In this case, the kernel size is set to (5, 5) and the standard deviation is
set to 0, which means that it is automatically calculated based on the kernel size.
Finally, the original and smoothed images are displayed using cv2.imshow() and
cv2.waitKey().

14.4. Output Figure

P a g e | 36
Digital Image Processing Labo ratory

15. EXPERIMENT NO. 15

To create an opencv-python program to smooth a given RGB /


15 grayscale image by a median filter.

15.1. Some Key Terms Related to This Experiment


Image Smoothing by Median Filter: Image smoothing or blurring using a Median filter is a
technique used in digital image processing to reduce noise and improve the overall appearance
of an image. The process involves replacing each pixel value in the image with the median value
of its neighboring pixels within a defined kernel or window size.

The Median filter is a non-linear filter that is widely used for image smoothing because it can
effectively suppress impulse noise, which is a type of noise that can randomly occur in the
image due to external factors. The amount of smoothing can be controlled by adjusting the
size of the filter kernel.

15.2. Python Source Code


1 import cv2
2 import numpy as np
3 # Load the image
4 img = cv2.imread('original.jpg')
5 def smooth_image_median_filter(img):
6 # Define the kernel
7 kernel = np.ones((5, 5), np.float32)/25
8 # Apply the kernel
9 output = cv2.medianBlur(img, 5)
10 # Save the smoothed image
11 cv2.imwrite('smoothed_median_filter.jpg', output)
12 # Display Results
13 cv2.imshow('Original Image', img)
14 smooth_image_median_filter(img)
15 cv2.imshow('Smoothed Image Using Median Filter',
16 cv2.imread('smoothed_median_filter.jpg'))
17 cv2.waitKey(0)

15.3. Solution Procedure


This code demonstrates how to apply a median filter to an image using the OpenCV library in
Python. The median filter is a nonlinear smoothing filter that replaces each pixel with the
median value of the neighboring pixels. This filter is useful for removing salt-and-pepper noise
in an image.
The code starts by loading an image using the cv2.imread() function. It then defines a
function smooth_image_median_filter() that takes an image as an input and applies
the median filter to it using the cv2.medianBlur() function. The filter size is defined as

P a g e | 37
Digital Image Processing Labo ratory

(5,5) using the kernel variable. The resulting smoothed image is saved using the
cv2.imwrite() function.

Finally, the original image and the smoothed image are displayed using the cv2.imshow()
function and the cv2.waitKey() function is used to wait for a key event.

15.4. Output Figure

P a g e | 38
Digital Image Processing Labo ratory

16. EXPERIMENT NO. 16

To create an opencv-python program to smooth a given RGB /


16 grayscale image by a bilateral filter.

16.1. Some Key Terms Related to This Experiment


Image Smoothing by Bilateral Filter: Image smoothing or blurring using a Bilateral filter is a
technique used in digital image processing to reduce noise and improve the overall appearance
of an image. The process involves convolving the image with a weighted Gaussian filter, where
the weights are determined by both the spatial distance between pixels and the difference in
pixel values.

The Bilateral filter is a non-linear filter that is widely used for image smoothing because it can
effectively suppress noise while preserving the edges and fine details in the image. The amount
of smoothing can be controlled by adjusting the standard deviation of the spatial Gaussian
distribution and the range Gaussian distribution, which determine the size of the filter kernel
and the weight distribution.

16.2. Python Source Code


1 import cv2
2 import numpy as np
3 # Load the image
4 img = cv2.imread('original.jpg')
5 def smooth_image_bilateral_filter(img):
6 # Define the kernel
7 kernel = np.ones((5, 5), np.float32)/25
8 # Apply the kernel
9 output = cv2.bilateralFilter(img, 9, 75, 75)
10 # Save the smoothed image
11 cv2.imwrite('smoothed_bilateral_filter.jpg', output)
12 # Display Results
13 cv2.imshow('Original Image', img)
14 smooth_image_bilateral_filter(img)
15 cv2.imshow('Smoothed Image Using Bilateral Filter',
16 cv2.imread('smoothed_bilateral_filter.jpg'))
17 cv2.waitKey(0)

16.3. Solution Procedure


This code demonstrates how to smooth an image using a bilateral filter in OpenCV. The
function smooth_image_bilateral_filter() takes an image as input and applies
the bilateral filter with the specified parameters using cv2.bilateralFilter(). The
resulting image is saved to a file called smoothed_bilateral_filter.jpg. The
cv2.imshow() function is used to display the original image and the smoothed image to

P a g e | 39
Digital Image Processing Labo ratory

the user. Finally, the program waits for the user to press a key before closing the windows
using cv2.waitKey().

16.4. Output Figure

P a g e | 40
Digital Image Processing Labo ratory

CONCLUSION

In conclusion, the basic Digital Image Processing lab covers fundamental concepts and
techniques that are essential for anyone interested in image processing. It provides an
understanding of image representation, transformation, enhancement, and analysis, and
introduces practical skills using popular image processing tools and libraries.
Part A of the lab introduced basic techniques such as image reading and writing, color space
conversion, image arithmetic, filtering, thresholding, and contour detection. These techniques
are fundamental to image processing and are the building blocks for more advanced
applications.
Part B of the lab will cover advanced topics such as image segmentation, feature extraction,
object recognition, and deep learning for image analysis. These techniques are essential for
advanced image processing applications and will further enhance the skills and knowledge of
participants.
Overall, the lab provides a comprehensive and hands-on approach to learning image
processing, and equips participants with practical skills that can be applied to a wide range of
image processing applications.

USEFULL LINKS

1. Python Official Download Link (Windows):


https://www.python.org/downloads/windows/
2. Python Official Download Link (Linux):
https://www.python.org/downloads/source/
3. Python Official Download Link (MacOS):
https://www.python.org/downloads/mac-osx/
4. VS Code Official Download Link (Windows):
https://code.visualstudio.com/docs/setup/windows
5. VS Code Official Download Link (Linux):
https://code.visualstudio.com/docs/setup/linux
6. VS Code Official Download Link (MacOS):
https://code.visualstudio.com/docs/setup/mac

P a g e | 41

You might also like