The program is two fold. Write a program that will embed an image (in my case a PGM grey scale file) into a (PPM) color image. The second part will be to write an extraction program, but until I know how I got it in I can't pull it out.
I have finally figured out how to read two files, without corrupting the data. The image to be inserted (imageb) and the host image (imagea) is the target PPM file.
I have a check routine to make sure there is enough space for the image to fit. I also output the size of the grey image so that I have the parameters to pull it out when I write the extraction program.
The file reading code is class provided, so that doesn't need adjusting. It reads to know if the file is a PPM or PGM file.
I am going to use the least significant bit method when I am finished, but for now I am embedding on the MOST significant bit in order to see if the embedding is happening. When that is successful I will shift the the least significant bit.
To keep everything simple I am also dropping the two least significant bits of the gray image so that I can pair the gray image bits 7 & 6 to band O (red), bits 5 & 4 with band 1 (green), and bits 3 & 2 with band 2 (blue).
The logic, as I understand it, and what I am having trouble with is sequencing from band 0 after loading the new bits and writing, then going to band 1 to do the same, and then on to band 2 to finish the routine and then advance the grey image to the second pixel. The color image advances three times for each single advance of the grey image.
Attached is my CPP code file.
Number of downloads: 5839