Implementation of Integer-Based Wavelets Using Java ... - CiteSeerX

4 downloads 4573 Views 203KB Size Report
used in the Digital Image Processing instructions and .... Language (HTML) form on a web page. ... If the file type is supported, the image is converted to.
Implementation of Integer-Based Wavelets Using Java Servlets Andrew R. Dalton Department of Computer Science, Appalachian State University Boone, North Carolina 28608, USA and Rahman Tashakkori Department of Computer Science, Appalachian State University Boone, North Carolina 28608, USA ABSTRACT In this paper, we will discuss applications of Java servlets as a web-based tool for illustration of integerbased new-generation wavelets (lifting) techniques used in the Digital Image Processing instructions and research. The graphical user interface of the application designed as part of this project appears as a web page in the browser of the user’s choice. This web page displays several options that the user can use to perform the lifting analysis on digital images. The current options are: the choice of lifting scheme, choice of decomposition or reconstruction, and the level of decomposition or reconstruction. Although input/out images can be in various formats, for the purpose of web browsing, all images are stored in JPEG or GIF formats. Also, the front-end of the tool allows users to choose the inverse or forward transform and the location on the local hard disk from/to which images will be read/written.

Wavelets provide a much more powerful and more attractive alternative tool in image and signal processing than the traditional Fourier Transform. “Wavelets are mathematical functions that cut up data into different frequency components, and then study each component with a resolution matched to its scale” [8]. Lifting schemes, the new generation wavelets, are efficient methods for performing wavelet transforms [6]. Lifting provides the power of wavelets and are much simpler to implement and easier to understand. They allow for multi-resolution analysis of data, in our study, image data [7]. Figure 2 shows a comparison of wavelets and lifting procedures.

Keywords: Digital Image Processing, Java Servlets, integer-based wavelets, and lifting schemes. 1. Introduction In recent years, wavelets analysis is introduced in most digital image processing courses. Wavelets analysis became more attractive for image processing due to the fact that wavelets are smaller waves with abnormal shapes. Figure 1 illustrates the Discrete Wavelet Transform of an image. H0H0 H0H0 H0

H0 H0H1` H0H1`

H1H0 H1H0 H1

H1

H1H1 H1H1

Figure 1 - Two-Dimensional discrete wavelet analysis with Down-sampling

Figure 2 - Comparison of discrete wavelet analysis and lifting A simple, yet powerful way of representing images at multiple resolutions is an image pyramid [7]. An image pyramid consists of a single image viewed at multiple sizes and at multiple resolutions. The base of the pyramid is the original image to which the wavelet transform is being applied. Subsequent images going up the pyramid are the trend of the original image at smaller size and the details. This process can be repeated multiple times forming multiple levels of the image pyramid as shown in Figure 3. A P-level pyramid is generated by executing the wavelet operation P times, starting with the original image [8]. In this project, we present the result of our study using two lifting schemes: Haar and Cohen-DaubechiesFeauveau - CDF(2,2). The forward and inverse lifting process are shown on Figures 4 and 5.

2. Theory and Background This project demonstrates two lifting techniques: Haar and Cohen-Daubechies-Feauveau – CDF(2,2). Haar wavelet is the simplest example of lifting [7]. The Haar lifting technique generates an alternating sequence of averages (trends) and difference (details) based on the scheme shown below: di, j = di, j - si, j si, j = si, j + ½ di, j

difference average

(1)

The Cohen-Daubechies-Feauveau 2, 2 - CDF(2,2) is another lifting technique very similar to Haar lifting. CDF(2,2) however, uses more points in each calculation. Instead of using two values for each calculation, CDF(2,2) uses four. This is a biorthogonal wavelet and the two numbers in the parenthesis (2, 2), represent the number of vanishing moments for the high pass synthesis filter g and the high-pass analysis ~ respectively. The CDF(2,2) is shown below: filter g di, j = di, j – ½( si, j + si+1 ) si, j = si, j – ¼ (-di - 1, j - di )

difference average

(2)

Since an image is in 2-D, this process is initially performed on the rows then columns. The lifting process, in general, can be done in-place such that there is no need for auxiliary memory to keep the intermediate results. This is shown on Figure 6. In the process, details are stored in the odd rows or columns depending on the processing direction and trends are stored in the even rows or columns. After each level, the trends and details are permuted, i.e., trends are moved to the upper-left quarter of the image and the details to the two sections in the lower half and to the one on the upper-right to produce the total of four contiguous sections. The top-left section contains the trend data which represents the actual image in oneforth of its original size, and the other sections contains the details with respect to x direction, y direction, and x-y direction. These are shown in Figure 3 after two levels of decomposition. This lifting process continues for both rows and columns as many times as the level of decomposition is. At the end, the “lifted” image, which contains different subbands of the original image is created. The final image maintains all the information that was available in the original image; thus, the process can be reversed to reconstruct the original image exactly as it appeared before the process was started.

Figure 4 - The forward lifting process; 1st split, 2nd computing details, and 3rd use the details to update the trend

Figure 5 - The inverse lifting process; 1st undo the update to recover the even samples, 2nd add the prediction to the details and reconstruct the odd sample, 3rd merge to get the signal at the lower level

Figure 6 - In-place calculation of CDF(2,2) lifting scheme

Figure 3 - Second Level wavelet decomposition of an image

Lifting can be used as an effective method of compression or noise removal. The “noise” appears in the high frequency subbands, which contains much smaller values than those in the low-frequency subbands. These values can be set to zero as a way to

achieve compression or remove noise. Note that if the high-frequency data contains valuable information, the data cannot be discarded. However, since this technique produces large contiguous sections of near zero data, other compression algorithms may compress this data more effectively. 3. Method This project was implemented using Java Servlets. Servlets are very similar to CGI applications; however, there are several key differences. Servlets, like CGI applications, interact with a web server that services web clients on the network. However, a servlet is not started and stopped each time a request is serviced. A servlet runs in a “servlet container,” a dispatcher application that receives data forwarded from the web server and sends that data to the appropriate servlet. Once the servlet container invokes a servlet, that servlet remains running until a given timeout expires. This provides servlets with greater efficiency when compared to CGI applications. Servlets also have access to any of the wide verity of Java Application Programming Interfaces (API) available [1].

prompted to fill out several pieces of information about the type of lifting he or she wishes to do including the lifting technique, forward or inverse lifting, the number of levels of lifting he or she wishes to perform, and the file on which he or she wishes to perform that lifting technique. The user then clicks a button on the web page which sends the selected parameters and the image itself as multi-part form data to the web server. The web server determines that the requested page is a servlet by the URL request it receives and then forwards the associated data to the servlet container where the servlet is initialized, if necessary, then invoked. The doPost() method of the servlet is called and passed the necessary information to extract the data sent from the client. As there is no pre-defined functionality provided to handle multi-part form data, the parameters and the file had to be extracted from the raw data stream of the request. The lifting type, lifting direction, lifting level, and the file were extracted, and the file was saved locally to disk. If the content type associated with the file was not one of the supported file formats (GIF and JPEG), an error message is generated and displayed on the client web browser.

A servlet gets input from a web server, performs some computation on that input, and return output to the web server. The input to a servlet usually originates from the client web browser. There are two primary methods for a web client to transmit data to a web server: GET and POST [2]. The first method for a web client to transmit data to a web server is the GET method. The GET method appends data to the Universal Resource Locator (URL) the web client is requesting from the web server. The maximum length of a URL is a limiting factor of this method as the data appended could potentially be truncated [3]. The data being sent to the server appears as tuples of names and values, beginning with a question mark, and delimited by the ampersand character. The format of such a URL is as follows, where i indicates the i-th tuple: http://[URL]?namei=valuei[&namei=valuei]*

The second, and most versatile, method for a web client to transmit data to a web server is the POST method. This method, instead of appending the data to the URL, embeds the data in the Hyper Text Transfer Protocol (HTTP) request itself [2, 3]. This method is more secure in that parameter data, which could theoretically be password-related data, is not visible on the URL line of the web browser [3]. Also, the POST method does not place a limit on the size of the data the servlet will process which means that large files can be uploaded using this method.

The POST method was used to implement this project. The user is presented with a Hyper Text Markup Language (HTML) form on a web page. The user is

Figure 7 - Interaction Diagram of Sample Session If the file type is supported, the image is converted to raw pixel data using an imaging toolkit found at [4], and converted to a Portable Gray Map (PGM) file by averaging the red, green, and blue components of the image data. The selected lifting technique is then applied, or inverted depending on the selection made by the user, to that PGM image the specified number of times and the resultant image is saved to disk. Finally, using an imaging toolkit found at [5], the PGM image is converted back to a JPEG. The content type of the response to the web client is specified to be of type JPEG and the image data is written directly to the response stream. The servlet container then forwards that response data to the web client. The web client

receives the data and displays the resultant image to the user. The flow diagram of this process is shown in Figure 7. 1.

The user selects the lifting technique, inverse or forward, number of levels to decompose/reconstruct, and the image. 2. The user selects the “Submit” button. 3. The web browser reads the selected image from the local hard drive. 4. The web browser transmits the selected options and the image to the web server. 5. The web server examines the requested URL, determines the URL request is for a servlet. 6. The web server forwards the data to the servlet container. 7. The servlet container initializes the servlet, if necessary, and invokes the servlet’s doPost() method. 8. The servlet reads the parameters from the input stream and performs the requested action based on those parameters. 9. The servlet writes the resultant image to its output stream. 10. The servlet container delivers this data to the web server. 11. The web server delivers this data back to the requesting web browser. 12. The web browser displays the resultant image to the user.

Figure 8 - Lena after one level of Haar decomposition Figure 9 shows the same image after two levels of Haar decomposition.

Figure 9 - Lena after two levels of Haar decomposition Figure 10 shows Lena after three levels of Haar decomposition

For debugging purposes, the intermediate images that are saved to disk are not automatically discarded, however, the end user has no access to these intermediate images. It is therefore possible to examine the GIF or JPEG image transmitted from the client and the resultant PGM image with the lifting techniques applied. It should be noted, however, that if this application was published for public use, a mechanism should be put into place that will “clean up” these intermediate images.

4. Results Below are results generated using our Java-base lifting tool. First, the results of the Haar lifting technique are shown. Next, an example of the inverse Haar technique is shown. Finally, we will show examples of the CDF(2,2) technique.

Figure 10 - Lena after three levels of Haar decomposition Figure 11 shows the image reconstructed after one level of Haar decomposition.

Figure 8 shows the image of Lena after one level of Haar decomposition.

Figure 11 - Lena reconstruction using the data at the first level of Haar decomposition The next three figures show the decomposition results by the CDF(2,2).

platforms and from distance. This tool will be ideal for teaching the lifting concepts over the web as well. Further developments are required to include more complicated lifting schemes. 6. References

Figure 12 - Lena after one level of CDF(2,2) decomposition

[1]. Sun Microsystems. Java Server Technology, An Online Reference http://java.sun.com/products/servlet/. November 30, 2002. [2]. Fielding R., Irvine U.C., et al. Request for Comments 2616, “Hypertext Transfer Protocol – HTTP/1.1” Online Reference. http://www.faqs.org/ftp/rfc/rfc2616.txt. November 30, 2002. [3]. Fulton, John. The GET and POST Methods. Online Reference. http://www.rci.rutgers.edu/~jfulton/get-post/. November 30, 2002.

Figure 13 - Lena after two levels of CDF(2,2) decomposition

[4]. Zhong, Zi. Image Processing Package in Java. Library Provided Free Online at: http://www.ee.columbia.edu/~dzhong/JIM/JIM.ht ml. November 30, 2002. [5]. Schmidt, Marco. JIU – The Java Imagin Utilities. Library Provided Under GPL License at: http://jiu.sourceforge.net/. November 30, 2002. [6]. Tashakkori, Rahman, Medical Image Compression Using Wavelet and Lifting Combined with New Scanning Techniques, Dissertation. Louisiana State University, May 2000.

Figure 14 - Lena after three levels of CDF(2,2) decomposition 5. Conclusions The Java-based tool presented on this paper can make the research and instructions of lifting (the new generation wavelets) much easier. This tool allows users to analyze digital images using different lifting schemes and different levels of decomposition. The tool allows both forward and inverse lifting. In addition, visualization of the lifting process on a web browser makes the tool very useful on different

[7]. Gonzalez, Rafel, Woods, Richard. Digital Image Processing, Second Edition. Pages 349-404. Prentice-Hall, Inc. 2002. [8]. Graps, Amara. An Introduction to Wavelets. Institute of Electrical and Electronics Engineers, Inc. Online Reference. http://www.amara.com/IEEEwave/IEEEwavelet.ht ml. December 2, 2002.

Suggest Documents