Homework 1

CS 585 HW 1
Andrea Fariņa
01-29-2020

Problem Definition

In your lab section on Friday, Janurary 24, you learned how to input an image into your code, process it, and output it. The goal of this part of the assignment is to further familiarize you with programming with images. Your program should take an image of your face as an input, manipulate it in three ways and then output the processed face:

1. Create a grayscale image of your face by converting your color image using one of the conversions we discussed in class last week.
2. Flip your face image horizontally, i.e. left to right, right to left.
3. Come up with a third way of manipulating your face that produces an interesting output. For example, you may create a blurred image of your grayscale face by assigning to each pixel the average grayscale pixel value of itself and its 8 neighbors. Hint: You may have to run your program a few times to make the blurring noticeable.

Method and Implementation

1.

For every pixel I took its 3 RGB values and computed the average value and I created a CV_8UC1 and assigned for that same pixel index position the average value of (R+G+B)/3.

2.

I created a CV_8UC3 data type, because it will be an RGB image, so it needs 3 values. I flipped the pixels by assigning the pixel (i,j) value to the pixel (i, number of columns-j-1). To do a right to left flip.

3.

I added all the grayscale values of the pixel (i,j) and its 8 neighbours and divided by 9. Then I created a CV_8UC1 and assigned those values to each (i,j) pixel. This algorithm had to be performed 10 times in order to have visible blurring results.

Experiments

For part 3 I had to repeat the blurring process because the first time I computed the pixel assignation with the average of the pixel and its 8 neighbours, I could not tell a difference, then I repeated the algorithm five times but the blur was not obvious yet. In the end I decided to implement the average assignation of the pixel's value 10 times.

Results

Results

Source Image Result Image Exercise
1. Grayscale
2. Flipped
3. Grayscale blurred