Assignment HW1

CS 585 HW 1
Donghyun Kim
09/14/2017


Problem Definition

Given an RGB face image, we need to create (1) gray scale and (2) blur image of the face.
Additionaly, we come up with a new way to manipulate the face image in order to create (3) an intersting face image.


Method and Implementation

(1) Gray image
for x=0,y=0 to x=OriginalImage.width-1, y=OriginalImage.column-1
  Gray(x,y) = (OriginalImage(x,y,B) + OriginalImage(x,y,G) + OriginalImage(x,y,R))/3

B,G,R represent value of BGR channels in the originalImage
In the loop, it calculates the average RGB value and assign its value to the gray array.

(2) Blur Image
for x=0,y=0 to x=Gray.width-1, y=Gray.column-1
 for neightboring 8 pixels and itself
  if pixel exists (inside the image size boundary)
    Blur(x,y) = Calculate average gray value
In the loop, it checks existing neighboring pixels, calculates the average gray values of neighboring pixels and itself, and assign its value to the gray array.

(3) Sharp Image
Contrary to the (2) Blur Image, I intend to create sharp image using Laplacian filter

value = 0
for x=0,y=0 to x=Gray.width-1, y=Gray.column-1
 for neightboring 8 pixels and itself
  if neighboring pixel exists (inside the image size boundary)
   value = value - neighborpixels
  if pixel is itself
   value = value + 9*itself
 Sharp(x,y) = value

In the loop, it checks existing neighboring pixels, substracts all the neighboring pixels from 9*itself value, and assign its value to the gray array.


Experiments

(1) First, I used my face image, 'face.jpg' (RGB). After reading the image with opencv library, I created gray image.
(2)With the generated gray image, I generated blur image and sharp image below.
In the Results section, we can qualitatively check how the image changes.


Results

Experimental results. (1) Gray image, (2) Blur image, and (3) Sharp image

Results

Trial Source Image Result Image
(1) Gray image
(2) Blur image
(3) Sharp image


Discussion

Discuss your method and results:


Conclusions

I learned simple usage of OpenCV functions and how to manipulate an image as we want to. In addition, there are many ways for the same task.
For example, in order to make a gray scale image, we could use many different ways.
It is quite hard to say that a certain method is superior to all other methods for every task.
Therefore, sometimes it is important that find a method which is appropriate to our task and shows the best performance.


Credits and Bibliography

HW1: http://www.cs.bu.edu/fac/betke/cs585/restricted/hw1/
Lecture slide: http://www.cs.bu.edu/faculty/betke/cs585/restricted/lectures/image-formats-projections-Fall2017.pdf
Laplacian filter: https://homepages.inf.ed.ac.uk/rbf/HIPR2/log.htm