CSC 318 -- Encoding Project

Goal:

Implement a Windows application that hides a coded message in a binary image encoded in pgm format. The application should include push buttons for displaying images and textfiles, and for encoding and decoding. See table below for details.

 

Suggested Controls

You may modify this design if you wish.

Type of ControlLabel or Caption for Control
Edit Box Raw Image File Name
Push Button Get Raw Image File Name
Push Button Display Raw Image
Edit Box Encoded Image File Name
Push Button Get Encoded Image File Name
Push Button Display Encoded Image
Edit Box Input Text File Name
Push Button Get Input Text File Name
Push Button Display Input Text File
Edit Box Output Text File Name
Push Button Get Output Text File Name
Push Button Display Output Text File
Menu Item Encode
Menu Item Decode

Be sure to look at the examples in EncodeProject.zip.

 

Pseudocode for Encoding Algorithm of Encoding Project 4.

open origimg and msgfile for binary read
open codedimg for binary write
read origimg header
write codedimg header (don't forget endl at end of each line)

read byte from msgfile
base = 10000000 (binary)

while not at msgfile eof

    for i = 0 to 7
      read pixel from origimg
      mask = (base >> i)
      if (byte & mask == 00000000 (binary))
        outpixel = (pixel & 11111110 (binary))
      else
        outpixel = (pixel | 00000001 (binary))
      end if

      write outpixel to coded image

    end for
    read byte from msgfile
end while

encode 00000000 (binary) in next 8 outimg pixels
copy remaining pixels unchanged to outimg file.
close all files

 

Pseudocode for Decoding Algorithm of Encoding Project 4.

open codedimage for binary read
open outmsg for binary write

read codedimg header
base = 10000000 (binary)

while(TRUE)

    byte = 00000000 (binary)

    for i = 0 to 7

      read pixel from codedimg
      bit = low order bit of pixel
      mask = (base >> i)
      if (bit = 00000001 (binary))
          byte |= mask    (or byte = byte | mask)
    end for

    if byte == 00000000 (binary)

      break out of loop

    write byte to outmsg
end while

close all files