P.pranay Kumar 21BAI1504 Exp-09

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Name: P.

Pranay Kumar
Reg no:21BAI1504
Faculty:Dr.Palani Thanaraj

EXPERIMENT - 9
Morphological Image Processing
Aim: To perform image morphing (erosion and dilation) along with watershed algorithm
implementation in python.

Resources Used: Anaconda Python Environment


Google Colab Jupyter Notebook

Theory
OpenCV (Open-Source Computer Vision Library) is an open-source computer vision and machine
learning software library. OpenCV was built to provide a common infrastructure for computer
vision applications and to accelerate the use of machine perception in the commercial products.
NumPy is a library for the Python programming language, adding support for large, multi-
dimensional arrays and matrices, along with a large collection of high-level mathematical functions
to operate on these arrays.
Matplotlib is a plotting library for the Python programming language and its numerical
mathematics extension NumPy. It provides an object-oriented API for embedding plots into
applications using general-purpose GUI toolkits like Tkinter, Python, Qt, or GTK.

Tasks:
Task 1: Perform morphological erosion and dilation operation of an input image and observe the
output. Use different structuring element and compare the morphological output.

Task 2: Perform segmentation of the COIN image using watershed algorithm. Prepare the input
image suitable for watershed algorithm to work namely
a) conversion to binary
b) performing morphological operations to remove noises
c) determine the markers for initializing the seed point for the image. Finally display the
segmented output namely coins in different colors.

Procedure:
Open Google Colab and create a new Jupyter Notebook.
Import the required libraries which are OpenCV, Matplotlib, Numpy and Ipython Display.
Task 1: Perform morphological erosion and dilation operation of an input image and observe the
output. Use different structuring element and compare the morphological output.

Read the image in grayscale and perform erosion and dilation on it with custom kernels and display
them in subplots side by side.
Task 2: Perform segmentation of the COIN image using watershed algorithm. Prepare the input
image suitable for watershed algorithm to work namely
a) conversion to binary
b) performing morphological operations to remove noises
c) determine the markers for initializing the seed point for the image. Finally display the
segmented output namely coins in different colors.
Read the image of coins.

Convert the image to grayscale.


a) Convert the image into a binary image.

b) Performing morphological operations to remove noises Noise Removed binary image


Background and foreground of the image

Coins marked in different colors.


Using watershed algorithm to outline and segment the coins in the image.

Results: The given tasks have been done using programs in Python using Numpy,Matplotlib,
OpenCV and Image libraries.

Conclusion: Python program have been created to perform Erosion Dilation using
morphological operations and applying watershed algorithm to segment coins
from a coins image, to output the coins in different colors and outlinethem.

You might also like