Carnegie Mellon University

Data Privacy Center

Data Privacy Course


JPEG Lab: Working with Hand Images




Objective

The objective of this lab is for you to learn how to work with JPEG image files within Java sufficient to work with hand geometry and fingerprint data.


Overview of activities

The in-class activities concern your working with a few hand images from the silhouette database. You will convert the images to pure black-and-white, remove the shaded borders from the sides, and compute an image that shows only the outline of the hand.

Part I. JPEG Notes


Part II. Binarization of an Image

  1. Visit the hands database and select three images for processing. You will use these images throughout these activities. Here is a link to the silhouette. Hands database 2.

    Place each of your images in a directory called step0, which should be one level down from the place where you will compile and work with your Java code.

  2. Convert the images to pure black-and-white. If you look at the images carefully, you will see they contain many shades of colors. To convert them to black-and-white, you will use Java code.

    In order to use this code, you will need a subdirectory to the location of your Java code, which for convenience you should name step1. Below is a copy of the header comment from the file.

    
     ** This application reads the JPEG files in the indir and writes a 
     ** corresponding JPEG file in the outdir with all pixel values
     ** above a threshold stored as black and all below stored as white. 
     ** Threshold should be a value between 0 and 255.
     ** The original files remain unchanged.  Files not ending
     ** in .jpg are ignored. 
     **  
     ** Usage: java JPGBinarizeAll threshold indir outdir
     **
     ** Usage for large files: -mx180m JPGBinarizeAll threshold indir outdir
     **
     ** Author: L. Sweeney, For: Privacy Technology, Date: 2/2006.
    

    Run the program using the image files in the step0 directory and have the results stored in the step1 directory. View the resulting files. Also, take a look at the code and see how it works. As time permits, we will discuss in class.


Part III. Remove side borders

If you examine the images, you will see that there is a dark border on the left and right sides of each image. Use the following Java code to remove these borders.

In order to use this code, you will need a subdirectory to the location of your Java code, which for convenience you should name step2. Below is a copy of the header comment from the file.


 ** This application reads the JPEG files in the indir and writes a 
 ** corresponding JPEG file in the outdir with the side borders removed.
 ** The left and right sides of an image are assumed o have dark bands
 ** which are re-colored white in the new JPEG files. 
 ** The original files remain unchanged.  Files not ending
 ** in .jpg are ignored. Assumes that only borders are dark from the top
 ** of the image to the bottom of the image for any pixel column.
 **  
 ** Usage: java JPGRemoveBorderAll indir outdir
 **
 ** Usage for large files: -mx180m JPGRemoveBorderAll indir outdir
 **
 ** Author: L. Sweeney, For: Privacy Technology, Date: 2/2006.

Run the program using the image files in the step1 directory and have the results stored in the step2 directory. View the resulting files. Also, take a look at the code and see how it works. As time permits, we will discuss in class.


Part IV. Produce an outline of the image.

Instead of a black-and-white colored image, we want to show only the edge or outline of the hand. Use the following Java code to remove these borders.

In order to use this code, you will need a subdirectory to the location of your Java code, which for convenience you should name step3. Below is a copy of the header comment from the file.


 ** This application reads the JPEG files in the indir and writes a 
 ** corresponding JPEG file in the outdir that shows the outline
 ** of the image using edge detection.
 ** The original files remain unchanged.  Files not ending
 ** in .jpg are ignored. 
 **  
 ** Usage: java JPGEdgeDetect indir outdir
 **
 ** Usage for large files: -mx180m JPGEdgeDetect indir outdir
 **
 ** Author: L. Sweeney, For: Privacy Technology, Date: 2/2006.

Run the program using the image files in the step2 directory and have the results stored in the step3 directory. View the resulting files. Also, take a look at the code and see how it works. As time permits, we will discuss in class.

You will want to run the program with different Kernels to see how they transform the image differently. We will examine and discuss these in class. Various Kernels are provied within the code and commented out.


Part IV. Finding anchor points in the hands image

One of the possible tasks you may elect to do in Assignment 4 concerns writing a Java program that automatically locates anchor points within hand silhouette images. Achieving this task can be done by extending the work performed in this Lab. You will want to compute the sloppe of the outline provided in Part III above as you move around the outline of the hand. Anchor points tend to appear at particular changes in slope. To compute the length of fingers, you will want to draw a line that is not an anchor point, but that cuts across the tops of the fingers, where the left top and right top of each finger is identified as an anchor point.

To produce this code, do NOT want just run each of these steps sequentially. It will be too slow! Speed matters. Part of your task is to write code that runs reasonably fast (e.g., using few passes through the data). So, you will likely want to mix and bundle the code together. You may alternatively use an entirely different code. Afterall, Java provides support for JPEG images directly and you are free to use these classes as well.


Spring 2006 Privacy Technology
Professor: Latanya Sweeney, Ph.D. [latanya@dataprivacylab.org]