image merger
In most movies and productions today there is a a lot of image composition done. The process of merging computer generated images onto existing filmed scenes. The program you are to make takes two simple images and imposes one of these images onto another image. For example. given these two images:
You are to create an merged image of:
To be able to do this you must be able to read in a given image. An example of an easy image format is a PNM image. PNM images are simply a collection of RGB values in a data file, and a simple header that tells the type of data for the image, the size of the image, and the max color value. An example of a header and the beginning of a PNM file is:
P3
640 480
255
255 0 0 255 0 0 .....
This simple header says that data is of type 3, its size is 640 x 480, and the max color value is 255. After this is done the pixels of the image are laid out in the format of RGBRGB so the start of this file is that the first pixel has the value R = 255, G = 0, B = 0. PNM files also allow for comments to be put into the data header after the data type line and before the max color value line. Another sample PNM header is:
P6
# This file has a comment.
640 480
255
255 0 0 255 0 0 .....
The data file types for a PNM file are:
| P1 - Text Data for a Black and White image. (2 color) | |
| P2 - Text Data for a Grayscale image. | |
| P3 - Text Data for a RGB image. | |
| P4 - Binary Data for a Black and White image. (2 color) | |
| P5 - Binary Data for a Grayscale image. | |
| P6 - Binary Data for a RGB image. |
In order for the merging process to work a pixel mask is needed so that the program can determine which pixels of the merging image are to be used on the composite image and which pixels are to be ignored. The way this is done is the image that is to be merged has a single pixel value that is considered not to be part of the image. When merging the two images each pixel is looked at in the overlaying image. If it is the pixel mask, then the background pixel is put into the composite image, if it is not, then the overlay pixel is put into the image.
Updated: