Assignment 1

CS 585 HW 1
Lunhao Liang
No Teammate
Sept. 11, 2018


Problem Definition

In your lab section on Friday, September 7, 2018, 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.

Please collect your code, your input image and your output images in one directory called hw1-YourLastName and zip them.

Please follow our naming convention. It helps us locate your files (especially if they ended up in the wrong directory or were submitted late) and speeds up the grading process.

Transfer your zip file to your homedirectory on csa1.bu.edu, csa2.bu.edu, or csa3.bu.edu. Use the command gsubmit to submit your zip file to our grader. If you have never used gsubmit, please check this web page.


Method and Implementation

In this assignment I implemented 3 funtions programming with images. Here I use one of my face image as the input image. The functions' details are listed below.

1. I create a grayscale image of my face by setting each pixel's red, blue and green color channels as (R+G+B)/3, the R G B is the value of each pixel's red, blue and green color channels in the input image.

2. I flip my face image horizontally by exchanging the value of first half pixels and the second half pixels which are symmetrical about the middle pixel of the same row.

3. I create a blurred image of my grayscale face by assigning to each pixel the average grayscale pixel value of itself and its 8 neighbors. For the boundary piexls I do not do any operation to them because the boundary logic to processing them is too complicated, the effciency is low and boundary pixels nearly have no influences on the final output image. One more thing is I run this method 20 times to make the blurring noticeable.

Briefly outline the functions you created in your code to carry out the algorithmic steps you described earlier.

I wrote three funcitons in this program:

  • void tintImageGrey(Mat& image): to turn the input image into a grayscale image
  • void FlipImageHorizontally(Mat& image): to flip the input image horizontally
  • void BlurringImage(Mat& image): to blur the image input

  • Experiments

    I use one of my face image as the original input image.

    File NameImage
    input_face_image.jpgInout Face Image

    Results

    The output images are listed below.

    File NameImage TypeImage
    grayscale_face_image.jpgGrayscale Image
    flipped_grayscale_face_image.jpgFlipping Image
    blurred_face_image.jpgBlurring Image
    (Run 20 times)

    Discussion

    Discuss your method and results:


    Conclusions

    Based on the discussions, I learnt so much on basic operation of OpenCV.


    Credits and Bibliography

    https://en.wikipedia.org/wiki/Grayscale