Lab 2: Vision Algorithms

Lead TA: Andrew Hundt

Due Date: Tuesday, January 27th, 2009

Lab Materials

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


Useful Links

PGM specification
ImageMagick (converts PGM)
Open Office
PGM conversion program for MATLAB

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.

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 Somchaya.

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.