Lab 2: Vision Algorithms

Lead TAs: Rui Cai (rcai@andrew), Jason Lin (jasonli1@andrew)

Due Date:Tuesday, January 31st, 2012

Lab Materials

In-Class Presentation
Optional Starter Code
mona.pgm
Group Letters


Useful Links

PGM specification
GIMP (converts JPG/GIF/etc. with PGM)
Open Office
PGM conversion program for MATLAB
PGM reader for MATLAB (handles negative numbers)

Lab Purpose:
This lab will help you understand some fundamental concepts of machine vision such as thresholding, contrast and histograms.

Assignment:
Write a program (or three programs) that has the following functionality:

  • Thresholding: 
    Write a program that reads in a PGM file, takes as input a number "n", and outputs a binary image. All pixels in the output image are "black" if their corresponding pixels in the input image are below "n". The remaining pixels in the output image are "white." Save the resulting image as a file.

  • Contrasting: 
    Write a program that searches for the lowest and highest pixel value in an image and then scales the image such that the lowest value is 0 and the highest value is 255. Save the resulting image as a file.

  • Histogram: 
    Compute the histogram of an image. Output the data in a meaningful manner.

If you use MATLAB for this lab, please do not use any functions that solve the problem for you, such as hist(). If you have any doubt as to whether it's okay to use a particular function, be safe and don't use it.

Test your program(s) on three different PGM images

  1. Mona Lisa
  2. The letter corresponding to your group (A = Group 1; B = Group 2, etc...)
  3. Any PGM image of your choice

Hand in:
Create a website that demonstrates the following:

  • The output of your threshold, contrast, and histogram algorithms on the three PGM images that you tested.
  • Each image should be displayed as a JPEG (including the histogram)
  • Include a link to your source code

Email the URL of the website to the head TA.

Tools for converting PGM to JPEG (and vice versa):

NOTE: To ensure everything works for you, make sure you convert to an 8-bit, ASCII PGM Image.