Assignment Title

CS 585 HW 1

Georgios Karantonis

1/29/2020

Problem Definition

The goal of this assignment is to create an image processing system that takes as input a facial picture and outputs various alternations of it. More specifically, given the original picture, our system creates grayscale, flipped horizontally and blurred copies of it.

Method and Implementation

The image is represented by a matrix, each cell of which consists of 3 values that correspond to the colors red, green and blue.

In order to convert the image to grayscale, we iterated over each cell of the picture and multiplied its value by the vector [0.2989, 0.5870, 0.1140]. Each value of this vector represents the scale we are going to use for each color in order to convert the image to grayscale.

For the horizontal flip of the image we iterated over half of the columns of the matrix and at each iteration we switched the position of the current column with the column that has a distance equal to the current index from the last column of the matrix. In order to make this procedure more clear let’s suppose that we have an Nx10 matrix and that after a few iterations we are now examining the column with index 3. So we place the column with index 3 to the position of the column with index 6 (since the matrix has 10 columns the respective indices are 0-9) and the column with index 6 is place to the position of the column 3. Also, in order to avoid using extra memory, as it is usually required in such procedures we perform the permutation in the following manner; we will call ‘a’ the column with index 3 and ‘b’ the column with index 6:

a = a - b

b = a + b

a = b - a

Now ‘a’ has the original value of ‘b’ and ‘b’ has the original value of ‘a’.

Regarding the blurring of the image we performed convolution in the picture matrix. More specifically, we used a kernel of size 10x10 and we passed it over the whole image. At each step we performed the convolution by averaging (because our kernel consists of only 1s) over all the cells that fall inside the window (we also divided afterwards by 256 which is the number of all possible color values). The result of each convolution step was saved to the corresponding cell of another matrix creating this way the final blurred image.

Experiments

The code of this assignment is located in the file hw1-Karantonis.zip

Results

 Original Grayscale Flipped Blurred