You are on page 1of 3

FOCP-Assignment 3

National University of Sciences & Technology (NUST)


School of Electrical Engineering and Computer Science (SEECS)
Faculty of Computing

CS 110: Fundamentals of Computer Programming


Assignment # 3
Assignment Date: 28/11/2023 Due Date: Thursday, Marks: 20
11/12/2023, (23:59)
CLO Attainment: [CLO-2] Solve given real-world problem by applying appropriate
programming concepts and techniques

Assignment Title: Image Convolution Using C++


Learning Objectives:

• Develop the ability to decompose a complex problem (image convolution) into smaller,
manageable tasks.
• Understand different ways to use 2-Dimensional arrays. In this case, to represent an
image and the kernel.
• Practice modular programming.
• Develop the ability to document code effectively, providing clear explanations of
function purposes, parameters, and usage.
Overview:
Convolution is a powerful operation in image processing and is a fundamental concept in
Convolutional Neural Networks. In this assignment, you are required to implement a C++
program that performs image convolution using a given kernel.
Tentative Workflow:

• Generate a random image of size 6x6 and a kernel of size 3x3 using 2-Dimensional arrays.
• Display the generated image and the convolution kernel.
• Perform convolution and display the resulting image.
• Ensure the program handles edge cases appropriately by applying zero-padding.

The following equation represents the sizes of input and output with the same padding.

[(n + 2p) x (n + 2p) image] * [(f x f) filter] —> [(n x n) image].

The value of p = (f-1)/2 since (n+2p-f+1) = n

We can use the above formula and calculate how many layers of padding can be added to get
the same size as the original image. For example, if we use a 6x6 image and 3x3 filter we need 1
layer of padding [P = (3 -1)/2 = 1] to get 6x6 output image.

1|Page
FOCP-Assignment 3

The program should be modular, with separate procedures for generating a random image and
a kernel, performing convolution, applying zero-padding, and displaying the result.
By working on this assignment, students will enhance their problem-solving skills in the context
of image processing while gaining valuable experience in modular programming and 2-
Dimensional arrays.
Follow C++ coding standards and best practices. Use meaningful variable and function names.
Employ proper indentation and code formatting. Use commenting for code understanding.
Submission Guidelines:
Code Submission:

• Submit a well-commented C++ source code file (.cpp) with appropriate modularization.
Documentation:

• Provide a brief document explaining the structure of your program and the role of each
function.
• Include a sample 6x6 image and apply convolution (by hand) with zero-padding on it using
a sample 3x3 kernel. Show the working and final output.
Demo and Viva:

• Demo and viva will be conducted in the lab.


Submission Criteria:

• This is a group assignment.

2|Page
FOCP-Assignment 3

• Submit the assignment in the form of a .zip folder using the nomenclature
FirstMemberName-SecondMemberName-Class-Section.zip on the LMS.
• Inside the .zip folder, include the following:
o A report in the .pdf document format using the nomenclature
FirstMemberName-SecondMemberName-Class-Section.pdf. Clearly mention
the names of each group member on the title page.
o A well-commented C++ code saved as FirstMemberName-
SecondMemberName-Class-Section.cpp file.
Both members should submit the same .zip folder in LMS to allow marking. Late submissions are
not accepted. Plagiarism will be marked zero.

Grading Rubric

Needs
Component Criteria Excellent Improvement Inadequate
(2) (1) (0)
Modularity
Image and kernel generation
Implementation Convolution Procedure
Zero Padding
Testing

Convolution by Hand
Documentation Well-commented code
+
Coding standards
Code
Maintenance Demo
Viva

3|Page

You might also like