Image Processing Tool on the WWW

Le Minh Trung
Asian Institute of Technology
School of Environment, Resources & Development (SERD)
Space Technology Application & Research Program (STAR)
P.O. Box 4 KhlongLuang, Pathumthani 12120, Thailand
Tel. (662) 524 5585 Fax. (662) 524 6147 
Internet: http://www.rsl.ait.ac.th/Trung/
Email: trung@ait.ac.th 

Abstract

This paper introduces an image processing program executable on the World Wide Web. We call it briefly IPT applet. It may be used as a training tool for courses on image processing, during which students can understand some basic image processing techniques and see the effects of these operations. In addition to basic image processing techniques, it contains some morphological operations such as dilation and erosion. Written in Java programming language, it supports two image file formats (jpg and gif). In the future other formats may be added. 


Background

The current version of IPT applet contains the following transformations/operations: 

1. Change to gray scale image

Some filters can process only gray scale images, so if the original image is a color image, it is necessary to convert it to a gray scale image before further processing. In a gray scale image, each pixel has a value ranging from 0 (black) to 255 (white). The transformation is based on the equation (see [Russ95], pp. 39):

gray value = 0.299*r + 0.587*g + 0.114*b

where r, g, b are the red, green, blue values of a pixel in the color image.
The following images demonstrate the effect of this filter: 

Fig. 1 Original image

Fig. 2 Gray scale image

2. Change to negative image

For a gray scale image, this transformation replaces each color (gray scale value) with its opposite. The effect is similar to a photographic negative. This is accomplished by the simple formula: new value = 255 - old value. Here is the resulting image from the gray scale image above (Fig. 3)

3. Brighten

This simply brightens the image, applying equation: 

for red, green and blue values of each pixel.

4. Darken

This darkens the image, applying equation: 

for red, green and blue values of each pixel.
These are the results of brighten and darken applied to the image in Fig. 2:

Fig. 4 Brighten

Fig. 5 Darken

5. Rotate

Rotates the image 90 degrees clockwise each time this operation is performed.

6. Mirror 

Creates the mirror image.
These are examples showing the mirror image and rotated image:

Fig. 1 Original image

Fig. 6 Mirror image

Fig. 7 Image rotated 90 degrees

7. Thresholding

Change the pixel value according to a given threshold value v. In the program, we use this method only for gray scale images, and any pixel having a value not less than v will be changed to white, otherwise to black. This technique is useful for segmentation to recognize and perform some calculation on a specific feature.

Below is an image of a National Park in the United States. After thresholding we can see individual trees, which enable us to count the number of trees (See section 12, Counting Separate Objects, in this part).

Fig. 8 Original image

Fig. 9 Thresholded image

8. Histogram equalization

This method performs the following steps (see [Gonzalez93 pp.173], [Sid-Ahmed95 pp.67-68]):

The following images demonstrate the effect of this filter:

Fig. 12 Original image

Fig. 13 Result after applying histogram equalization

9. Median filter

Filters alter each pixel's color based on its current color and the colors of neighboring pixels. Median filter replaces each pixel with its median neighbor. If we sort all the neighbors of a pixel according to their gray scale values, the middle pixel is called the median neighbor. This technique is useful for noise removal, as we can see in Fig. 10 and Fig. 11 below.

Fig. 10 Original image with noise

Fig. 11 Result after applying median filter

10. Erosion 

In IPT applet, this filter can be applied to only black and white images. Here we use the simplest kind of erosion (classical erosion), which removes foreground pixels touching at least one background pixel. This removes a layer from around the periphery of all regions. Repeating this operation may lead to separation of touching features (which enables us to count the features, for instance).
This operation can be accomplished by the following simple procedure: for each foreground pixel (black), if it is on the boundary, remove it. 
Below are two images demonstrating this operation:

Fig. 14 Original image with touching features
Fig. 15 Image after 8 cycles of erosion

11. Dilation 

Dilation, on the contrary, adds any background pixel that touches a foreground pixel. This will add a layer around the periphery of each region. This filter can also be applied to only black and white images. 
The operation is accomplished by the following simple procedure: change each background pixel (white) touching at least one foreground pixel to black. 
Below is a simple example of using dilation to fill gaps inside features.

Fig. 16 Original image

Fig. 17 After one cycle of dilation

12. Counting separate objects 

The counting operation is performed with the region growing technique (see [Gonzalez93 pp. 458], [Russ95 pp. 399-402]). This can be accomplished by the following procedure: 

  1. Initialize the counter to 0 and unmark all pixels. 
  2. For each unmarked pixel not on the background, do the following: 
    1. Increment the counter by one. 
    2. From this pixel, grow to all neighbors not on the background, and mark them with an identification number. This process is performed repeatedly to create an area. 

A demonstration of this operation can be seen at http://www.rsl.ait.ac.th/~trung/TreeCount/

Implementation Considerations

The Java Developer's Kit has packages for image processing, including the RGBImageFilter class and others. Point operations (i.e. processing a pixel depends only on its value, not on the values of neighbors) can be accomplished by using classes in the java.awt.image package.

However, many operations above are neighbor operations (median filter, erosion, dilation...), in which pixel processing depends on both its value and the values of its neighbors. In this case we still can use the classes mentioned above, but for higher speed we implemented our own classes.

To implement the region growing algorithm above, we used a queue data structure to keep the pixels under consideration, so the region scanning process can be easily accomplished. The algorithm for marking an area from a given pixel p in this area can be described as follows:

  1. Create empty queue Q
  2. Add pixel p to Q 
  3. While (queue Q not empty) do the following: 
    1. Take element t from the front of queue Q 
    2. Mark pixel t 
    3. For all neighbors n of t not in the background, do the following: 
      1. Mark pixel n 
      2. Add pixel n to queue Q 

And finally, due to the security policy of browser vendors (Netscape, Microsoft...), users can process the images from only the server where the images are located, and the processed image can not be saved on the local machine. To process an image from the local machine, the user must upload it to the server (on specific directory) before running the IPT applet. 

Technical Requirements and Instructions

The following are requirements for Internet users:

The IPT applet is available at http://www.rsl.ait.ac.th/~trung/ImPro/

To process an image, perform the following steps:

  1. Click on the Open Image button. A window appears showing a list of available image files ready for processing. 
  2. In the list, select the image file you want to process. A window appears showing the image. 
  3. Choose the appropriate processing technique from the pull-down menu in the middle of the applet. 
  4. Click on the Proceed button. After a while (depending on the size of the image) you will see the resulting processed image. 
  5. To restore the processed image to the original image, click on the Restore button. 

Note: Before clicking the Proceed button,, users should know in advance whether the currently used filter (image processing method) can be applied for the type of currently loaded image (black & white, gray scale or color image). Otherwise, unexpected results may occur. 

Conclusions

Java technology enables us to develop many interesting tools for the web, from simple things such as animation images, to more advanced image processing tools and others (for instance, expert systems) . This paper presents a simple image processing tool for education and training purposes. Further additions will be considered in the future to cover popular image processing techniques, available in other commercial image processing software.

We also intend to add an on-line explanation module into the applet, so that users can have a deep understanding about what is happening behind the underlying image processing transformation.

The IPT applet provides only global image processing techniques, i.e. every operation is applied to the whole image, not to a point or a specific smaller area. This restriction will be overcome in later versions of IPT applet. 

References

  1. [Russ95] The Image Processing Handbook, 2nd Edition, CRC Press.
    John C. Russ. North Carolina State University, 1995.
  2. [Gonzalez93] Digital Image Processing, Addition-Wesley Publishing Company.
    Rafael C. Gonzalez, Richard E. Woods, 1993.
  3. [Sid-Ahmed95] Image Processing: Theory, Algorithms, and Architecture.
    M.A. Sid-Ahmed, International Edition, 1995
  4. [Hopson96] Developing Professional Java Applets
    K.C. Hopson and Stephen E. Ingram, Sams.net Publishing 1996
  5. [Naughton96] Java Handbook
    Patrick Naughton. McGraw-Hill 1996
  6. [Manger96] Essential Java
    Jason J. Manger, McGraw-Hill 1996
  7. [Lemay96] Teach yourself Java in 21 days
    Laura Lemay & Charles L. Perkins, Sams.net Publishing 1996

HTML 3.2 Checked! This document validates as HTML 3.2





Return to Top of Page
Return to Posters Index