Implementing 2D Convolution

I implemented 2D Convolution from scratch in this project. (Link to Github Repo of Source Code) I recorded my output and performance results below. Link to post on medium.

The parameters associated with each of the tasks is given below.

PART A

The following two input images were used to carry out the 2d convolutions described in task A.

A Cartoon Image (1280 x 720)

A Checkerboard Image (1920 x 1080)

The output for part A is given below. The normalized output for part A is included at the end of the file.

Task 1

The following two images were produced using kernel_1. The checker board result indicates that kernel 1 functions as a form of horizontal edge detector. cartoon_task1_k1

checker_task1_k1

Task 2

The following two images were produced using kernel_4.The checker board result indicates that kernel 4 also functions as a form of horizontal edge detector. We also observe that the edge detection is more pronounced in this case. cartoon_task2_k4

checker_task2_k4

The following two images were produced using kernel_5. The checker board result indicates that kernel 5 functions as a form of vertical edge detector. cartoon_task2_k5

checker_task2_k5

Task 3

Note that all the output images are smaller than the input image due to stride value being greater than 1.

The following two images were produced using kernel_1.The checker board result indicates that kernel 1 functions as a form of horizontal edge detector. cartoon_task3_k1

checker_task3_k1

The following two images were produced using kernel_2. The checker board result indicates that kernel 2 functions as a form of vertical edge detector. cartoon_task3_k2

checker_task3_k2

The following two images were produced using kernel_3. This kernel is supposed to be a smoothing filter. cartoon_task3_k3

checker_task3_k3


PART B

Graphs showing the time taken for convolution as a function of the i Values (where 2^i = number of output channels), for each of the input images is given below. part_b_1

part_b_1


PART C

Graphs showing the number of operations in the convolutions as a function of the given kernel sizes, for each of the input images is given below. part_c_1

part_c_1


Normalized Output for PART A

Task 1

The following two images were produced using kernel_1. cartoon_task1_k1

checker_task1_k1

Task 2

The following two images were produced using kernel_4. cartoon_task2_k4

checker_task2_k4

The following two images were produced using kernel_5. cartoon_task2_k5

checker_task2_k5

Task 3

The following two images were produced using kernel_1. cartoon_task3_k1

checker_task3_k1

The following two images were produced using kernel_2. cartoon_task3_k2

checker_task3_k2

The following two images were produced using kernel_3. cartoon_task3_k3

checker_task3_k3

Written on April 6, 2018