Assignment Title

CS 585 HW 1
Yuansheng Dong

9.12.2018


Problem Definition

The problem is that to input an original image and convert the image to the grayscale image, flip the image horizontally and blur the grayscale image. The result of the assignment could help to familiarize the programming with images since these three tasks are the basic operations to the image and could be used in later tasks. I made the assumpiton that these three problems share the same idea that to deal with each pixel could solve the problem. And the anticipated difficulty is that operations to pixels could cause unexpected errors when coding.


Method and Implementation

1.We are supposed to output the grayscale image. There are three possible algorithm to get a grayscale and I chose to use the weighed algorithm which means the pixels in the grayscale image is corresponding the weighed of the rgb three channels of the pixels in the original image. The first step of the algorithm is to create a single channel grayscsale image and two pointers which point at the start of the original image and the grayscale image. Then, calculate the weighed value of three channels of the first pointer and assign it to another pointer and move the pointer until the end.
2.To flip the image horizontally is almost the same as the first part. Firstly create an image of three channels which means it's a colorful image. Then use two pointers, the first points at the first of a row of the original image and the other points at the end of a row of the result image. Simply copy the value of the first pointer to the other and move two pointers until the end of the row and then move to the next row until all the image is ergodic.
3.To get a blurred image is to make the value of each pixel the average of the 8 contiguous pixels and itself. So the algorithm is to create a grayscale image as a result iamge and then visit each pixel in the result image and make it the average of the 9 pixels including itself. The first and the last row or the first and the last column keep unchanged. To make it noticeble, repeat these steps 20 times.

All functions are created in the main function but each part has an annotation.


Experiments

There are three available algorithms in the first part and I tried all three and chose the last one because it seems approximately more close to the noticeble grayscale image. The second part is simply to accomplish and no other try. The third part I tried to use pointers to visit pixels but I think it's quite complex to code.

Since all three algorithms should visit all pixels, the complexity is O(n^2). The detection rates and the running time based on the pixel numbers of the orignal image. The accuracies in this assignment are quite well.


Results

Results

Trial Source Image Result Image
trial 1
trial 2
trial 3


Discussion

Discuss your method and results:


Conclusions

The conclusion is that the result images are generally successful since all these result images fit the requirements of the task.


Credits and Bibliography

https://blog.csdn.net/weixin_37720172/article/details/72627543 5/22/2017