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.
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.
|Trial||Source Image||Result Image|
Discuss your method and results:
- The strengths is that the algorithms are easy to code and modify and the weakness is that the runtime is rather slow.
- The results show that my method is generally successful and the limitations might be the use of memory. The result images are that the images turn gray or flipped or blurred and the results are noticeble by eyes.
- There are possibly faster methods to visit all pixel other than one by one which can be improved later.
The conclusion is that the result images are generally successful since all these result images fit the requirements of the task.
Credits and Bibliography