0% found this document useful (0 votes)
29 views

LAB1

Here are the key steps for the assignment: 1. Define smoothing and sharpening kernels with user-defined centers 2. Apply each kernel to grayscale images using convolution 3. For color images, apply kernels separately to each RGB/HSV channel 4. Subtract results of RGB and HSV convolutions to compare differences 5. Implement Gaussian and mean smoothing, and Laplacian/LoG sharpening 6. Convolve images with Sobel filters as well 7. Output original and filtered images for comparison In summary, the assignment involves designing filters, applying them to grayscale and color images through convolution, and comparing the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

LAB1

Here are the key steps for the assignment: 1. Define smoothing and sharpening kernels with user-defined centers 2. Apply each kernel to grayscale images using convolution 3. For color images, apply kernels separately to each RGB/HSV channel 4. Subtract results of RGB and HSV convolutions to compare differences 5. Implement Gaussian and mean smoothing, and Laplacian/LoG sharpening 6. Convolve images with Sobel filters as well 7. Output original and filtered images for comparison In summary, the assignment involves designing filters, applying them to grayscale and color images through convolution, and comparing the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

CSE 4128

Image Processing and Computer Vision


Laboratory
Dr. Sk. Md. Masudul Ahsan Dipannita Biswas
Professor Lecturer
Dept. of CSE, KUET Dept. of CSE, KUET

1
Course Outlines

WEEK 1 Convolution

WEEK 2 Segmentation applying edge detection and thresholding


WEEK 3 Histogram equalization and matching

WEEK 4 Frequency Domain Filtering

WEEK 5 Region Descriptors

WEEK 6 Project Showcasing

2
Week 1

Topic: Convolution

3
Image Processing
Image processing is converting an image to a digital format and applying various
functions to it to create a better image or extract additional information from it.

Digital Image: is present in pixelated form.


• Grayscale Image: Every pixel size is one byte and has a variation of 256 colors
from black to white.
• Color Image: composed of multiple color channels, each representing the
intensity of a specific color or perceptual feature. The most common color
models:
• RGB(Red, Green, Blue),
• HSI(Hue, Saturation, Intensity), and
• HSV(Hue, Saturation, Value).

4
Digital Image

y
Grayscale Image Color image in RGB space

5
Digital Image

Color image in RGB space

Figure(Left to
right): Blue,
Green, Red
Channel
6
Python as Task Language
• Ease of readability and ease of learning
• Extensive libraries present, the majority are open source and free.
• Generally slower than C++ in terms of raw performance but more
user-friendly.

Libraries:
• OpenCV (Open Source Computer Vision Library)
• Pillow (PIL Fork)
• NumPy
• Matplotlib
7
OpenCV
• OpenCV is faster than PIL
• OpenCV and PIL both can do general image manipulation and
processing tasks.
• It also can perform certain computer vision-specific operations, unlike
PIL, like object detection, feature extraction, image segmentation, etc.
• Integrates well with libraries like NumPy, scikit-learn, TensorFlow, and
other computer vision and machine learning libraries.

8
Convolution
• Convolution is an operation performed on two functions to produce a
third function.
• In image processing, convolution is the process of transforming an
image by applying a kernel over each pixel and its local neighbors
across the entire image.
• The convolution operation applied on Image I(x,y) using a kernel F is
given by

9
Convolution

1 1 0 1 0 0 0 0 0 0
1 2 3
0 0 1 0 0 0 0 0 0 0

0 1 0 0 1 4 5 6 0 0 0 0 0

1 0 1 0 1 7 8 9 0 0 0 0 0

0 1 1 1 0 0 0 0 0 0

F I(X,Y) F * I(X,Y)

10
Convolution

1X 1X8 0X7 1 0 0 0 0 0 0
9
1 2 3
0X 0X 1X 0 0 0 23 0 0 0
6 5 4
4 5 6 0 0 0 0 0
0X 1X 0X 0 1
3 2 1
7 8 9 0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
0 1 1 1 0

F I(X,Y) F * I(X,Y)

11
Convolution

1 1X9 0X8 1X7 0 0 0 0 0 0


1 2 3
0 0X 1X 0X 0 0 23 24 0 0
6 5 4
4 5 6 0 0 0 0 0
0 1X 0X 0X 1
3 2 1
7 8 9 0 0 0 0 0
1 0 1 0 1

0 1 1 1 0 0 0 0 0 0

F I(X,Y) F * I(X,Y)

12
Convolution

1 1 0 1 0 0 0 0 0 0
1 2 3
0 0 1 0 0 0 23 24 15 0

0 1 0 0 1 4 5 6 0 0 0 0 0

1 0 1 0 1 7 8 9 0 0 0 0 0

0 1 1 1 0 0 0 0 0 0

F I(X,Y) F * I(X,Y)

13
Convolution

1 1 0 1 0 0 0 0 0 0
1 2 3
0 0 1 0 0 0 23 24 15 0

0 1 0 0 1 4 5 6 0 16 0 0 0

1 0 1 0 1 7 8 9 0 0 0 0 0

0 1 1 1 0 0 0 0 0 0

F I(X,Y) F * I(X,Y)

14
Convolution

1 1 0 1 0 0 0 0 0 0
1 2 3
0 0 1 0 0 0 23 24 15 0

0 1 0 0 1 4 5 6 0 16 16 0 0

1 0 1 0 1 7 8 9 0 0 0 0 0

0 1 1 1 0 0 0 0 0 0

F I(X,Y) F * I(X,Y)

15
Convolution

1 1 0 1 0 0 0 0 0 0
1 2 3
0 0 1 0 0 0 23 24 15 0

0 1 0 0 1 4 5 6 0 16 16 17 0

1 0 1 0 1 7 8 9 0 0 0 0 0

0 1 1 1 0 0 0 0 0 0

F I(X,Y) F * I(X,Y)

16
Convolution

1 1 0 1 0 0 0 0 0 0
1 2 3
0 0 1 0 0 0 23 24 15 0

0 1 0 0 1 4 5 6 0 16 16 17 0

1 0 1 0 1 7 8 9 0 21 0 0 0

0 1 1 1 0 0 0 0 0 0

F I(X,Y) F * I(X,Y)

17
Convolution

1 1 0 1 0 0 0 0 0 0
1 2 3
0 0 1 0 0 0 23 24 15 0

0 1 0 0 1 4 5 6 0 16 16 17 0

1 0 1 0 1 7 8 9 0 21 20 0 0

0 1 1 1 0 0 0 0 0 0

F I(X,Y) F * I(X,Y)

18
Convolution

1 1 0 1 0 0 0 0 0 0
1 2 3
0 0 1 0 0 0 23 24 15 0

0 1 0 0 1 4 5 6 0 16 16 17 0

1 0 1 0 1 7 8 9 0 21 20 22 0

0 1 1 1 0 0 0 0 0 0

F I(X,Y) F * I(X,Y)

19
Installation

• Download Anaconda installer.


• Installation link: https://docs.anaconda.com/anaconda/install/
• OpenCV installation on Anaconda prompt:
• pip install opencv-python
• pip install opencv-contrib-python

• For updating pip: python -m pip install --upgrade pip

20
Classwork

Input

Output

21
Assignment
1. Apply Convolution using both smoothing and sharpening kernels on
a grayscale image and output the results.
2. Repeat the process for the Color image:
1. Take an RGB image and apply convolution with each kernel, applying
convolution separately on each channel.
2. Convert the RGB image to HSV mode and apply convolution with each
kernel, applying convolution separately on each channel of HSV space.
3. Subtract the resulting image obtained from the RGB and HSV modes
to distinguish their differences.
3. Repeat (2) for both smoothing and sharpening kernels.

22
Assignment
Instructions for Filters:
1. The center of each kernel should be user-defined. Don’t fix it in the
center.
2. Use smoothing filters like the Gaussian blur filter and Mean filter.
1. For the Gaussian filter, create a filter function with parameters σx, σy (which will
be user-input) such that it satisfies:

3. Use Sharpening filters like the Laplacian filter, and Laplacian of a


Gaussian (LoG) filter for each operation.
4. Try with the Sobel filter.
23
Assignment
• Instructions for Assignment:
1. Everyone must generate separate windows to show their input
image, output image with each transition, and the
KERNELS (such as Gaussian, Laplacian, LOG) that they used to
generate outputs.
2. Ensure the presence of a menu-style system enabling us to select
specific sections of the assignment for assessment. For instance,
selecting option 1 could allow the examination of the outputs of the
Gaussian function on a grayscale image, while option 2 could allow
checking it on a color image, and so forth.

24
Assignment(Example)
i. Applying Gaussian filter

Convoluted in RGB space

Input image Difference between the outputs

25
Convoluted in HSV space

You might also like