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:
I use one of my face image as the original input image.
The output images are listed below.
|File Name||Image Type||Image|
(Run 20 times)
Discuss your method and results:
- My method to turn an origin image into grayscale is simply using (R+G+B)/3 it is very fast but the shadow and light in image is not good enough than other algorithms. In my method blurring the image, I don't do any operation on boundary piexls 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. But if we do not operate boundary pixels and if the image resolution is low, the boundary of the image will be unnaturally different with the middle part of the image, that is the disadvantage.
- The results show that my method is generally successful. In this experiment, I want to get farmilier with basic operation on pixels in OpenCV I think my goal is achieved.
- Potential future work: I can improve my boundary logic in the future in my blurring algorithm to make the boundary of blurring image seems more naturally.
Based on the discussions, I learnt so much on basic operation of OpenCV.
Credits and Bibliography