Pages Titobiloluwa's CS351 Page Project 1

Abstract

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.

Problem Description

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:

alpha = mask[offset].r/255; image1[i].r = alpha*image1[i].r + (1 - alpha)*image2[offset].r

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.
Results

This is the initial picture of the tree:

Discussion and Summary

Labels
• No labels