|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
In the sample JPEG image above, the following colors are being displayed in the cells.
0 (blue=255, green=0, red=0) | 1 (blue=0, green=255, red=0) | 2 (blue=0, green=0, red=255) | 3 (blue=255, green=255, red=255) |
4 (blue=100, green=100, red=100) | 5 (blue=200, green=100, red=200) | 6 (blue=100, green=200, red=200) | 7 (blue=0, green=0, red=0) |
As shown above, 0,0,0 is black and 255,255,255 is white. In the other version of the one-dimensional array used in the Java code, each pixel uses 3 consecutive cells in the array, rather than one. In this version, the first cell assigned to th pixel stores the integer value for blue, the second for green, and the third for red.
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.
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.
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.
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.
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.