Assignment 1

CS 585 HW 1
E Chengyuan

Jan 29 2020

Problem Definition

The problem is to process images in different ways with my own functions . The program needs to input an image of my face, turn it into grayscale image, flipped image, and blurred image, and then output these images. The goal is to get more familiar with programming with images based on what I've learned in class.

Method and Implementation

The main idea is to create a grayscale version of my face, flip the image of my face horizontally, create a salt noise version of the image and denoise the salted image by mean filter. So, I wrote four functions to manipulate images in order that they all turn out to be what are required. For the grayscale image, I created the grayscale function in which I used two for loops to go through every row and column to get every pixel. Once getting to a new pixel, convert three values to one by dividing the sum value of red, green and blue channels by three and assign the value to the pixel of output image in the same position by using the formula 0.07 * img[i,j,0] + 0.72 * img[i,j,1] + 0.21 * img[i,j,2], 0, 255. For the horizontal flipped image, I created the flip function in which I used the same way as mentioned above to get every pixel. Once getting to a new pixel, assign three values to the symmetry pixel of output image. For the blurred image, I created the Gaussianblur function. In this approach, instead of a box filter consisting of equal filter coefficients, a Gaussian kernel is used. It is done with the function, cv2.GaussianBlur(). We should specify the width and height of the kernel which should be positive and odd. We also should specify the standard deviation in the X and Y directions, sigmaX and sigmaY respectively. If only sigmaX is specified, sigmaY is taken as equal to sigmaX. If both are given as zeros, they are calculated from the kernel size. Gaussian filtering is highly effective in removing Gaussian noise from the image.


Methods Images
Horizontally flip
Gaussian Blur


Discuss your method and results:


The overall performance of output images is successfully. Taking the image of my face as an input, manipulating it in 3 ways and outputting the processed face. I am able to manipulate images to produce different outputs, which can be used to solve problems in image processing. Also, other solutions discussed above can be further implemented to improve performances.

Credits and Bibliography