# Pages Titobiloluwa's CS351 Page Project 1 Page History

## Key

• This line was removed.
• Formatting was changed.
Comment: Migrated to Confluence 4.0

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

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:

Code Block
lang javascript
offset = i%cols - dx + (i/cols - dy)*cols;

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

Code Block
lang javascript
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:

Code Block
else if(image[i].b > 140 && image[i].b < 160 && bvalue > 0){
image[i].r = bvalue/30*(255);
image[i].g = bvalue/30*(255);
image[i].b = bvalue/30*(255);

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