Skip to end of metadata
Go to start of metadata

For this project, I worked on a program that applies four different filters to a given image. 

Here is my original image:

For the first task, I made a method that loops over each pixel of the image and changes its blue value. 

The second task was to binarize the image into black and white. This is with a threshold of 120. Everything above that becomes black, everything at or below it white. I used OpenCV's threshold function for this.

The third task was to flip the image horizontally. This was easy enough, and just requires OpenCV's built-in flip function each time.

The next task was to apply an additional filter to the image, for which I chose a Gaussian blur. This is also made possible by a built-in OpenCV function. I decided to do an 11x11 blur with a standard deviation of three on both axes.

All of these modifications can be done with the keyboard keys h, j, k and l. I made a function that waits for the correct type of key input to execute the functions, and recursively calls itself to continue waiting otherwise. There did not seem to be a more efficient way to catch key events and prevent the program from closing on waitKey(0) otherwise. I made it so the ESC key will close the program, though.

Pressing "h" flips the image back and forth on each press, while the other keys, upon being pressed again, simply return to the default image. The effects can be overlapped, such as blue with a flip, but selectively undoing the blur filter, thresholding, and blue-increasing methods proved to be tough tasks that may require researching reversal/inversion algorithms, so I decided to leave them be for now, and possibly approach them in a future project.

As an extension, I added on to the GUI by making a slider for changing the blue values. To this end, I changed the existing method to take in a given value to change the blue values of each pixel to. Each time the user touches the slider, the method is called, and the values update to match the value on the slider. (I also *tried* to explore facial detection before realizing that the dwarf I was using didn't have the library I was trying to use on it)

If I were to change something about the project, I would make the function that waits for keys less redundant, because it has a lot of code duplication that could be made more elegant. But as a whole, it was a good introduction to the OpenCV library.