This is a practice to get to know OpenCV. The exercise can be described as simple image manipulation, which can be considered very important to any image editing software. The anticipated difficulty is not having knowledge on the library and basic data structures that it has.
Method and Implementation
The methods implemented consisted mostly of going through the pixels of the image and changing their intensities. This includes the intensities of RGB values to create a grey scale and switching pixels with other pixels so a flipped image can be created.
The function used for greyscale looped through the pixels on the image, used a formula (0.3*red + 0.6*green + 0.1 * blue) to average the RGB values, and then changed the image's original RGB values to the result of the formula.
For the flipping, the loop goes to half of the columns of the image and for each pixel on one side, it found a corresponding pixel on the other half of the image and exchanged intensity values of both.
As for the black and white transformation, the code looped through the whole image and if the intensity was larger than 127 (which is halfway through 255), then it considered the pixel white, otherwise the pixel is black.
As it was required, I used a picture of my face to conduct the tests, for most of the trials the code did not compile, but when it did the results were what was expected.
|Trial||Source Image||Result Image|
|Black and White|
Discuss your method and results:
- The results were very defined, as they are applicable to almost all pictures.
- The grey scale transformation could have also transformed the image into a 1 channel image instead of 3. Also, the black and white can be adjusted depending on the picture so it can be more clear on what is depicted.
There are improvements that can be made, but the project reached its objective, which was to further my knowledge on C++ and OpenCV.
Credits and Bibliography
Credit to Yifu (TA) that helped me a lot with this.