Lab 12: Pixel Neighbor Edges

Assignment

  1. Copy over the starter files at /users/smatzko/212/public/. The provided C/C++ code handles reading the image into a buffer, creating a buffer for the output image, and creating 2-dimensional variables (in2D, out2D) for referencing the image buffers.
  2. Modify the code for apply_filter to create and output a modified image similar to the Lena example below. ("Lena" is an image that is commonly used in graphics, purportedly because of the interesting graphical qualities present (skin, hair, feathers, etc), and not because the picture originally can from a Playboy magazine.)
  3. Create a bitset of size 9 to hold data about the 9 pixels in a 3x3 block,
  4. For each grayscale pixel in the image,
    1. for each of the surrounding pixels (3 about, 3 in the middle, and 3 below)
      1. If the absolute difference between the pixel values > t,
      2. Set the corresponding bit in the bitset to 1. Corresponding: upper left pixel is element 0, etc.
    2. If the bitset has is 8 or 0 bits set (to 1), set the pixel to black (0). Otherwise, white (255).

Hints

  • To prevent falling off the edges, use mod:
    e.g. row = (row+height)%height.
  • You need to loop through each pixel (nested for loops), and then for each pixel, loop through the 3x3 block of pixels surrounding it (more nestsed for loops).

Turn in

Turn in all of the code, and the Makefile.
Use sendlab.212.302 12 *.o *.cpp *.h Makefile