In this project, I worked with images and learnt a little more about c-programming. I created a variety of programs for different purposes. For example a masking program that turned a bluescreen image into a mask and a merging program that merged images together. From doing all this, I was able to super-impose two pictures on top of each other.
The first major task that I had was to do something different to the image that we were provided with. Also, I had to create a program that took in a bluescreen image and returned a mask of that image. Then I had to write a program that takes in two images and a mask image and merges the two images using the mask as an alpha mask. After this, I added the ability to add an x and y offset by which one could merge the two pictures. Then, as an extension, I tried to make the mask so that it has in-between values for pixels on the edge.
Theory and Algorithms
For the first task, all I did was change the lines that assigned the rgb values of each pixel and set the r to half its original value, the green to half its value and the blue to a quarter of its value. For the next task, I simply found a value called the bvalue that was the difference between the blue value and the average of the red and green vales. If this value was greater than a threshold, then I set the mask value to 1 and if not, I set it to 0. To create the merging program, I allowed the user to input the images they wanted to merge, along with the mask and then I used the alpha function to create a new image that had the two images combined. To get the offset effect, I simply allowed the user to input a dx and a dy and then I made the calculation:
where cols is the number of columns and i is the index of the pixel in the image. Then, I used this offset for the image2 and the mask like:
For the extension, in my masking program, I added an else if in my if statement as follows:
By doing this, the pixels on the edge were given in-between values.
This is the initial and final picture of the tree:
As you can see, the algorithm has given a yellowish tint to the picture like a fog before sunrise. This are the initial and final pictures:
This is the merged picture before and after. I was also able to create a funny-looking picture using the offset ability:
For the extension, I made an image that was especially sharp and took the edges into consideration:
If you look at tis picture closely, you can see that my hair is not cut into angles like the previous ones and there is a better shape to it.
Discussion and Summary
In summary, I feel like the bluescreen Image program could have been better optimized to notice all the levels of blue that still remained on the edge. Also, I have seen that these programs can be used to make very interesting pictures. Also, I now have a much better understanding of c and how all of the features work. In conclusion, I think this was a very successful project and I can't wait for the next one.