IDL Wavelet Toolkit User’s Guide IDL Version 7.0 November 2007 Edition Copyright © ITT Visual Information Solutions All Rights Reserved 1107IDL70WV Restricted Rights Notice The IDL®, IDL Analyst™, ENVI®, and ENVI Zoom™ software programs and the accompanying procedures, functions, and documentation described herein are sold under license agreement. Their use, duplication, and disclosure are subject to the restrictions stated in the license agreement. ITT Visual Information Solutions reserves the right to make changes to this document at any time and without notice. Limitation of Warranty ITT Visual Information Solutions makes no warranties, either express or implied, as to any matter not expressly set forth in the license agreement, including without limitation the condition of the software, merchantability, or fitness for any particular purpose. ITT Visual Information Solutions shall not be liable for any direct, consequential, or other damages suffered by the Licensee or any others resulting from use of the software packages or their documentation. Permission to Reproduce this Manual If you are a licensed user of these products, ITT Visual Information Solutions grants you a limited, nontransferable license to reproduce this particular document provided such copies are for your use only and are not sold or distributed to third parties. All such copies must contain the title page and this notice page in their entirety. Export Control Information This software and its associated documentation are subject to the controls of the Export Administration Regulations (EAR). It has been determined that this software is classified as EAR99 under U.S. Export Control laws and regulations, and may not be retransferred to any destination expressly prohibited by U.S. laws and regulations. The recipient is responsible for ensuring compliance to all applicable U.S. Export Control laws and regulations. Acknowledgments ENVI® and IDL® are registered trademarks of ITT Corporation, registered in the United States Patent and Trademark Office. ION™, ION Script™, ION Java™, and ENVI Zoom™ are trademarks of ITT Visual Information Solutions. Numerical Recipes™ is a trademark of Numerical Recipes Software. Numerical Recipes routines are used by permission. GRG2™ is a trademark of Windward Technologies, Inc. The GRG2 software for nonlinear optimization is used by permission. NCSA Hierarchical Data Format (HDF) Software Library and Utilities. Copyright © 1988-2001, The Board of Trustees of the University of Illinois. All rights reserved. NCSA HDF5 (Hierarchical Data Format 5) Software Library and Utilities. Copyright © 1998-2002, by the Board of Trustees of the University of Illinois. All rights reserved. CDF Library. Copyright © 2002, National Space Science Data Center, NASA/Goddard Space Flight Center. NetCDF Library. Copyright © 1993-1999, University Corporation for Atmospheric Research/Unidata. HDF EOS Library. Copyright © 1996, Hughes and Applied Research Corporation. SMACC. Copyright © 2000-2004, Spectral Sciences, Inc. and ITT Visual Information Solutions. All rights reserved. This software is based in part on the work of the Independent JPEG Group. Portions of this software are copyrighted by DataDirect Technologies, © 1991-2003. BandMax®. Copyright © 2003, The Galileo Group Inc. Portions of this computer program are copyright © 1995-1999, LizardTech, Inc. All rights reserved. MrSID is protected by U.S. Patent No. 5,710,835. Foreign Patents Pending. Portions of this software were developed using Unisearch’s Kakadu software, for which ITT has a commercial license. Kakadu Software. Copyright © 2001. The University of New South Wales, UNSW, Sydney NSW 2052, Australia, and Unisearch Ltd, Australia. This product includes software developed by the Apache Software Foundation (www.apache.org/). MODTRAN is licensed from the United States of America under U.S. Patent No. 5,315,513 and U.S. Patent No. 5,884,226. FLAASH is licensed from Spectral Sciences, Inc. under a U.S. Patent Pending. Portions of this software are copyrighted by Merge Technologies Incorporated. Support Vector Machine (SVM) is based on the LIBSVM library written by Chih-Chung Chang and Chih-Jen Lin (www.csie.ntu.edu.tw/~cjlin/libsvm), adapted by ITT Visual Information Solutions for remote sensing image supervised classification purposes. IDL Wavelet Toolkit Copyright © 2002, Christopher Torrence. IMSL is a trademark of Visual Numerics, Inc. Copyright © 1970-2006 by Visual Numerics, Inc. All Rights Reserved. Other trademarks and registered trademarks are the property of the respective trademark holders. Contents Chapter 1 Introduction to the IDL Wavelet Toolkit ................................................. 5 What Is the IDL Wavelet Toolkit? .................................................................................... 6 IDL Wavelet Toolkit Architecture .................................................................................... 9 Chapter 2 Using the IDL Wavelet Toolkit .............................................................. 11 Starting the Toolkit .......................................................................................................... Menu Description ............................................................................................................ Preferences ...................................................................................................................... Dataset Viewer ................................................................................................................ Importing Data ................................................................................................................ Wavelet Viewer ............................................................................................................... Wavelet Power Spectrum ............................................................................................... Multiresolution Analysis ................................................................................................. Denoise Tool ................................................................................................................... IDL Wavelet Toolkit 12 14 18 20 25 28 32 39 41 3 4 Adding User Tools ........................................................................................................... 45 Chapter 3 Theory and Examples .......................................................................... 47 Wavelet Transform .......................................................................................................... 48 Wavelet Power Spectrum ................................................................................................. 49 Denoise ............................................................................................................................ 51 Multiresolution Analysis .................................................................................................. 54 Bibliography .................................................................................................................... 55 Chapter 4 IDL Wavelet Toolkit Reference ............................................................. 57 List of Commands by Functionality ................................................................................ 58 WV_APPLET .................................................................................................................. 60 WV_CW_WAVELET ..................................................................................................... 62 WV_CWT ........................................................................................................................ 66 WV_DENOISE ................................................................................................................ 69 WV_DWT ........................................................................................................................ 74 WV_FN_COIFLET ......................................................................................................... 78 WV_FN_DAUBECHIES ................................................................................................ 80 WV_FN_GAUSSIAN ...................................................................................................... 82 WV_FN_HAAR .............................................................................................................. 85 WV_FN_MORLET ......................................................................................................... 87 WV_FN_PAUL ............................................................................................................... 90 WV_FN_SYMLET .......................................................................................................... 93 WV_IMPORT_DATA ..................................................................................................... 96 WV_IMPORT_WAVELET ............................................................................................ 99 WV_PLOT3D_WPS ...................................................................................................... 101 WV_PLOT_MULTIRES ............................................................................................... 104 WV_PWT ...................................................................................................................... 107 WV_TOOL_DENOISE ................................................................................................. 109 Index .................................................................................................... 113 Contents IDL Wavelet Toolkit Chapter 1 Introduction to the IDL Wavelet Toolkit This chapter discusses the following topics: What Is the IDL Wavelet Toolkit? . . . . . . . . . 6 IDL Wavelet Toolkit IDL Wavelet Toolkit Architecture . . . . . . . . 9 5 6 Chapter 1: Introduction to the IDL Wavelet Toolkit What Is the IDL Wavelet Toolkit? The IDL Wavelet Toolkit consists of a set of graphical user interfaces (GUI) and IDL routines for wavelet analysis of multi-dimensional data. Motivation Wavelet analysis is becoming a popular technique for data and image analysis. By decomposing a signal using a particular wavelet function, one can construct a picture of the energy within the signal as a function of both spatial dimension (or time) and wavelet scale (or frequency). The wavelet transform is used in numerous fields such as geophysics (seismic events), medicine (EKG and medical imaging), astronomy (image processing), and computer science (object recognition and image compression). The technique is flexible and robust, yet it is fast enough to be used in real-time image processing. A set of standard wavelet techniques have been developed which make it possible for the average user to apply the wavelet method with confidence. Recent advances in significance testing and cross-wavelet analysis have also enhanced the acceptability of wavelet analysis within the scientific community. Nevertheless, the calculation of the wavelet transform and the display of the output requires considerable experience. Users The IDL Wavelet Toolkit is designed for a wide audience, ranging from the casual user who wishes to explore the possibilities of wavelet analysis, to the scientist or engineer who wants to produce robust and complex results. Potential users and their applications include: • Students— introduction to wavelets, graphical analysis; • Engineers— data analysis, signal processing, data compression; • Scientists— data analysis, filtering and denoising, cross-wavelet; • Computer scientists— image compression, speed of operations; • Mathematicians— explore wavelet families, test out new analysis techniques. Applications Examples of specific applications are: What Is the IDL Wavelet Toolkit? IDL Wavelet Toolkit Chapter 1: Introduction to the IDL Wavelet Toolkit 7 • Time-series analysis— time-scale power spectrum, noise filtering, multiresolution analysis; • Self-similar series— fractals, long-memory processes; • Turbulence— detection of coherent structures; • Signal processing— filtering and denoising; • Image processing— edge detection, compression, enhancement. Features The IDL Wavelet Toolkit has the following features: Wavelet Applet The Toolkit Applet lets you manage your projects, import data and wavelets, visualize the results, and add your own user tools. Continuous Wavelet Transform Allows you to compute the continuous wavelet transform on one-dimensional vectors. This routine is written in IDL .pro code. Discrete Wavelet Transform Allows you to compute the discrete wavelet transform (partial or full) on multidimensional data. These routines are written in C and contained in the IDL wavelet dlm. Wavelet Functions The Toolkit comes with several wavelet functions that are accessible both inside the Applet and from your own programs. You can easily add your own wavelet functions to the Toolkit. 3D Wavelet Power Spectrum Callable from within the Applet and from your own programs, the visualizer plots the wavelet power as a three-dimensional surface, with optional contour lines. You can rotate, translate, and find the power at a particular location. Multiresolution Analysis Stand alone or callable from the Applet, this routine produces plots for the smooth (low pass), detail (band-pass), and rough (high-pass) components of your data. IDL Wavelet Toolkit What Is the IDL Wavelet Toolkit? 8 Chapter 1: Introduction to the IDL Wavelet Toolkit Denoise Tool This widget tool enables you to denoise your vector or image array by thresholding (hard or soft) either by cumulative power or coefficient number. Dataset Viewer Manage the datasets within each project by importing new data, viewing data values, and customizing the data fields. Import Data You can import data from a variety of file formats: ASCII, binary, image (BMP, JPEG, PNG, PPM, SRF, TIFF, DICOM), and WAV audio. Image files can be either indexed color (8- or 16-bit) or TrueColor (24-bit). You can also import data directly from the IDL> command prompt. User Tools You can extend the functionality of the IDL Wavelet Toolkit by adding your own tools. What Is the IDL Wavelet Toolkit? IDL Wavelet Toolkit Chapter 1: Introduction to the IDL Wavelet Toolkit 9 IDL Wavelet Toolkit Architecture File Organization The Toolkit consists of the following components: • Source (.pro) files in the wavelet directory; • A bitmaps subdirectory with button bitmaps; • The data subdirectory with sample data files; • The Online help manual in the IDL help directory; • The DLM (Dynamically Loadable Module) in the IDL bin directory. Note You are encouraged to view the source files for details on implementation and technique. You are also welcome to modify the source files, however, it is strongly encouraged that you copy the files to your own directory first. By modifying the IDL !PATH variable you can ensure that your routines are compiled first. See “!PATH” (IDL Reference Guide) for more information. Structure The IDL Wavelet Toolkit consists of three layers. The topmost layer is the Wavelet Applet, which allows you to import data and wavelet functions, and access various visualization and tool routines. The middle layer is the set of compound widgets and widget tools for visualization and analysis. These tools are accessible both from the Wavelet Applet and from your own routines. The lowest layer are the wavelet API (application programming interface) that consist of the wavelet functions, the wavelet transform, and the import data routine. IDL Wavelet Toolkit IDL Wavelet Toolkit Architecture 10 IDL Wavelet Toolkit Architecture Chapter 1: Introduction to the IDL Wavelet Toolkit IDL Wavelet Toolkit Chapter 2 Using the IDL Wavelet Toolkit This chapter discusses the following topics: Starting the Toolkit . . . . . . . . . . . . . . . . . . . Menu Description . . . . . . . . . . . . . . . . . . . . Preferences . . . . . . . . . . . . . . . . . . . . . . . . . Dataset Viewer . . . . . . . . . . . . . . . . . . . . . . . Importing Data . . . . . . . . . . . . . . . . . . . . . . . IDL Wavelet Toolkit 12 14 18 20 25 Wavelet Viewer . . . . . . . . . . . . . . . . . . . . . . Wavelet Power Spectrum . . . . . . . . . . . . . . Multiresolution Analysis . . . . . . . . . . . . . . Denoise Tool . . . . . . . . . . . . . . . . . . . . . . . . Adding User Tools . . . . . . . . . . . . . . . . . . . 28 32 39 41 45 11 12 Chapter 2: Using the IDL Wavelet Toolkit Starting the Toolkit To start the IDL Wavelet Toolkit type the following at the IDL> command prompt: wv_applet This action compiles the wv_applet routines and starts up the main window, shown in the following figure. For other startup options see “WV_APPLET” on page 60. The window consists of Menu Items, the Toolbar, the Dataset Viewer, and a Status Bar at the bottom. Menu Items The menu items, located at the top of the IDL Wavelet Toolkit window, allow you to perform various actions. These menu items are described in the next section. Toolbar The toolbar is divided into five sections: File, Import, Edit, Visualize, and Help. The toolbar buttons allow you to easily access various menu items. When you position the mouse pointer over a toolbar the Status Bar displays a description of its function. Dataset Viewer The variables contained in your dataset are displayed in the dataset table, described in “Dataset Viewer” on page 20. Status Bar The Status Bar displays descriptions of the Toolbar buttons and the status of various actions such as Open, Import, and Save. The Status Bar also provides warnings if, for example, you select “Visualize...” without selecting a variable. Starting the Toolkit IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 13 Figure 2-1: The main Wavelet Toolkit window. IDL Wavelet Toolkit Starting the Toolkit 14 Chapter 2: Using the IDL Wavelet Toolkit Menu Description The main window has five items: File Menu, Edit Menu, Visualize Menu, Tools Menu, and Help Menu. Each menu and its submenus is described below. File Menu The File menu accesses and manipulates files. New Applet This menu item or button starts a new Wavelet Toolkit applet with an empty dataset. Open Dataset... This menu item or button closes the current dataset and allows you to open up a different dataset. Wavelet datasets have the default filename suffix .sav and are written in IDL SAVE format. For more information, see “SAVE” (IDL Reference Guide). If the previous dataset has not been saved, then you will be prompted to save the previous dataset first. Save Select this menu item or button to save the current dataset and preferences. If the dataset has not yet been saved, then you are prompted for a filename with the Save As dialog. Save As... This menu item allows you to choose a new filename for the current dataset using the Save As dialog, and then saves the dataset to this file. Import... Select this menu item to import an external data file into the current dataset. Details on allowable file formats and import options can be found in “Dataset Viewer” on page 20. You can also import data from the current IDL session using the WV_IMPORT_DATA procedure. Preferences... This menu item opens up a Preferences dialog in which you can customize your interaction with the Wavelet Toolkit. The Default button restores the built-in default Menu Description IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 15 options for all of the preferences. The OK button keeps all of the changes to Preferences. The Cancel button discards all of the changes. Exit This menu item will close the current Wavelet Toolkit applet. Other Wavelet applets (either started from the command line or via the “New Applet” menu item) are unaffected. If you have made changes to the current dataset, then you will be prompted to save the dataset before exiting. Edit Menu The Edit Menu manipulates the Dataset Viewer. Move Variable Left Select this menu item or button to move the currently-selected variable to the left. Move Variable Right Select this menu item or button to move the currently-selected variable to the right. View Data Values This menu item or button displays the values for the currently-selected variable. Delete Variable Select this menu item or button to delete the currently-selected variable or variables. You are asked for confirmation before the variables are removed. Visualize Menu The Visualize Menu contains methods to graphically display and manipulate the wavelet transform. Wavelets This menu item or button starts up the wavelet compound widget, which allows you display the available wavelet functions and their properties. You can also start the wavelet viewer using the WV_CW_WAVELET function from the IDL> command prompt. The wavelet widget is described in “Wavelet Viewer” on page 28. IDL Wavelet Toolkit Menu Description 16 Chapter 2: Using the IDL Wavelet Toolkit Wavelet Power Spectrum This menu item or button starts the three-dimensional viewer for the wavelet power spectrum, using the currently-selected variable. You can also start the viewer using the WV_PLOT3D_WPS function from the IDL> command prompt. For more information, see “WV_PLOT3D_WPS” on page 101. The wavelet power spectrum viewer is described in “Wavelet Power Spectrum” on page 32. Multiresolution Analysis This menu item or button starts the viewer for multiresolution analysis of the currently-selected variable. You can also start the viewer using the WV_PLOT_MULTIRES function from the IDL> command prompt. The Multiresolution viewer is described in “Multiresolution Analysis” on page 39. Tools Menu The Tools Menu contains built-in and user-defined tools. Denoise This menu item starts the widget for denoising, filtering, and compression of the currently-selected variable. You can also start the viewer from the IDL> command prompt by using the WV_TOOL_DENOISE function. The Denoise tool is described in “Denoise Tool” on page 41. Other user tools... If you have added other tools then they will be displayed here. The currently-selected variable will be passed to the tool function. See “Adding User Tools” on page 45. Help Menu The Help Menu provides various help functions. IDL Help This menu item will start up the IDL Online Help manual. IDL Wavelet Toolkit Help This menu item or button will start up the online help manual for the IDL Wavelet Toolkit. Menu Description IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 17 Wavelet Readme This menu item will display the Readme file included with the Toolkit. Wavelet Release Notes This menu item will display the Release Notes file included with the Toolkit. About IDL Wavelet Toolkit... Select this menu item to display information about the current version of IDL and the IDL Wavelet Toolkit. IDL Wavelet Toolkit Menu Description 18 Chapter 2: Using the IDL Wavelet Toolkit Preferences The Preferences dialog, under the File Menu, allows you to set various default preferences and options for the currently active dataset. Note The Preferences are saved within each dataset rather than in a separate preferences file; each dataset can therefore have its own set of preferences. Note, however, that opening a new dataset may change the current preferences. These new preferences will remain in effect until changed either via the Preferences window or by opening a different dataset. Default Directory Set this option to your working directory. The Wavelet Toolkit will start all file open or save dialogs in this directory. This directory may be overridden if “Remember Current Directory” is set. Remember Current Directory Set this option to cause the Wavelet Toolkit to store the directory selected within any file open or save dialogs, and to use this directory for future dialogs. If this option is not set, the “Default Directory” will be used. Confirm Exit If this option is set, the Wavelet Toolkit will ask you for confirmation when you exit the Toolkit. Compress Save Files Set this option to use file compression when saving dataset files. Compressed files will occupy less disk space than uncompressed files, but may be slower to save and open. Stride Factor When importing large data arrays, the IDL Wavelet Toolkit will automatically calculate the X and Y stride values by dividing the length of vector arrays by the “Vector” stride factor, and each dimension of two-dimensional arrays by the “Array” stride factor. After the data is imported, you may change the X and Y stride values on the Dataset Viewer. The minimum stride factor is 2. Preferences IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 19 Tip To force the stride values to always be set to 1 when importing data, set the stride factors to a value larger than the maximum dimension for your data. “Defaults” Button Press this button to restore all of the preferences to their default settings. IDL Wavelet Toolkit Preferences 20 Chapter 2: Using the IDL Wavelet Toolkit Dataset Viewer Your dataset can consist of several different variables, each with a different data format. The Dataset Viewer, located in the middle of the Wavelet Toolkit applet, allows you to organize and manipulate your dataset. The variables are assigned a number and a name derived from the Variable name. You can sort the variables using the Move Variable Left and Move Variable Right buttons. Variable Information Each variable contains a one-dimensional vector or two-dimensional array of data values. The data values can be of any numeric type, such as BYTE, INTEGER, FLOAT, etc. The variable also has several descriptor fields which you can modify, described below and summarized in the table below. To modify a field, double-click with the left-mouse button on the field. After editing the field, press the <Return> key to keep your changes or, click outside of the table to discard your changes. Type This string shows the numeric type and the array size of the data. It is not modifiable by the user. Title This string contains the overall name of the variable. The Title field is used to label the Wavelet Power Spectrum and Multiresolution widgets. The default is the null ('') string. Variable This string provides a short name for the variable. The Variable is used to label plots, and for the labels in the Dataset Viewer. For a one-dimensional vector (e.g. a time series), the Variable is equivalent to Ytitle. The default is either the name of the import file, or 'Data' if imported from the IDL> command prompt. Units This string gives the units of the variable, and is used to label various plots. For a one-dimensional vector (e.g. a time series), the Units is equivalent to the Yunits. The default is the null ('') string. Dataset Viewer IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit Field Type 21 Example (1D vector) Example (2D array) Title STRING Wave audio recording IEEE Test Image Variable STRING Channel1 IEEEtest Units STRING Amplitude intensity Xname STRING Time X Xunits STRING seconds pixels Xstart STRING 0 0 Dx STRING 1d0/22050 1 Yname STRING Y Yunits STRING pixels Ystart STRING 0 Dy STRING 1 Xoffset LONG 0 0 Xcount LONG 16384 256 Xstride LONG 1 2 Yoffset LONG 0 Ycount LONG 256 Ystride LONG 2 Source STRING wavelet/data/hello.wav wavelet/data/IEEEtest.tif Notes STRING Voice saying ‘hello’ IEEE test image Table 2-1: Data fields in the Dataset Viewer . Xname This string is the name of the independent variable for the first data dimension (“X”), and is used to label the x-axis. The default is the null ('') string. IDL Wavelet Toolkit Dataset Viewer 22 Chapter 2: Using the IDL Wavelet Toolkit Xunits This string gives the units of X. The default is the null ('') string. Xstart This string gives the value of the first X coordinate. The default is '0'. Xstart can contain complicated mathematical expressions, although the result must be a scalar number. Dx This string gives the sampling interval between the X coordinates. The default is '1'. Dx can contain complicated mathematical expressions, although the result must be a scalar number. Yname This string is the name of the independent variable for the second data dimension (“Y”), and is used to label the y-axis (for a one-dimensional variable this is actually equivalent to the name of the dependent Variable). The default is the null ('') string. Yunits This string gives the units of Y. The default is the null ('') string. Ystart This string gives the value of the first Y coordinate. The default is '0'. Ystart can contain complicated mathematical expressions, although the result must be a scalar number. Dy This string gives the sampling interval between the Y coordinates. The default is '1'. Dy can contain complicated mathematical expressions, although the result must be a scalar number. Xoffset The offset along the first data dimension at which to start. The default is 0L. Xcount The number of data points to use along the first data dimension. The default is the size of the first dimension. Dataset Viewer IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 23 Xstride The sampling interval along the first data dimension. The default is 1L. Yoffset This long integer gives the offset along the second data dimension at which to start. The default is 0L. Ycount This long integer gives the number of data points to use along the second data dimension. The default is the size of the second dimension. Ystride This long integer gives the sampling interval along the second data dimension. The default is 1L. Source This string describes the original source or location of the data. The default is either the full filename (if the data was from a file) or ’Imported’ (if the data was from the IDL> command prompt). Notes You can enter miscellaneous information into the Notes string. The default is the null ('') string. Mathematical Expressions For Xstart, Dx, Ystart, and Dy, it is highly recommended that whenever possible you enter mathematical expressions, rather than converting to numbers. For example, in the above table, the sampling rate for hello.wav is 22050 Hz. One could have entered Dx as 0.00004535 rather than ‘1d0/22050’. Nevertheless, the latter is not only more accurate (limited only by your computer’s precision) but is also much more informative. (Note that the ‘1d0’ forces the computation to be done in double precision.) You may also enter IDL functions in these strings. For example, if your X coordinate was in Julian days, starting from say 29 February 2000, you could set Xstart = 'JULDAY(2,29,2000)'. IDL Wavelet Toolkit Dataset Viewer 24 Chapter 2: Using the IDL Wavelet Toolkit Selecting Variables To select a particular variable for visualization or some other action, click the mouse on any field for that variable, or click the mouse on the Table row label to highlight the entire row. To select multiple variables for deletion, click the mouse on any field and drag down to select the list of variables, or click once on the row label, scroll down and hold the <Shift> key while clicking on the last row label. Dataset Viewer IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 25 Importing Data You can import data in multiple file formats into the IDL Wavelet Toolkit. ASCII Files Select this menu item or button to import data from an ASCII text file. After choosing the file using the Select Import File dialog, you can specify the particular format for the ASCII_TEMPLATE dialog. See “ASCII_TEMPLATE” (IDL Reference Guide) for more information. The ASCII_TEMPLATE routine handles ASCII files consisting of an optional header of a fixed number of lines, followed by columnar data. The procedure consists of three steps: 1. “Define Data Type/Range”— Specify whether the data is in fixed width columns or separated by commas or spaces. The first 50 lines are displayed. Choose the first line of data and click on the Next > button; 2. “Define Fields”— Choose the number of fields per line and then click Next >; 3. “Field Specification”— You can change the names and data types for the various fields. The Field names can also be changed once the data is imported into the Toolkit. Click on the Finish button to import the data into the Wavelet Toolkit. Once the data is successfully imported, you can change the default names for the variable Title, Variable, etc. Independent Variable For ASCII files with multiple columns, if the first column is determined to be monotonically increasing in value, or is assigned the field name “TIME” within the ASCII_TEMPLATE, then it is assumed to be the “independent variable.” In this case the remaining columns are then imported as the “dependent variables.” Note You may change the name “TIME” after the data has been imported into the Wavelet Toolkit. Two-Dimensional Arrays By default, each column within the file will be imported into the IDL Wavelet Toolkit as a separate variable. To import a two-dimensional array of data, you should IDL Wavelet Toolkit Importing Data 26 Chapter 2: Using the IDL Wavelet Toolkit use the Group All button within the ASCII_TEMPLATE dialog to connect all of the columns into one field. Binary Files Select this menu item or button to import data from a binary data file. After choosing the file using the Select Import File dialog, you can specify the particular format for the file using the BINARY_TEMPLATE dialog. See “BINARY_TEMPLATE” (IDL Reference Guide) for more information. The BINARY_TEMPLATE routine handles raw binary files consisting of headers and multiple data fields. The dialog consists of a Binary Template window where you can define various fields within the file. Each field will be imported into the Wavelet Toolkit as a separate variable. Image Files Select this menu item or button to import an image file. The function DIALOG_READ_IMAGE is used to select the image file. For files with multiple images you can choose the particular image you wish to import. See “DIALOG_READ_IMAGE” (IDL Reference Guide) for more information. For TrueColor (24-bit) images, you will then be asked how you wish to convert the three channels into a single two-dimensional image. You have the option to scale the data into an intensity from 0–255, quantize the 24-bit colors down to 256 colors, or split the three channels into separate red, green, and blue images. WAV Audio Files Select this menu item or button to import a .WAV (RIFF) audio file as a onedimensional vector. The file must be in uncompressed PCM format. Multiple channels are imported as separate variables, one for each channel. IDL Command Line You can also import data directly from the IDL> command prompt using the WV_IMPORT_DATA command: WV_IMPORT_DATA, variable where variable is either a data vector or array, or a structure of data tags (see “WV_IMPORT_DATA” on page 96 for tag information). Importing Data IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 27 If there is more than one Wavelet Toolkit applet currently running, then variables are entered into the one that was most-recently active. IDL Wavelet Toolkit Importing Data 28 Chapter 2: Using the IDL Wavelet Toolkit Wavelet Viewer The Wavelet Viewer is accessible from the Visualize menu or button, and can also be started from the IDL> command prompt using the WV_CW_WAVELET function: wId = WV_CW_WAVELET() For more information, see “WV_CW_WAVELET” on page 62. The Wavelet Viewer consists of a graph of the currently-selected wavelet function, a selection area for the wavelet function, and an information area, shown in the following figure: Figure 2-2: The Wavelet Viewer. Wavelet and Scaling Functions The wavelet consists of two components, the scaling function which describes the low-pass filter for the wavelet transform, and the wavelet function which describes the band-pass filter for the transform. Changing Wavelets The droplist contains the names of all currently-available wavelets. The Family refers to the overall properties of the wavelet, while the Order determines the particular wavelet within each family. Wavelet Viewer IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 29 Wavelet Information After you select a wavelet family and order, the following information will be displayed: Discrete/Continuous Discrete wavelet functions are used with the discrete wavelet transform, which provides the most compact representation of the data. The discrete transform is very fast and is best suited for image processing, filtering, and large arrays. Continuous wavelet functions are used to approximate the continuous wavelet transform, which provides a highly-redundant transformation of the data. The continuous wavelet transform is much smoother than the discrete transform and is better suited for time-series analysis on small arrays (less than 20000 data points). Orthogonal/Nonorthogonal Orthogonal wavelet functions will have no overlap with each other (zero correlation) when computing the wavelet transform, while nonorthogonal wavelets will have some overlap (nonzero correlation). Using an orthogonal wavelet, you can transform to wavelet space and back with no loss of information. Nonorthogonal wavelet functions tend to artificially add in energy (due to the overlap) and require renormalization to conserve the information. In general, discrete wavelets are orthogonal while continuous wavelets are nonorthogonal. Symmetry This flag describes the symmetry of the wavelet function about the midpoint. Symmetric wavelets show no preferred direction in “time,” while asymmetric wavelets give unequal weighting to different directions. Compact Support This value measures the effective width of the wavelet function. A narrow wavelet function such as the Daubechies order 2 (compact support=3) is fast to compute, but the narrowness in “time” implies a very large width in “frequency.” Conversely, wavelets with large compact support such as the Daubechies order 24 (compact support=47) are smoother, have finer frequency resolution and are usually more efficient at denoising. IDL Wavelet Toolkit Wavelet Viewer 30 Chapter 2: Using the IDL Wavelet Toolkit Vanishing Moments An important property of a wavelet function is the number of vanishing moments, which describes the effect of the wavelet on various signals. A wavelet such as the Daubechies 2 with vanishing moment=2 has zero mean and zero linear trend. When the Daubechies 2 wavelet is used to transform a data series, both the mean and any linear trend are filtered out of the series. A higher vanishing moment implies that more moments (quadratic, cubic, etc.) will be removed from the signal. Regularity The regularity gives an approximate measure of the number of continuous derivatives that the wavelet function possesses. The regularity therefore gives a measure of the smoothness of the wavelet function with higher regularity implying a smoother wavelet. e-Folding Time (Continuous Wavelets Only) The e-folding time is a measure of the wavelet width, relative to the wavelet scale s. Using the wavelet transform of a spike, the e-folding time is defined as the distance at which the wavelet power falls to 1/e^2, where e = 2.71828. Larger e-folding time implies more spreading of the wavelet power. User-Defined Wavelets You can easily extend the IDL Wavelet Toolkit by adding more wavelet functions. These wavelet functions should follow the same calling mechanism as the built-in wavelet functions such as “WV_FN_DAUBECHIES” on page 80. In addition, your wavelet function should begin with the prefix 'wv_fn_'. 1. Let’s say you would like to add a wavelet function called “Spline” giving the Daubechies “Spline” wavelets. To do this, first create a wavelet function to return the wavelet coefficients and the information structure: FUNCTION wv_fn_spline, Order, Scaling, Wavelet, Ioff, Joff ; compute coefficients here... ... ; find support, moments, and regularity ... info = {family:'Spline', $ order_name:'Order', $ order_range:[1,5,1], $ order:order, $ discrete:1, $ orthogonal:1, $ Wavelet Viewer IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 31 symmetric:0, $ support:support, $ moments:moments, $ regularity:regularity} RETURN, info END 2. Save this function in a file 'wv_fn_spline.pro' that is accessible from your current IDL path. 3. Now start the Wavelet Toolkit with your new wavelet function: WV_APPLET, WAVELETS='Spline' Or, if you are already running the Wavelet Toolkit: WV_IMPORT_WAVELET, 'Spline' Your new wavelet function should appear in the list of current wavelet functions, and should be accessible from any of the wavelet tools. IDL Wavelet Toolkit Wavelet Viewer 32 Chapter 2: Using the IDL Wavelet Toolkit Wavelet Power Spectrum The wavelet transform converts the data array into a series of wavelet coefficients, each of which represents the amplitude of the wavelet function at a particular location within the array and for a particular wavelet scale. The Wavelet Power Spectrum viewer, shown in the following figure, allows you to visualize the wavelet power as a three-dimensional surface plot, where the height of the surface represents the magnitude of the wavelet coefficients. Figure 2-3: The Wavelet Power Spectrum 3D viewer. Wavelet Power Spectrum IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 33 File Menu Open State... This menu item opens a previously saved “state” file into a new window. Save State... This menu item saves the current state of the Wavelet Power Spectrum into a file. Export To... • Bitmap File [Windows only]: The bitmap file saves the current image as a bitmap. • Vector Metafile [Windows only]: The vector metafile produces a scalable image file, but may not be able to accurately reproduce the 3D geometry. • Bitmap Pict [Macintosh only]: The bitmap pict saves the current image as a bitmap. • Bitmap Postscript: The bitmap postscript format saves the current image as a bitmap. • Vector Postscript: The vector postscript format takes less disk space than bitmap, and is scalable, but may not be able to accurately reproduce the 3D geometry. • VRML: The Virtual Reality Markup Language produces a three-dimensional output file suitable for web publication. Note It is not always possible to translate the complicated 3D geometry produced by IDL object graphics into equivalent VRML code. Print This menu item will output the image to a printer. Close This menu item closes the Wavelet Power Spectrum viewer. IDL Wavelet Toolkit Wavelet Power Spectrum 34 Chapter 2: Using the IDL Wavelet Toolkit Edit Menu Undo This menu item will undo the previous rotation, scaling, or translation of the model. Copy To Clipboard This menu item makes a copy of the current graphics image and places it on the system clipboard. View Menu Color Table Selecting this item brings up the XLOADCT color table editor. You can then choose different color tables for the graphics image. See “XLOADCT” (IDL Reference Guide) for more information. Drag Quality This submenu has three different settings that affect the drawing speed during object manipulations: • Low— only the axes are exposed for graphics manipulation such as rotation and translation; • Medium— low resolution graphics are used for graphics manipulation; • High— full resolution is used for all graphics manipulations Wavelet Options If you select this menu item, the Wavelet Options panel will be hidden. Select this menu item again to show the panel. View Options If you select this menu item, the View Options panel will be hidden. Select this menu item again to show the panel. Help Menu This menu contains Help items for the Wavelet Power Spectrum and for IDL. Wavelet Power Spectrum IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 35 Wavelet Options You can change the current wavelet family or the order. The plot will be automatically updated. Note For two-dimensional input data, only the discrete wavelet functions are available. View Options 3D Turn this button off to rotate the image so it appears flat. Turn this button on to rotate the image to a three-dimensional perspective. For vector data, this button also controls whether the data series and global wavelet plot are flat or vertical. Note The surface will remain three-dimensional; only the viewpoint is changed. Color Bar Turn this button off to remove the color bar at the bottom. Turn this button on to restore the color bar. Data Plot [One-dimensional only] Turn this button off to remove the data series plot at the back. Turn this button on to restore the plot. Global [One-dimensional only] Turn this button off to remove the plot of the global wavelet. Turn the button on to restore the plot. Zero Phase Lines [Complex wavelet functions only] Turn this button on to add the zero wavelet phase lines to the surface plot. Energy Scaling These buttons control the scaling of the wavelet magnitude in the Z-direction. IDL Wavelet Toolkit Wavelet Power Spectrum 36 Chapter 2: Using the IDL Wavelet Toolkit Power The power is the absolute-value-squared of the wavelet coefficients. The height of each point measures the contribution to the total energy. This scaling emphasizes large peaks and sharp discontinuities, and de-emphasizes low-amplitude background noise. Magnitude The magnitude is the absolute value of the wavelet coefficients, and provides a measure of the relative amplitude of each point. This scaling reduces the weighting given to large peaks and can bring out finer-detail features. Decibels The power can also be displayed in decibels, normalized relative to the mean of the wavelet power spectrum. Since decibels are a logarithmic scale, the smallest wavelet coefficients are given just as much weight as the largest coefficients. This scaling is most useful for data that contain a broad range of energy, or that contain a single sharp spike embedded in small-amplitude noise. db Cutoff You can specify the lower cutoff for the Decibel plot. The default is –50 db. Surface Style There are seven different surface plots from which to choose: • Points— places colored dots at each location/height; • Mesh— creates an unfilled surface plot; • Surface— creates a shaded filled surface; • XZ Lines— draws lines parallel to the X-axis, one for each Y location; • YZ Lines— draws lines parallel to the Y-axis, one for each X location; • Lego— draws a lego-block plot with mesh sides; • Lego filled— draws a lego-block plot with solid sides. You can also use the buttons to remove or add a “Skirt” around the surface, make the surface “Flat”, or change to a “Gray” palette. Wavelet Power Spectrum IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 37 Contour Lines You can choose to include contour lines at the top of the plot, the bottom, or three dimensional. Color Contours You can also put color contours at the top, bottom, or 3D. The color contours can be either open or filled. The color palette is the same as that used for the surface plot. Tip To produce a shaded surface with contours, make the surface “Shaded”, set the “Gray” button, and select “3D” color contours. Significance The statistical significance of each point in the wavelet power spectrum can be plotted as a three-dimensional sheet, or as contours on the top, bottom, or 3D. Points in the wavelet power spectrum that lie above the sheet (or within the contours) are said to be “significant at the xx% level,” where xx is your chosen percentage. You can choose the significance level as 10%, 5%, 1%, or 0.1%. Note The significance level is given by the chi-square function with one degree of freedom for real wavelet functions, or two degrees of freedom for complex wavelets (such as the Morlet). This significance is relative to the wavelet power spectrum of a random dataset (assuming Gaussian “white noise”). Power Display The graphics window contains the three-dimensional image and a color palette. If you move the mouse cursor over points in the image, the current location and power will be displayed in the Status Bar. Rotation, Translation, Stretching To rotate the image, click on the image while holding down the left mouse button, and drag the mouse pointer to rotate the image about the midpoint. To translate the image, click on the image while holding down the right mouse button (on the Macintosh hold down the command key also), and drag the mouse pointer. IDL Wavelet Toolkit Wavelet Power Spectrum 38 Chapter 2: Using the IDL Wavelet Toolkit To stretch the image, click on the image while holding the middle mouse button (on Windows hold down the Ctrl key also; on Macintosh hold down the Option key). Drag the mouse pointer right/left to stretch/shrink in the X-direction, drag the pointer up/down to stretch/shrink in the Y-direction. Wavelet Power Spectrum IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 39 Multiresolution Analysis Multiresolution Analysis uses the wavelet transform to decompose a data series in a cascade from the smallest scales to the largest. At each scale there are three components: the Smooth (or low-pass filtered) data series, the Details (or band-pass) data series, and the Rough (or high-pass). For one-dimensional vectors, this can be viewed as a hierarchy of x-y plots, as shown in the following figure: For two-dimensional arrays, the multiresolution analysis gives a series of images. File Menu Page Setup This menu item sets up the page height and width for exporting and printing. Export Postscript Export the image to a postscript file. Printer Setup This menu item allows you to set up the printer via the Printer Dialog. Print This menu item prints the image. Close This menu item closes the Multiresolution viewer. Wavelet Options You can change the current wavelet family, or the order. The plot will be updated automatically. IDL Wavelet Toolkit Multiresolution Analysis 40 Chapter 2: Using the IDL Wavelet Toolkit Figure 2-4: Multiresolution Analysis of the “Chirp” Variable Multiresolution Analysis IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 41 Denoise Tool You can use the Denoise Tool to explore different techniques for removing noise and compressing data using the wavelet transform. The Denoise Tool is shown in the following figure. The plots and options are described below. Figure 2-5: The Denoise Tool IDL Wavelet Toolkit Denoise Tool 42 Chapter 2: Using the IDL Wavelet Toolkit File Menu Open State... This menu item opens a previously saved “state” file into a new window. Save State... This menu item saves the current state of the Denoise Tool into a file. Close This menu item closes the Denoise Tool viewer. Original Data This window displays a graph of the original one-dimensional vector or twodimensional image. For images, all values are converted to an intensity (0–255) and a grayscale color palette is used. Filtered Data This window displays the data after filtering using the wavelet function and options given on the right. For images, all values are converted to an intensity (0–255) and a grayscale color palette is used. Wavelet Coefficients The filtered coefficients are displayed as a two-dimensional image using a logarithmic energy scaling. The method is as follows: 1. Find the maximum value “Pm” of the original, unfiltered, wavelet power (absolute-value squared of the wavelet coefficients); 2. Square the filtered wavelet coefficients to get wavelet power, then take the base-10 logarithm of each; 3. Scale this logarithmic power from the range [–10 Log10(Pm), Log10(Pm)] into the range [32, 255]. Values greater than zero but less than –10 Log10(Pm) are set equal to 32. 4. Set all values removed by the filter to zero (0). 5. Display the image using a grayscale color palette. Denoise Tool IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 43 Using the above method, all retained coefficients will appear in the image, shaded from dark gray (32) to white (255). Coefficients that have been removed will be black. Coefficient Power This graph shows the wavelet power for each coefficient, sorted into decreasing order, and scaled so that the total power is 100%. The wavelet power is also shown as a cumulative plot, where each point represents the sum of all of the previous points. Both curves are plotted on a logarithmic x-axis, so that the largest coefficients are easily visible. The dashed line shows the current cutoff value that you have selected. Wavelet Options You can change the current wavelet family or the order. Since all of the denoise options remain constant, you can compare the effects of different wavelet orders and families. Denoise Options Cumulative Power The slider bar allows you to set the cutoff threshold for cumulative power. Coefficients to the right of the dotted line in the Coefficient Power graph will be excluded. The # Coeffs box is adjusted accordingly. Note At low cumulative power you may notice that the slider adjusts itself in uneven increments. This is designed so that at least one additional coefficient is either discarded (as the slider moves left) or retained (as the slider moves right). These jumps in power correspond to the discrete steps in the coefficient power graph. Number of Coefficients You can specify the exact number of coefficients that you wish to retain. The cumulative power slider bar will be adjusted accordingly. Hard Threshold The hard threshold removes all discarded wavelet coefficients by setting them to zero and computing the inverse wavelet transform. For details see “Denoise” on page 51. IDL Wavelet Toolkit Denoise Tool 44 Chapter 2: Using the IDL Wavelet Toolkit Soft Threshold The soft threshold also sets all discarded wavelet coefficients to zero. However, it also linearly reduces the magnitude of the each retained wavelet coefficient by an amount equal to the largest discarded coefficient. For details see “Denoise” on page 51. Results Window This text window contains the following output results: Threshold The threshold is the actual wavelet power (in the variable’s units squared) that is used for the cutoff value. Percent of Coefficients This is the percent number of coefficients used in the reconstruction. The smaller the percent coefficients the more efficient the filter. RMS Difference This is the root-mean-square difference between the original data (upper-left plot) and the filtered data (upper-right plot) in the variable units. A smaller number implies a more accurate reconstruction. Percent Difference This is the percent difference between the original and filtered data, and is equal to 100% x (RMS difference/StdDev) where StdDev is the standard deviation of the original data. The smaller the percent difference, the more accurate the reconstruction. Function Call The text under Function Call contains the actual IDL code used to call the WV_DENOISE function. See “WV_DENOISE” on page 69 to copy this code into your own programs to call the denoise function directly. Denoise Tool IDL Wavelet Toolkit Chapter 2: Using the IDL Wavelet Toolkit 45 Adding User Tools You can extend the capabilities of the IDL Wavelet Toolkit by adding your own userdefined tool functions. These wavelet functions should follow the same calling mechanism as the built-in tool functions such as “WV_TOOL_DENOISE” on page 109. In addition, your tool function should begin with the prefix 'wv_tool_'. 1. Let’s say you want to add a wavelet tool called “Edge Detect” that uses the wavelet transform to detect edges in images. To do this, first create a tool function that accepts a data array and possibly other variable parameters: FUNCTION wv_tool_edgedetect, $ Array ; 1D vector or 2D array [,X] ; X coordinates of array [,Y] ; Y coordinates of array [, GROUP_LEADER=group_leader] [, TITLE=title] [, UNITS=units] [, XTITLE=xtitle] [, XUNITS=xunits] [, YTITLE=ytitle] [, YUNITS=yunits] [, XOFFSET=xoffset] [, YOFFSET=yoffset] ; start the edge detection applet... ... ; return the Widget ID for the applet RETURN, wID END 2. Save this function in a file wv_tool_edgedetect.pro that is accessible from your current IDL path. 3. Now start the Wavelet Toolkit with your new wavelet function: WV_APPLET, TOOLS=['Edge Detect'] Your new tool should appear in the Tools Menu. The actual function name is constructed by removing all white space from the name and attaching a prefix of WV_TOOL_. Note At a minimum, your tool function must accept a data Array. All other parameters (such as X and Y) and keywords (GROUP_LEADER, TITLE, etc.) are optional. The IDL Wavelet Toolkit will pass in only those parameters and keywords that are usable by your tool function. IDL Wavelet Toolkit Adding User Tools 46 Adding User Tools Chapter 2: Using the IDL Wavelet Toolkit IDL Wavelet Toolkit Chapter 3 Theory and Examples This chapter discusses the following topics: Wavelet Transform . . . . . . . . . . . . . . . . . . . . 48 Wavelet Power Spectrum . . . . . . . . . . . . . . . 49 Denoise . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 IDL Wavelet Toolkit Multiresolution Analysis . . . . . . . . . . . . . . 54 Bibliography . . . . . . . . . . . . . . . . . . . . . . . . 55 47 48 Chapter 3: Theory and Examples Wavelet Transform Background Wavelet analysis is a technique to transform an array of N numbers from their actual numerical values to an array of N wavelet coefficients. Each wavelet coefficient represents the closeness of the fit (or correlation) between the wavelet function at a particular size and a particular location within the data array. By varying the size of the wavelet function (usually in powers-of-two) and shifting the wavelet so it covers the entire array, you can build up a picture of the overall match between the wavelet function and your data array. Since the wavelet functions are compact (hence the term wave-let), the wavelet coefficients only measure the variations around a small region of the data array. This property makes wavelet analysis very useful for signal or image processing; the “localized” nature of the wavelet transform allows you to easily pick out features in your data such as spikes (for example, noise or discontinuities), discrete objects (in, for example, astronomical images or satellite photos), edges of objects, etc. The localization also implies that a wavelet coefficient at one location is not affected by the coefficients at another location in the data. This makes it possible to remove “noise” of all different scales from a signal, simply by discarding the lowest wavelet coefficients. For a general introduction to the wavelet transform and its applications see Hubbard (1998). Method The IDL Wavelet Toolkit uses the continuous and discrete wavelet transforms. Details on the discrete wavelet transform can be found in Daubechies (1992) and Mallat (1989). A good introduction to the DWT and multiresolution analysis is given in Lindsay et al. (1996). The DWT routines are based on the routines described in section 13.10 of Numerical Recipes in C: The Art of Scientific Computing, 2nd ed. (Cambridge University Press), and are used by permission. An introduction to the continuous wavelet transform for time series analysis can be found in Torrence and Compo (1998), along with a discussion of statistical significance testing. Wavelet Transform IDL Wavelet Toolkit Chapter 3: Theory and Examples 49 Wavelet Power Spectrum Background The wavelet coefficients yield information as to the correlation between the wavelet (at a certain scale) and the data array (at a particular location). A larger positive amplitude implies a higher positive correlation, while a large negative amplitude implies a high negative correlation. A useful way to determine the distribution of energy within the data array is to plot the wavelet power, equivalent to the amplitude-squared. By looking for regions within the Wavelet Power Spectrum (WPS) of large power, you can determine which features of your signal are important and which can be ignored. Method Given the wavelet transform Wi of a multi-dimensional data array, Ai, where i=0...N– 1 is the index and N is the number of points, then the Wavelet Power Spectrum is defined as the absolute-value squared of the wavelet coefficients, |Wi|2. One-dimensional Vector For a vector (such as a time series) the coefficients of wavelet power can be rearranged to yield a two-dimensional picture, where the first dimension is the independent variable (e.g. time) and the second dimension is the wavelet scale (e.g. 1/frequency). Two-dimensional Array The wavelet transform of a 2D array is also two-dimensional, and is arranged so that the smallest scales are in the upper-right quadrant (assuming that index [0, 0] is in the lower-left). Example Use the “Chirp” dataset that is included in the Wavelet sample file. This dataset contains a time series with a sine wave that has an exponentially-increasing frequency. You can use the Multiresolution Analysis viewer to examine the time series. IDL Wavelet Toolkit Wavelet Power Spectrum 50 Chapter 3: Theory and Examples Try the following steps: 1. From the main window, select the Chirp dataset and start the Wavelet Power Spectrum viewer using either the Visualize Menu or the Toolbar button. The WPS can be seen under “Wavelet Power Spectrum” on page 32. 2. Select the Morlet wavelet function from the Family dropdown box. You should be able to see the exponential increase in frequency as a band of high power extending from left to right, and ranging from about Scale=256 sec. near the beginning to Scale=16 sec. near the end of the time series. 3. To bring out the features more clearly, change the Energy Scaling dropdown item from Power to Magnitude. 4. Notice the large peak near Scale=256 sec. This is primarily due to the discontinuity that occurs when the dataset is wrapped around from the end back to the beginning. Move the Order slider bar from 6 to 4 to make the peak more narrow. Tip You can use your mouse to rotate, zoom in or out, or move the plot. 5. To find the chirp peaks, select the Zero Phase Lines check box. 6. Now deselect the 3D check box to view the surface from above. Figure 3-1: The Wavelet Power Spectrum of the Chirp Signal Wavelet Power Spectrum IDL Wavelet Toolkit Chapter 3: Theory and Examples 51 Denoise Background One of the most useful applications of wavelet analysis is to remove unwanted noise from a dataset. This noise could be due to measurement errors or instrument noise. In image processing the “noise” might be small-scale features or artifacts. You could try to remove noise from the signal by using a low-pass or band-pass Fourier filter. There are two problems with this approach: 1. You need to carefully choose the width and shape of your filter, both to avoid removing too much of your signal and to decrease “ringing” from peaks and discontinuities, and, 2. In many cases the noise is “white,” in other words, it is distributed across all frequencies or spatial scales. Wavelet analysis, on the other hand, offers a scale-independent and robust method to filter out noise. The basic technique involves computing the wavelet transform of your data and then decreasing or discarding the smallest wavelet coefficients. The inverse transform of these coefficients will then be a filtered version of your data. Method We assume that you have computed the wavelet transform Wi of a multi-dimensional data array, Ai, where i=0...N–1 is the index and N is the number of points. You then compute a threshold level W0. This threshold level can be based on the percent of wavelet power that you wish to retain, the number of coefficients, or some other method. Suggestions for choosing the threshold are given in Donoho and Johnstone (1994). Wavelet coefficients smaller than this threshold are discarded while those above are retained. There are two methods for thresholding: Hard threshold The hard threshold removes all discarded wavelet coefficients by setting them to zero and computing the inverse wavelet transform. This can be defined as: ⎧ ⎪ W Wi = ⎨ i ⎪ 0 ⎩ IDL Wavelet Toolkit Wi > W0 Wi ≤ W0 Denoise 52 Chapter 3: Theory and Examples where Wi is the wavelet coefficient and W0 is the chosen threshold level. Soft Threshold The soft threshold also sets all discarded wavelet coefficients to zero. However, it also linearly reduces the magnitude of the each retained wavelet coefficient by an amount equal to the largest discarded coefficient, i.e.: ⎧ ⎪ sgn ( W i ) ( W i – W 0 ) Wi = ⎨ 0 ⎪ ⎩ Wi > W 0 Wi ≤ W 0 where sgn(Wi) is the sign of Wi. Example We will look at a magnetic-resonance image (MRI) of the brain, and use the Denoising widget tool to filter out unwanted speckles and compress the size of the image. Try the following steps: 1. In WV_APPLET, choose File → Import → Image File, and navigate to the examples/data directory in the IDL distribution. 2. Import the file mr_brain.dcm. The file should contain a 256 x 256 unsigned integer (UINT) image. 3. In the Dataset Viewer, change the Title field to ‘MRI Brain Image’ and the Variable field to 'Brain'. 4. Select the Brain dataset and start up the Denoise tool from the Tools Menu. You should see the Denoise widget, with the threshold set to 100% and all coefficients retained. 5. Set the # coeffs threshold to 8192 points. You should then see a view similar to that of the following figure. Denoise IDL Wavelet Toolkit Chapter 3: Theory and Examples 53 Figure 3-2: The Denoise Widget for the MRI Brain Scan Notice that you have retained 12.5% of the coefficients and have discarded 87.5%. The black regions of the “Wavelet Coeffs” plot shows the discarded coefficients. The percent difference between the original and filtered image is about 6%. Examining the filtered image, you will notice that much of the speckling around the outside is now gone. In addition, some of the small-scale features and low-contrast regions within the image have been diminished. Finally, the dotted line on the Cumulative Power graph indicates that although you are only retaining 12.5% of the information you are preserving almost 100% of the variance, or power. IDL Wavelet Toolkit Denoise 54 Chapter 3: Theory and Examples Multiresolution Analysis Background The wavelet transform can be thought of as a band-pass filter, where the location and width in Fourier space depends on the wavelet scale. Larger scales imply a lower frequency and small bandwidth. In computing the wavelet transform, you change from small scales to larger scales. At each stage you can stop and compute the inverse wavelet transform using the remaining coefficients, while setting the small-scale coefficients to zero. You can then build up a series of smooth (or low-passed), detailed (or band-passed), or rough (high-passed) versions of your original data. Method Details on computing the multiresolution analysis can be found in Lindsay et al. (1996). Example Use the “Mantle convection” dataset that is included in the Wavelet sample file. This dataset contains an image of convection within the Earth’s mantle. Try the following steps: 1. Select the Convection dataset and start up the Multiresolution Analysis viewer using either the Visualize Menu or the Toolbar button. 2. As you progress from top to bottom the wavelet scale increases in powers of two. At the smallest scale most of the image is still in the Smooth image. Notice that the Rough image contains only the edges or discontinuities which the small scales can pick out. 3. Change to the Haar wavelet and observe the different structure of the images. Multiresolution Analysis IDL Wavelet Toolkit Chapter 3: Theory and Examples 55 Bibliography Daubechies, I., 1992: Ten Lectures on Wavelets. Society for Industrial and Applied Mathematics, 357 pp. Donoho, D. L. and I. M. Johnstone, 1994: Ideal spatial adaptation by wavelet shrinkage. Biometrika, 81, 425–455. Hubbard, B. B., 1998: The World According to Wavelets, 2nd ed. A. K. Peters, Wellesley, Mass., 331 pp. Lindsay, R. W., D. B. Percival, and D. A. Rothrock, 1996: The discrete wavelet transform and the scale analysis of the surface properties of sea ice. IEEE Trans. Geosci. Remote Sens., 34, 771–787. Mallat, S., 1989: Multiresolution approximation and wavelets. Trans. Amer. Math. Soc., 315, 69–88. Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992: Numerical Recipes in C: The Art of Scientific Computing, 2nd ed. Cambridge University Press, 994 pp. Torrence, C., and G. P. Compo, 1998: A practical guide to wavelet analysis. Bull. Amer. Meteor. Soc., 79, 61–78. IDL Wavelet Toolkit Bibliography 56 Bibliography Chapter 3: Theory and Examples IDL Wavelet Toolkit Chapter 4 IDL Wavelet Toolkit Reference This reference lists the following topics: List of Commands by Functionality . . . . . . WV_APPLET . . . . . . . . . . . . . . . . . . . . . . . WV_CW_WAVELET . . . . . . . . . . . . . . . . . WV_CWT . . . . . . . . . . . . . . . . . . . . . . . . . . WV_DENOISE . . . . . . . . . . . . . . . . . . . . . . WV_DWT . . . . . . . . . . . . . . . . . . . . . . . . . . WV_FN_COIFLET . . . . . . . . . . . . . . . . . . . WV_FN_DAUBECHIES . . . . . . . . . . . . . . WV_FN_GAUSSIAN . . . . . . . . . . . . . . . . . WV_FN_HAAR . . . . . . . . . . . . . . . . . . . . . IDL Wavelet Toolkit 58 60 62 66 69 74 78 80 82 85 WV_FN_MORLET . . . . . . . . . . . . . . . . . . 87 WV_FN_PAUL . . . . . . . . . . . . . . . . . . . . . 90 WV_FN_SYMLET . . . . . . . . . . . . . . . . . . 93 WV_IMPORT_DATA . . . . . . . . . . . . . . . . 96 WV_IMPORT_WAVELET . . . . . . . . . . . . 99 WV_PLOT3D_WPS . . . . . . . . . . . . . . . . 101 WV_PLOT_MULTIRES . . . . . . . . . . . . . 104 WV_PWT . . . . . . . . . . . . . . . . . . . . . . . . . 107 WV_TOOL_DENOISE . . . . . . . . . . . . . . 109 57 58 Chapter 4: IDL Wavelet Toolkit Reference List of Commands by Functionality Widget Commands and Visualization Tools The following table describes the widget and visualization tools: Command Description WV_APPLET Run IDL Wavelet Toolkit GUI (graphical user interface). WV_CW_WAVELET Compound widget to display and select wavelets. WV_IMPORT_DATA Import data from the IDL> command prompt. WV_IMPORT_WAVELET Import wavelet functions into the current applet. WV_PLOT3D_WPS Run the wavelet power spectrum GUI. WV_PLOT_MULTIRES Run the multiresolution analysis GUI. WV_TOOL_DENOISE Run the wavelet de-noising GUI. Table 4-1: Widget Commands and Tools Wavelet Transform The following table describes the wavelet transform commands: Command Description WV_CWT Compute the continuous wavelet transform of an array. WV_DENOISE Denoise an array using the discrete wavelet transform. WV_DWT Compute the discrete wavelet transform of an array. WV_PWT Compute the partial wavelet transform of a vector. Table 4-2: Wavelet Transform Commands List of Commands by Functionality IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 59 Wavelet Functions The following table describes the built-in wavelet functions: Command Description WV_FN_COIFLET Construct coiflet wavelet coefficients. WV_FN_DAUBECHIES Construct Daubechies wavelet coefficients. WV_FN_GAUSSIAN Construct the Gaussian wavelet function. WV_FN_HAAR Construct Haar wavelet coefficients. WV_FN_MORLET Construct the Morlet wavelet function. WV_FN_PAUL Construct the Paul wavelet function. WV_FN_SYMLET Construct symlet wavelet coefficients. Table 4-3: Wavelet Basis Functions IDL Wavelet Toolkit List of Commands by Functionality 60 Chapter 4: IDL Wavelet Toolkit Reference WV_APPLET The WV_APPLET procedure runs the IDL Wavelet Toolkit graphical user interface. Note The IDL Wavelet Toolkit must be licensed on your system to be able to use this procedure. Syntax WV_APPLET [, Input] [, ARRAY=array] [, GROUP_LEADER=widget_id] [, /NO_SPLASH] [, TOOLS=string array] [, WAVELETS=string or string array] Arguments Input Input can be either a string giving the name of a IDL Wavelet Toolkit save file, or a one- or two-dimensional array of data. If Input is not specified, then the sample file wv_sample.sav is opened. If Input is set to null string ('') then the IDL Wavelet Toolkit is started with an empty dataset. Keywords ARRAY Set this keyword to a one- or two-dimensional array of data to be imported into the IDL Wavelet Toolkit upon startup. If argument Input is set to a filename then ARRAY will be added to the list of variables. GROUP_LEADER The widget ID of an existing widget that serves as group leader for the newly-created widget. When a group leader is killed, for any reason, all widgets in the group are also destroyed. A given widget can be in more than one group. The WIDGET_CONTROL procedure can be used to add additional group associations to a widget. For more information see “WIDGET_CONTROL” (IDL Reference Guide). It is not possible to remove a widget from an existing group. WV_APPLET IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 61 NO_SPLASH If this keyword is set then the splash screen will not be displayed on startup. TOOLS A scalar string or vector of strings giving the names of user-defined functions to be included in the WV_APPLET Tools menu. The actual function names are constructed by removing all white space from each name and attaching a prefix of WV_TOOL_. WAVELETS A scalar string or vector of strings giving the names of user-defined wavelet functions to be included in WV_APPLET. The actual function names are constructed by removing all white space from each name and attaching a prefix of WV_FN_. Examples WV_APPLET, TOOLS=['Renormalize','My Tool'] The above statement will start up the Wavelet Toolkit, and add the user tools 'Renormalize' and 'My Tool' to the Tools menu. When these are selected the actual functions that will be called are WV_TOOL_RENORMALIZE and WV_TOOL_MYTOOL. Version History 5.3 Introduced See Also WV_CW_WAVELET, WV_IMPORT_DATA, WV_IMPORT_WAVELET, WV_PLOT3D_WPS, WV_PLOT_MULTIRES, WV_TOOL_DENOISE IDL Wavelet Toolkit WV_APPLET 62 Chapter 4: IDL Wavelet Toolkit Reference WV_CW_WAVELET The WV_CW_WAVELET function is a compound widget that lets the user select and display wavelet functions. WV_CW_WAVELET is accessible from the Visualize Menu of WV_APPLET. Note The IDL Wavelet Toolkit must be licensed on your system to be able to use this function. Syntax Result = WV_CW_WAVELET( [Parent] [, /DISCRETE] [, /NO_COLOR] [, /NO_DRAW_WINDOW] [, TITLE=string] [, UNAME=string] [, UVALUE=value] [, VALUE=structure] [, WAVELETS=string array] ) Return Value The returned value of this function is the widget ID of the newly-created widget. Arguments Parent The widget ID of the parent widget. Omit this argument to created a top-level widget. Keywords DISCRETE Set this keyword to include only discrete wavelets in the list of wavelet functions. Set this keyword to zero to include only continuous wavelets. The default is to include all available wavelets. NO_COLOR If this keyword is set, the wavelet functions will be drawn in black and white. NO_DRAW_WINDOW If this keyword is set, the draw window will not be included within the widget. WV_CW_WAVELET IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 63 TITLE Set this keyword equal to a scalar string containing the title of the top level base. TITLE is not used if the wavelet widget has a parent widget. If it is not specified, the default title is “Wavelets.” UNAME Set this keyword to a string that can be used to identify the widget in your code. You can associate a name with each widget in a specific hierarchy, and then use that name to query the widget hierarchy and get the correct widget ID. To query the widget hierarchy, use the WIDGET_INFO function with the FIND_BY_UNAME keyword. See “WIDGET_INFO” (IDL Reference Guide) for more information. The UNAME should be unique to the widget hierarchy because the FIND_BY_UNAME keyword returns the ID of the first widget with the specified name. UVALUE Set this keyword equal to the user value associated with the widget. VALUE Set this keyword to an anonymous structure of the form {FAMILY:'', ORDER:0d} representing the initial value for the widget. WAVELETS A scalar string or vector of strings giving the names of user-defined wavelet functions to be included in WV_CW_WAVELET. The actual function names are constructed by removing all white space from each name and attaching a prefix of WV_FN_. Widget Keywords Accepted The WV_CW_WAVELET function also accepts the following WIDGET_BASE keywords: ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_TOP, DISPLAY_NAME, FRAME, GROUP_LEADER, KBRD_FOCUS_EVENTS, MAP, NOTIFY_REALIZE, RESOURCE_NAME, SCR_XSIZE, SCR_YSIZE, SPACE, TLB_FRAME_ATTR, TRACKING_EVENTS, UNITS, XOFFSET, XSIZE, YOFFSET, YSIZE. See “WIDGET_BASE” (IDL Reference Guide) for more information. IDL Wavelet Toolkit WV_CW_WAVELET 64 Chapter 4: IDL Wavelet Toolkit Reference Keywords to WIDGET_CONTROL and WIDGET_INFO The widget ID returned by most compound widgets is actually the ID of the compound widget’s base widget. This means that many keywords to the WIDGET_CONTROL and WIDGET_INFO routines that affect or return information on base widgets can be used with compound widgets. In addition, you can use the GET_VALUE and SET_VALUE keywords to WIDGET_CONTROL to obtain or set the value of the wavelet. Use the command: WIDGET_CONTROL, id, GET_VALUE=value to read the current wavelet. To change the current wavelet, use the command: WIDGET_CONTROL, id, SET_VALUE=value In both cases value is an anonymous structure, {FAMILY: '', ORDER: 0}, where FAMILY is a string containing the name (for example ‘Daubechies’), and ORDER is a variable giving the order number. Depending on the family, ORDER can be of type Integer or Double. See “Creating a Compound Widget” (Chapter 2, Widget Application Programming) for a more complete discussion of controlling compound widgets using WIDGET_CONTROL and WIDGET_INFO. Widget Events Returned by the WV_CW_WAVELET Widget This widget generates event structures each time the family or order is changed. The event structure has the following definition: Event = { ID:0L, TOP:0L, HANDLER:0L, FAMILY:'', ORDER:0} The ID field is the widget ID of the WV_CW_WAVELET widget. The TOP field is the widget ID of the top-level widget. HANDLER is the widget ID of the widget handler. The FAMILY field contains the family name. The ORDER field contains the order number, and can be an Integer or a Double depending on the family. Version History 5.3 WV_CW_WAVELET Introduced IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 65 See Also WV_FN_COIFLET, WV_FN_DAUBECHIES, WV_FN_GAUSSIAN, WV_FN_HAAR, WV_FN_MORLET, WV_FN_PAUL, WV_FN_SYMLET IDL Wavelet Toolkit WV_CW_WAVELET 66 Chapter 4: IDL Wavelet Toolkit Reference WV_CWT The WV_CWT function returns the one-dimensional continuous wavelet transform of the input array. The transform is done using a user-inputted wavelet function. Syntax Result = WV_CWT(Array, Family, Order [, /DOUBLE] [, DSCALE=scalar] [, NSCALE=scalar] [, /PAD] [, SCALE=variable] [, START_SCALE=scalar]) Return Value The result is a two-dimensional array of type complex or double complex, containing the continuous wavelet transform of the input Array. Arguments Array A one-dimensional array of length N, of floating-point or complex type. Family A scalar string giving the name of the wavelet function to use for the transform. Order The order number, or parameter, for the wavelet function given by Family. Keywords DOUBLE Set this keyword to force the computation to be done in double-precision arithmetic. DSCALE Set this keyword to a scalar value giving the spacing between scale values, in logarithmic units. The default is 0.25, which gives four subscales within each major scale. WV_CWT IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 67 NSCALE Set this keyword to a scalar value giving the total number of scale values to use for the wavelet transform. The default is [log2(N/START_SCALE)]/DSCALE+1. PAD Set this keyword to force Array to be padded with zeroes before computing the transform. Enough zeroes are added to make the total length of Array equal to the next-higher power-of-two greater than 2N. Padding with zeroes prevents wraparound of the Array and speeds up the fast Fourier transform. Note Padding with zeroes reduces, but does not eliminate, edge effects caused by the discontinuities at the start and end of the data. SCALE Set this keyword to a named variable in which to return the scale values used for the continuous wavelet transform. The SCALE values range from START_SCALE up to START_SCALE·2^[(NSCALE–1)DSCALE]. START_SCALE Set this keyword to a scalar value giving the starting scale, in non-dimensional units. The default is 2, which gives a starting scale that is twice the spacing between Array elements. Reference Torrence and Compo, 1998: A Practical Guide to Wavelet Analysis. Bull. Amer. Meteor. Soc., 79, 61–78. Example ; Assume we have monthly random data. n = 500 dt = 1d/12 ; time sampling seed = 999 data = RANDOMN(seed, n) time = 1960 + dt*FINDGEN(n) ; Compute the wavelet transform and the power. wave = WV_CWT(data, 'Morlet', 6, /PAD, SCALE=scales) IDL Wavelet Toolkit WV_CWT 68 Chapter 4: IDL Wavelet Toolkit Reference wavePower = ABS(wave^2) ; Convert scales to time units. scales *= dt ; Contour visualization. ICONTOUR, wavePower, time, scales, /Y_LOG, YRANGE=[20,0.25], $ C_VALUE=FINDGEN(7)+1, $ /FILL, RGB_TABLE=39, $ YTITLE='Scale (years)', $ VIEW_TITLE='Wavelet Power' ; Insert a legend. tool = ITGETCURRENT(TOOL=oTool) void = oTool->DoAction('Operations/Insert/Legend') Version History 5.4 Introduced See Also WV_DWT, WV_FN_GAUSSIAN, WV_FN_MORLET, WV_FN_PAUL WV_CWT IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 69 WV_DENOISE The WV_DENOISE function uses the wavelet transform to filter (or de-noise) a multi-dimensional array. WV_DENOISE computes the discrete wavelet transform of Array, and then discards wavelet coefficients smaller than a certain threshold. WV_DENOISE then computes the inverse wavelet transform on the filtered coefficients and returns the result. Syntax Result = WV_DENOISE(Array [, Family, Order] [, COEFFICIENTS=value] [, CUTOFF=variable] [, DENOISE_STATE=variable] [, /DOUBLE] [, DWT_FILTERED=variable] [, PERCENT=value] [, THRESHOLD=value] [, WPS_FILTERED=variable]) Return Value The result is an array of the same dimensions as the input Array. If Array is double precision or /DOUBLE is set then the result is double precision, otherwise the result is single precision. Arguments Array A one-dimensional array of length N, of floating-point or complex type. Family A scalar string giving the name of the wavelet function to use for the transform. WV_DENOISE will construct the actual function name by removing all white space and attaching a prefix of 'WV_FN_'. Note WV_DENOISE may only be used with discrete wavelets, such as WV_FN_COIFLET, WV_FN_DAUBECHIES, WV_FN_HAAR, and WV_FN_SYMLET. IDL Wavelet Toolkit WV_DENOISE 70 Chapter 4: IDL Wavelet Toolkit Reference Order The order number, or parameter, for the wavelet function given by Family. If not specified the default for the wavelet function will be used. Note If you pass in a DENOISE_STATE structure, then Family and Order may be omitted. In this case the values from DENOISE_STATE are used. Keywords COEFFICIENTS Set this keyword to a scalar specifying the number of wavelet coefficients to retain in the filtered wavelet transform. This keyword is ignored if keyword PERCENT is present. CUTOFF Set this keyword to a named variable that, upon return, will contain the cutoff value of wavelet power that was used for the threshold. DENOISE_STATE This is both an input and an output keyword. If this keyword is set to a named variable, then on exit, DENOISE_STATE will contain the following structure: Tag Type Definition FAMILY STRING Name of the wavelet function used. ORDER DOUBLE Order for the wavelet function. DWT FLT/DBLARR Discrete wavelet transform of Array WPS FLT/DBLARR Wavelet power spectrum, equal to |DWT|^2 SORTED FLT/DBLARR Percent-normalized WPS, sorted CUMULATIVE FLT/DBLARR Cumulative sum of SORTED Table 4-4: The Structure Tags for DENOISE_STATE WV_DENOISE IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference Tag 71 Type Definition COEFFICIENTS LONG Number of coefficients retained PERCENT DOUBLE Percent of coefficients retained Table 4-4: The Structure Tags for DENOISE_STATE (Continued) Note If the DOUBLE keyword is set, then the arrays will be of type double. Upon input, if DENOISE_STATE is set to a structure with the above form, then DWT, WPS, SORTED, and CUMULATIVE will not be recomputed by WV_DENOISE. This is useful if you want to make multiple calls to WV_DENOISE using the same Array. Warning No error checking is made on the input values. The values should not be modified between calls to DENOISE_STATE. DOUBLE Set this keyword to force the computation to be done using double-precision arithmetic. DWT_FILTERED Set this keyword to a named variable in which the filtered discrete wavelet transform will be returned. PERCENT Set this keyword to a scalar specifying the percentage of cumulative power to retain. Note If neither COEFFICIENTS nor PERCENT is present then all of the coefficients are retained (i.e. no filtering is done). IDL Wavelet Toolkit WV_DENOISE 72 Chapter 4: IDL Wavelet Toolkit Reference THRESHOLD Set this keyword to a scalar specifying the type of threshold. The actual threshold, T, is set using COEFFICIENTS or PERCENT. Possible values are: Value Description 0 Hard threshold (this is the default). The hard threshold sets all wavelet coefficients with magnitude less than or equal to T to zero. 1 Soft threshold. The soft threshold sets all DWT[i] with magnitude less than T to zero, and also linearly reduces the magnitude of the each retained wavelet coefficient by T: Positive coefficients are set equal to DWT[i] – T, while negative coefficients are set equal to DWT[i] + T. Table 4-5: THRESHOLD Values WPS_FILTERED Set this keyword to a named variable in which the filtered wavelet power spectrum will be returned. Examples Remove the noise from a 128 x 128 image: image = dist(128) + 5*randomn(1, 128, 128) ; Keep only 100 out of 16384 coefficients: denoise = WV_DENOISE(image, 'Daubechies', 2, COEFF=100, $ DENOISE_STATE=denoise_state) window, xsize=256, ysize=155 tvscl, image, 0 tvscl, denoise, 1 xyouts, [64, 196], [5, 5], ['Image', 'Filtered'], $ /device, align=0.5, charsize=2 print, 'Percent of power retained: ', denoise_state.percent IDL prints: Percent of power retained: 93.151491 Change to a “soft” threshold (use DENOISE_STATE to avoid re-computing): denoise2 = WV_DENOISE(image, COEFF=100, $ DENOISE_STATE=denoise_state, THRESHOLD=1) WV_DENOISE IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 73 Figure 4-1: Example of De-Noising an Image. Version History 5.4 Introduced See Also WV_DWT, WV_TOOL_DENOISE IDL Wavelet Toolkit WV_DENOISE 74 Chapter 4: IDL Wavelet Toolkit Reference WV_DWT The WV_DWT function returns the multi-dimensional discrete wavelet transform of the input Array. The transform is done by WV_PWT using a user-inputted wavelet filter. The length of each dimension of Array must be either a power of two (2), or must be less than four (4). The transform is not computed over dimensions of lengths less than four (4), but is computed over all other dimensions (for example, the wavelet transform of an array of size [3, 256] is computed over each [1, 256] column vector). WV_DWT is based on the routine wtn described in section 13.10 of Numerical Recipes in C: The Art of Scientific Computing, 2nd ed. (Cambridge University Press), and is used by permission. Syntax Result = WV_DWT(Array, Scaling, Wavelet, Ioff, Joff [, /DOUBLE] [, /INVERSE] [, N_LEVELS=value]) Return Value The result is an output array of the same dimensions as Array, containing the discrete wavelet transform over each dimension. Arguments Array The input vector or array. The length of each dimension must be either less than four (4) or a power of two (2). Scaling A vector of scaling (father) coefficients, of length N. Wavelet A vector of wavelet (mother) coefficients, of length N. WV_DWT IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 75 Ioff An integer that specifies the support offset for Scaling. To center the scaling function over each point in Array, set Ioff to –N/2+2. Joff An integer that specifies the support offset for Wavelet. To center the wavelet function over each point in Array, set Joff to –N/2+2. Keywords DOUBLE Set this keyword to force the computation to be done in double-precision arithmetic. INVERSE If set, the inverse transform is computed. By default, the forward transform is computed. N_LEVELS Set this keyword to the number of wavelet levels to compute in the pyramid algorithm, starting with the smallest wavelet scale and progressing to larger scales. If this keyword is not set or is set to zero, then all wavelet levels in the pyramid algorithm are computed. Method and Result Format The WV_DWT function computes the wavelet coefficients using the pyramidal algorithm (Mallat 1989). One-Dimensional Vector For a one-dimensional vector, the pyramid appears below: Array elements [ 0, 1, 2, 3, \ / \ / s0,d0 s1,d1 \ / \ / S0,D0 \ \ IDL Wavelet Toolkit 4, 5, 6, 7, \ / \ / s2,d2 s3,d3 \ / \ / S1,D1 / / 8, 9, 10, 11, 12, 13, 14, 15] \ / \ / \ / \ / s4,d4 s5,d5 s6,d6 s7,d7 \ / \ / \ / \ / S2,D2 S3,D3 \ / \ / WV_DWT 76 Chapter 4: IDL Wavelet Toolkit Reference \ / \ / S0,D0 S1,D1 At each level of the hierarchy, the WV_PWT function is used to compute the scaling coefficient Si and wavelet coefficient Di (where i represents the position). The letters s, S, S and d, D, D represent increasing scale. The wavelet coefficients are stored in Result in order from largest scales to smallest: Result = [ S0, S1, D0, D1, D0, D1, D2, D3, d0, d1, d2, d3, d4, d5, d6, d7 ] Two-Dimensional Array For a two-dimensional Array, the wavelet transform is computed using the pyramidal algorithm along each dimension. The wavelet coefficients are stored in order with the largest scales in the [0, 0] position. As an example, for an 8 x 8 Array, the Result is an 8 x 8 array with the following structure: [0,0] [[ A0B0 [ A0B1 A1B0 A1B1 C0B0 C0B1 C1B0 C1B1 c0B0 c0B1 c1B0 c1B1 c2B0 c2B1 c3B0 ], c3B1 ], [ A0D0 [ A0D1 A1D0 A1D1 C0D0 C0D1 C1D0 C1D1 c0D0 c0D1 c1D0 c1D1 c2D0 c2D1 c3D0 ], c3D1 ], [ [ [ [ A1d0 A1d1 A1d2 A1d3 C0d0 C0d1 C0d2 C0d3 C1d0 C1d1 C1d2 C1d3 c0d0 c0d1 c0d2 c0d3 c1d0 c1d1 c1d2 c1d3 c2d0 c2d1 c2d2 c2d3 c3d0 c3d1 c3d2 c3d3 A0d0 A0d1 A0d2 A0d3 ], ], ], ]] Here A and B represent the scale coefficients for the first and second dimensions, respectively, The C and D represent the largest-scale wavelet coefficients for the first and second dimensions, respectively, while c and d represent the small-scale wavelet coefficients. Subscripts 0, 1, 2, 3 denote the position of the wavelet within the image. Example The following example shows how to compute the first three levels of the pyramid algorithm using either the N_LEVELS keyword or WV_PWT: ; Construct a random vector. n = 1024 x = randomn(s,n) info = WV_FN_DAUBECHIES(2, wavelet, scaling, ioff, joff) ; Take the wavelet transform but stop at level 3. WV_DWT IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 77 wv_dwtpartial = WV_DWT(x, wavelet, scaling, ioff, joff, $ N_LEVELS=3) ; First level of the pyramid algorithm. wv_level1 = WV_PWT(x, wavelet, scaling, ioff, joff) w_scaling1 = wv_level1[0:n/2-1] ; Left (scaling) half w_wavelet1 = wv_level1[n/2:*] ; Right (wavelet) half ; Second level of the pyramid algorithm. wv_level2 = WV_PWT(w_scaling1, wavelet, scaling, ioff, joff) w_scaling2 = wv_level2[0:n/4-1] ; Left (scaling) half w_wavelet2 = wv_level2[n/4:*] ; Right (wavelet) half ; Third level of the pyramid algorithm. wv_level3 = WV_PWT(w_scaling2, wavelet, scaling, ioff, joff) ; Verify that using WV_DWT with N_LEVELS=3 ; is the same as calling WV_PWT three times. wv_partial123 = [wv_level3, w_wavelet2, w_wavelet1] print, MAX(ABS(wv_dwtpartial - wv_partial123)) IDL prints: 0.000000 Version History 5.3 Introduced 6.1 Added N_LEVELS keyword See Also WV_CWT, WV_PWT, WTN IDL Wavelet Toolkit WV_DWT 78 Chapter 4: IDL Wavelet Toolkit Reference WV_FN_COIFLET The WV_FN_COIFLET function constructs wavelet coefficients for the coiflet wavelet function. Syntax Result = WV_FN_COIFLET( [Order, Scaling, Wavelet, Ioff, Joff] ) Return Value The returned value of this function is an anonymous structure of information about the particular wavelet. Tag Type Definition FAMILY STRING ‘Coiflet’ ORDER_NAME STRING ‘Order’ ORDER_RANGE INTARR(3) [1, 5, 1] Valid order range [first, last, default] ORDER INT The chosen Order DISCRETE INT 1 [0=continuous, 1=discrete] ORTHOGONAL INT 1 [0=nonorthogonal, 1=orthogonal] SYMMETRIC INT 2 [0=asymmetric, 1=symm., 2=near symm.] SUPPORT INT 6*Order – 1 [Compact support width] MOMENTS INT 2*Order [Number of vanishing moments] REGULARITY DOUBLE The number of continuous derivatives Table 4-6: Structure Tags for Result Arguments Order A scalar that specifies the order number for the wavelet. The default is 1. WV_FN_COIFLET IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 79 Scaling On output, contains a vector of double-precision scaling (father) coefficients. Wavelet On output, contains a vector of double-precision wavelet (mother) coefficients. Ioff On output, contains an integer that specifies the support offset for Scaling. Joff On output, contains an integer that specifies the support offset for Wavelet. Note If none of the above arguments are present then the function will simply return the Result structure using the default Order. Keywords None. Reference Coefficients are from Daubechies, I., 1992: Ten Lectures on Wavelets, SIAM, p. 261. Note that Daubechies has divided by Sqrt(2), and the coefficients are reversed. Version History 5.3 Introduced See Also WV_DWT, WV_FN_DAUBECHIES, WV_FN_HAAR, WV_FN_SYMLET IDL Wavelet Toolkit WV_FN_COIFLET 80 Chapter 4: IDL Wavelet Toolkit Reference WV_FN_DAUBECHIES The WV_FN_DAUBECHIES function constructs wavelet coefficients for the Daubechies wavelet function. Syntax Result = WV_FN_DAUBECHIES( [Order, Scaling, Wavelet, Ioff, Joff] ) Return Value The returned value of this function is an anonymous structure of information about the particular wavelet. Tag Type Definition FAMILY STRING ‘Daubechies’ ORDER_NAME STRING ‘Order’ ORDER_RANGE INTARR(3) [1, 24, 2] Valid order range [first, last, default] ORDER INT The chosen Order DISCRETE INT 1 [0=continuous, 1=discrete] ORTHOGONAL INT 1 [0=nonorthogonal, 1=orthogonal] SYMMETRIC INT 0 [0=asymmetric, 1=symm., 2=near symm.] SUPPORT INT 2*Order – 1 [Compact support width] MOMENTS INT Order [Number of vanishing moments] REGULARITY DOUBLE The number of continuous derivatives Table 4-7: Structure Tags for Result Arguments Order A scalar that specifies the order number for the wavelet. The default is 2. WV_FN_DAUBECHIES IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 81 Scaling On output, contains a vector of double-precision scaling (father) coefficients. Wavelet On output, contains a vector of double-precision wavelet (mother) coefficients. Ioff On output, contains an integer that specifies the support offset for Scaling. Joff On output, contains an integer that specifies the support offset for Wavelet. Note If none of the above arguments are present then the function will simply return the Result structure using the default Order. Keywords None. Reference Coefficients for orders 1–10 are from Daubechies, I., 1992: Ten Lectures on Wavelets, SIAM, p. 195. Note that Daubechies has multiplied by Sqrt(2). Coefficients for orders 11–24 are from http://www.isds.duke.edu/~brani/filters.html. Version History 5.3 Introduced See Also WV_DWT, WV_FN_COIFLET, WV_FN_HAAR, WV_FN_SYMLET IDL Wavelet Toolkit WV_FN_DAUBECHIES 82 Chapter 4: IDL Wavelet Toolkit Reference WV_FN_GAUSSIAN The WV_FN_GAUSSIAN function constructs wavelet coefficients for the Gaussian wavelet function. In real space, the Gaussian wavelet function is proportional to the m-th order derivative of a Gaussian, exp(–x2/2). The Gaussian second derivative, (x2–1) exp(–x2/2), is often referred to as the Marr wavelet. Syntax Result = WV_FN_GAUSSIAN( [Order] [, Scale, N] [, /DOUBLE] [, FREQUENCY=variable] [, /SPATIAL] [, WAVELET=variable]) The returned value of this function is an anonymous structure of information about the particular wavelet. Tag Type Definition FAMILY STRING ‘Gaussian’ ORDER_NAME STRING ‘Derivative’ ORDER_RANGE DBLARR(3) Valid orders [first, last, default] ORDER DOUBLE The chosen Order DISCRETE INT 0 [0=continuous, 1=discrete] ORTHOGONAL INT 0 [0=nonorthogonal, 1=orthogonal] SYMMETRIC INT 1 [0=asymmetric, 1=symm.] SUPPORT DOUBLE Infinity [Compact support width] MOMENTS INT 1 [Number of vanishing moments] REGULARITY DOUBLE Infinity [Number of continuous derivatives] E_FOLDING DOUBLE SQRT(2) [Autocorrelation e-fold distance] FOURIER_PERIOD DOUBLE Ratio of Fourier wavelength to scale Table 4-8: Structure Tags for Result WV_FN_GAUSSIAN IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 83 Arguments Order A scalar that specifies the non-dimensional order parameter for the wavelet. The default is 2. Scale A scalar that specifies the scale at which to construct the wavelet function. N An integer that specifies the number of points in the wavelet function. For Fourier space (SPATIAL=0), the frequencies are constructed following the FFT convention: • For N even: 0, 1/N, 2/N, ..., (N–2)/(2N), 1/2, –(N–2)/(2N), ..., –1/N. • For N odd: 0, 1/N, 2/N, ..., (N–1)/(2N), –(N–1)/(2N), ..., –1/N. For real space (/SPATIAL), the spatial coordinates are –(N–1)/2...(N–1)/2. Note If none of the above arguments are present then the function will simply return the Result structure using the default Order. Keywords DOUBLE Set this keyword to force the computation to be done in double-precision arithmetic. FREQUENCY Set this keyword to a named variable in which to return the frequency array used to construct the wavelet. This variable will be undefined if SPATIAL is set. SPATIAL Set this keyword to return the wavelet function in real space. The default is to return the wavelet function in Fourier space. WAVELET Set this keyword to a named variable in which to return the wavelet function. IDL Wavelet Toolkit WV_FN_GAUSSIAN 84 Chapter 4: IDL Wavelet Toolkit Reference Reference Torrence and Compo, 1998: A Practical Guide to Wavelet Analysis. Bull. Amer. Meteor. Soc., 79, 61–78. Examples Plot the Gaussian wavelet function at scale=20: n = 1000 ; pick a nice number of points info = WV_FN_GAUSSIAN( 2, 20, n, /SPATIAL, $ WAVELET=wavelet) plot, wavelet Now plot the same wavelet in Fourier space: info = WV_FN_GAUSSIAN( 2, 20, n, $ FREQUENCY=frequency, WAVELET=wave_fourier) plot, frequency, wave_fourier, $ xrange=[-0.2,0.2], thick=2 Version History 5.4 Introduced See Also WV_CWT, WV_FN_MORLET, WV_FN_PAUL WV_FN_GAUSSIAN IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 85 WV_FN_HAAR The WV_FN_HAAR function constructs wavelet coefficients for the Haar wavelet function. Note The Haar wavelet is the same as the Daubechies wavelet of order 1. Syntax Result = WV_FN_HAAR( [Order, Scaling, Wavelet, Ioff, Joff] ) Return Value The returned value of this function is an anonymous structure of information about the particular wavelet. Tag Type Definition FAMILY STRING ‘Haar’ ORDER_NAME STRING ‘Order’ ORDER_RANGE INTARR(3) [1, 1, 1] Valid order range [first, last, default] ORDER INT 1 DISCRETE INT 1 [0=continuous, 1=discrete] ORTHOGONAL INT 1 [0=nonorthogonal, 1=orthogonal] SYMMETRIC INT 0 [0=asymmetric, 1=symm., 2=near symm.] SUPPORT INT 1 [Compact support width] MOMENTS INT 1 [Number of vanishing moments] REGULARITY DOUBLE 0d [Number of continuous derivatives] Table 4-9: Structure Tags for Result IDL Wavelet Toolkit WV_FN_HAAR 86 Chapter 4: IDL Wavelet Toolkit Reference Arguments Order A scalar that specifies the order number for the wavelet. The default is 1. Scaling On output, contains a vector of double-precision scaling (father) coefficients. Wavelet On output, contains a vector of double-precision wavelet (mother) coefficients. Ioff On output, contains an integer that specifies the support offset for Scaling. Joff On output, contains an integer that specifies the support offset for Wavelet. Note If none of the above arguments are present then the function will simply return the Result structure using the default Order. Keywords None. Reference Daubechies, I., 1992: Ten Lectures on Wavelets, SIAM. Version History 5.3 Introduced See Also WV_DWT, WV_FN_COIFLET, WV_FN_DAUBECHIES, WV_FN_SYMLET WV_FN_HAAR IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 87 WV_FN_MORLET The WV_FN_MORLET function constructs wavelet coefficients for the Morlet wavelet function. In real space, the Morlet wavelet function consists of a complex exponential modulated by a Gaussian envelope: π–1/4s–1/2 exp[i k x / s] exp[– (x / s)2/2], where s is the wavelet scale, k is a non-dimensional parameter, and x is the position. Syntax Result = WV_FN_MORLET( [Order] [, Scale, N] [, /DOUBLE] [, FREQUENCY=variable] [, /SPATIAL] [, WAVELET=variable]) Return Value The returned value of this function is an anonymous structure of information about the particular wavelet. Tag Type Definition FAMILY STRING ‘Morlet’ ORDER_NAME STRING ‘Parameter’ ORDER_RANGE DBLARR(3) [3, 24, 6] Valid orders [first, last, default] ORDER DOUBLE The chosen Order DISCRETE INT 0 [0=continuous, 1=discrete] ORTHOGONAL INT 0 [0=nonorthogonal, 1=orthogonal] SYMMETRIC INT 1 [0=asymmetric, 1=symm.] SUPPORT DOUBLE Infinity [Compact support width] MOMENTS INT 1 [Number of vanishing moments] REGULARITY DOUBLE Infinity [Number of continuous derivatives] E_FOLDING DOUBLE SQRT(2) [Autocorrelation e-fold distance] FOURIER_PERIOD DOUBLE Ratio of Fourier wavelength to scale Table 4-10: Structure Tags for Result IDL Wavelet Toolkit WV_FN_MORLET 88 Chapter 4: IDL Wavelet Toolkit Reference Arguments Order A scalar that specifies the non-dimensional order parameter for the wavelet. The default is 6. Scale A scalar that specifies the scale at which to construct the wavelet function. N An integer that specifies the number of points in the wavelet function. For Fourier space (SPATIAL=0), the frequencies are constructed following the FFT convention: • For N even: 0, 1/N, 2/N, ..., (N–2)/(2N), 1/2, –(N–2)/(2N), ..., –1/N. • For N odd: 0, 1/N, 2/N, ..., (N–1)/(2N), –(N–1)/(2N), ..., –1/N. For real space (/SPATIAL), the spatial coordinates are –(N–1)/2...(N–1)/2. Note If none of the above arguments are present then the function will simply return the Result structure using the default Order. Keywords DOUBLE Set this keyword to force the computation to be done in double-precision arithmetic. FREQUENCY Set this keyword to a named variable in which to return the frequency array used to construct the wavelet. This variable will be undefined if SPATIAL is set. SPATIAL Set this keyword to return the wavelet function in real space. The default is to return the wavelet function in Fourier space. WAVELET Set this keyword to a named variable in which to return the wavelet function. WV_FN_MORLET IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 89 Reference Torrence and Compo, 1998: A Practical Guide to Wavelet Analysis. Bull. Amer. Meteor. Soc., 79, 61–78. Examples Plot the Morlet wavelet function at scale=100: n = 1000 ; pick a nice number of points info = WV_FN_MORLET( 6, 100, n, /SPATIAL, $ WAVELET=wavelet) plot, float(wavelet), THICK=2 oplot, imaginary(wavelet) Now plot the same wavelet in Fourier space: info = WV_FN_MORLET( 6, 100, n, $ FREQUENCY=frequency, WAVELET=wave_fourier) plot, frequency, wave_fourier, $ xrange=[-0.2,0.2], thick=2 Version History 5.4 Introduced See Also WV_CWT, WV_FN_GAUSSIAN, WV_FN_PAUL IDL Wavelet Toolkit WV_FN_MORLET 90 Chapter 4: IDL Wavelet Toolkit Reference WV_FN_PAUL The WV_FN_PAUL function constructs wavelet coefficients for the Paul wavelet function. In real space, the Paul wavelet function is proportional to the complex polynomial (1 – i x / s)^(–m–1), where s is the wavelet scale, m is a non-dimensional parameter, and x is the position. Syntax Result = WV_FN_PAUL( [Order] [, Scale, N] [, /DOUBLE] [, FREQUENCY=variable] [, /SPATIAL] [, WAVELET=variable]) Return Value The returned value of this function is an anonymous structure of information about the particular wavelet. Tag Type Definition FAMILY STRING ‘Paul’ ORDER_NAME STRING ‘Parameter’ ORDER_RANGE DBLARR(3) [1, 20, 4] Valid orders [first, last, default] ORDER DOUBLE The chosen Order DISCRETE INT 0 [0=continuous, 1=discrete] ORTHOGONAL INT 0 [0=nonorthogonal, 1=orthogonal] SYMMETRIC INT 1 [0=asymmetric, 1=symm.] SUPPORT DOUBLE Infinity [Compact support width] MOMENTS INT 1 [Number of vanishing moments] REGULARITY DOUBLE Infinity [Number of continuous derivatives] E_FOLDING DOUBLE 1/sqrt(2) [Autocorrelation e-fold distance] FOURIER_PERIOD DOUBLE Ratio of Fourier wavelength to scale Table 4-11: Structure Tags for Result WV_FN_PAUL IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 91 Arguments Order A scalar that specifies the non-dimensional order for the wavelet. The default is 4. Scale A scalar that specifies the scale at which to construct the wavelet function. N An integer that specifies the number of points in the wavelet function. For Fourier space (SPATIAL=0), the frequencies are constructed following the FFT convention: • For N even: 0, 1/N, 2/N, ..., (N–2)/(2N), 1/2, –(N–2)/(2N), ..., –1/N. • For N odd: 0, 1/N, 2/N, ..., (N–1)/(2N), –(N–1)/(2N), ..., –1/N. For real space (/SPATIAL), the spatial coordinates are –(N–1)/2...(N–1)/2. Note If none of the above arguments are present then the function will simply return the Result structure using the default Order. Keywords DOUBLE Set this keyword to force the computation to be done in double-precision arithmetic. FREQUENCY Set this keyword to a named variable in which to return the frequency array used to construct the wavelet. This variable will be undefined if SPATIAL is set. SPATIAL Set this keyword to return the wavelet function in real space. The default is to return the wavelet function in Fourier space. WAVELET Set this keyword to a named variable in which to return the wavelet function. IDL Wavelet Toolkit WV_FN_PAUL 92 Chapter 4: IDL Wavelet Toolkit Reference Reference Torrence and Compo, 1998: A Practical Guide to Wavelet Analysis. Bull. Amer. Meteor. Soc., 79, 61–78. Examples Plot the Paul wavelet function at scale=100: n = 1000 ; pick a nice number of points info = WV_FN_PAUL( 6, 100, n, /SPATIAL, $ WAVELET=wavelet) plot, float(wavelet), THICK=2 oplot, imaginary(wavelet) Now plot the same wavelet in Fourier space: info = WV_FN_PAUL( 6, 100, n, $ FREQUENCY=frequency, WAVELET=wave_fourier) plot, frequency, wave_fourier, $ xrange=[-0.2,0.2], thick=2 Version History 5.4 Introduced See Also WV_CWT, WV_FN_GAUSSIAN, WV_FN_MORLET WV_FN_PAUL IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 93 WV_FN_SYMLET The WV_FN_SYMLET function constructs wavelet coefficients for the Symlet wavelet function. Note The Symlet wavelet for orders 1–3 are the same as the Daubechies wavelets of the same order. Syntax Result = WV_FN_SYMLET( [Order, Scaling, Wavelet, Ioff, Joff] ) Return Value The returned value of this function is an anonymous structure of information about the particular wavelet. Tag Type Definition FAMILY STRING ‘Symlet’ ORDER_NAME STRING ‘Order’ ORDER_RANGE INTARR(3) [1, 15, 4] Valid order range [first, last, default] ORDER INT The chosen Order DISCRETE INT 1 [0=continuous, 1=discrete] ORTHOGONAL INT 1 [0=nonorthogonal, 1=orthogonal] SYMMETRIC INT 2 [0=asymmetric, 1=symm., 2=near symm.] SUPPORT INT 2*Order – 1 [Compact support width] MOMENTS INT Order [Number of vanishing moments] REGULARITY DOUBLE The number of continuous derivatives Table 4-12: Structure Tags for Result IDL Wavelet Toolkit WV_FN_SYMLET 94 Chapter 4: IDL Wavelet Toolkit Reference Arguments Order A scalar that specifies the order number for the wavelet. The default is 4. Scaling On output, contains a vector of double-precision scaling (father) coefficients. Wavelet On output, contains a vector of double-precision wavelet (mother) coefficients. Ioff On output, contains an integer that specifies the support offset for Scaling. Joff On output, contains an integer that specifies the support offset for Wavelet. Note If none of the above arguments are present then the function will simply return the Result structure using the default Order. Keywords None. Reference Coefficients for orders 1–10 are from Daubechies, I., 1992: Ten Lectures on Wavelets, SIAM, p. 198. Note that Daubechies has multiplied by Sqrt(2), and for some orders the coefficients are reversed. Coefficients for orders 11–15 are from http://www.isds.duke.edu/~brani/filters.html. Version History 5.3 WV_FN_SYMLET Introduced IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 95 See Also WV_DWT, WV_FN_COIFLET, WV_FN_DAUBECHIES, WV_FN_HAAR IDL Wavelet Toolkit WV_FN_SYMLET 96 Chapter 4: IDL Wavelet Toolkit Reference WV_IMPORT_DATA The WV_IMPORT_DATA procedure allows the user to add a variable to the currently active WV_APPLET widget from the IDL> command prompt. Note The IDL Wavelet Toolkit must be licensed on your system to be able to use this procedure. Syntax WV_IMPORT_DATA, Data [, MESSAGE_OUT=string] [, PARENT=variable] Arguments Data A one- or two-dimensional array of data, or a structure containing the data. Keywords MESSAGE_OUT A scalar string giving a message to be output to the WV_APPLET message bar. PARENT A long integer specifying the ID of the WV_APPLET widget in which to import the data. The default is the most-recently active WV_APPLET widget. Examples To import a 1D or 2D array directly into the active WV_APPLET widget: WV_IMPORT_DATA, Array To import a data structure: WV_IMPORT_DATA, {DATA: PTR_NEW(Array), $ SOURCE: ’Chandra X-Ray Observatory’, $ TITLE: ’Cygnus X-1 X-Ray Image’, $ VARIABLE: ’Cygnus X-1’, $ UNITS: ’Intensity’} WV_IMPORT_DATA IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 97 If Data is a structure then it must include at the very least a DATA tag containing a pointer to a one- or two-dimensional array. Recognized tags are shown in the following table. Tags other than these will be quietly ignored. Tag Type Definition DATA PTR->Array Pointer to data array TITLE STRING Long name of data variable VARIABLE STRING Short name of data variable UNITS STRING Units for variable XNAME STRING Name of X coordinate XUNITS STRING Units for X coordinate XSTART STRING Starting value for X coord DX STRING Sampling rate for X coord YNAME STRING Name of Y coordinate YUNITS STRING Units for Y coordinate YSTART STRING Starting value for Y coord DY STRING Sampling rate for Y coord XOFFSET LONG Starting index of X coord to use XCOUNT LONG Number of X coords to use XSTRIDE LONG X sampling interval to use YOFFSET LONG Starting index of Y coord to use YCOUNT LONG Number of Y coords to use YSTRIDE LONG Y sampling interval to use SOURCE STRING Filename or contact info NOTES STRING Miscellaneous notes COLORS PTR->Bytarr(3,256) Pointer to color table for Data Table 4-13: Tags Recognized by WV_IMPORT_DATA IDL Wavelet Toolkit WV_IMPORT_DATA 98 Chapter 4: IDL Wavelet Toolkit Reference Version History 5.3 Introduced See Also WV_APPLET WV_IMPORT_DATA IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 99 WV_IMPORT_WAVELET The WV_IMPORT_WAVELET procedure allows the user to add wavelet functions to the currently-active IDL Wavelet Toolkit(s). Note Any widgets that are currently active will not have access to the new wavelet functions until they are restarted. Note The IDL Wavelet Toolkit must be licensed on your system to be able to use this procedure. Syntax WV_IMPORT_WAVELET [, Wavelet] [, /RESET] Arguments Wavelet A string scalar or vector giving the names of the wavelet functions. The actual function names are constructed by removing all white space from each name and attaching a prefix of WV_FN_. Keywords RESET If set, then remove all user-defined wavelets from memory. If Wavelet is also specified then the new wavelets will be appended onto the built-in wavelets. Version History 5.3 IDL Wavelet Toolkit Introduced WV_IMPORT_WAVELET 100 Chapter 4: IDL Wavelet Toolkit Reference See Also WV_APPLET, WV_CW_WAVELET WV_IMPORT_WAVELET IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 101 WV_PLOT3D_WPS The WV_PLOT3D_WPS function runs the graphical user interface for threedimensional visualization of the wavelet power spectrum. WV_PLOT3D_WPS is accessible from the Visualize Menu of WV_APPLET. Note The IDL Wavelet Toolkit must be licensed on your system to be able to use this function. Syntax Result = WV_PLOT3D_WPS( Array [, X] [, Y] [, GROUP_LEADER=widget_id] [, SURFACE_STYLE=value] [, TITLE=string] [, UNITS=string] [, XTITLE=string] [, XUNITS=string] [, YTITLE=string] [, YUNITS=string] ) Return Value The returned variable is the Widget ID of the newly-created widget. Arguments Input Input must be either a string giving the name of a file to open, or a one- or twodimensional array of data. If set to a string, the file must contain a valid WV_PLOT3D_WPS “saved state.” X An optional vector of uniformly-spaced values giving the location of points along the first dimension of Input. The default is 0, 1, 2,..., NX–1, where NX is the size of the first dimension. This argument is ignored if Input is a filename. Y An optional vector of uniformly-spaced values giving the location of points along the second dimension of Input. The default is 0, 1, 2,..., NY–1, where NY is the size of the second dimension. This argument is ignored if Input is a filename. IDL Wavelet Toolkit WV_PLOT3D_WPS 102 Chapter 4: IDL Wavelet Toolkit Reference Keywords GROUP_LEADER The widget ID of an existing widget that serves as "group leader" for the newlycreated widget. When a group leader is killed, for any reason, all widgets in the group are also destroyed. A given widget can be in more than one group. The WIDGET_CONTROL procedure can be used to add additional group associations to a widget. See “WIDGET_CONTROL” (IDL Reference Guide) for more information. It is not possible to remove a widget from an existing group. Note The following keywords are ignored if Input is a filename. This includes the SURFACE_STYLE, TITLE, UNITS, XTITLE, XUNITS, YTITLE, and YUNITS keywords. SURFACE_STYLE Set this keyword to an integer specifying the initial style to use for the threedimensional surface. Valid values are: • 0 = Off • 1 = Points • 2 = Mesh • 3 = Shaded • 4 = XZ lines • 5 = YZ lines • 6 = Lego • 7 = Lego fill TITLE A scalar string giving the label to be used for the widget. The default is ‘WPS:’. UNITS A scalar string giving the units of Array. WV_PLOT3D_WPS IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 103 XTITLE A scalar string giving the label to be used for the first dimension. XUNITS A scalar string giving the units of X. YTITLE A scalar string giving the label to be used for the y-axis (for a 1D vector) or for the second dimension (for a 2D array). YUNITS A scalar string giving the units of Array (for a 1D vector) or the units of Y (for a 2D array). Widget Keywords Accepted The WV_PLOT3D_WPS function also accepts the following WIDGET_BASE keywords: DISPLAY_NAME, EVENT_FUNC, FRAME, KBRD_FOCUS_EVENTS, KILL_NOTIFY, MODAL, NOTIFY_REALIZE, RESOURCE_NAME, SCR_XSIZE, SCR_YSIZE, SPACE, TLB_FRAME_ATTR, TRACKING_EVENTS, UNITS, XOFFSET, XSIZE, YOFFSET, YSIZE. See “WIDGET_BASE” (IDL Reference Guide) for more information. Version History 5.3 Introduced See Also WV_APPLET IDL Wavelet Toolkit WV_PLOT3D_WPS 104 Chapter 4: IDL Wavelet Toolkit Reference WV_PLOT_MULTIRES The WV_PLOT_MULTIRES function runs the graphical user interface for multiresolution analysis. WV_PLOT_MULTIRES is accessible from the Visualize Menu of WV_APPLET. Note The IDL Wavelet Toolkit must be licensed on your system to be able to use this function. Syntax Result = WV_PLOT_MULTIRES( Array [, X] [, Y] [, GROUP_LEADER=widget_id] [, TITLE=string] [, UNITS=string] [, XTITLE=string] [, XUNITS=string] [, YTITLE=string] [, YUNITS=string]) Return Value The returned variable is the Widget ID of the newly-created widget. Arguments Array A one- or two-dimensional array of data to be analyzed. X An optional vector of uniformly-spaced values giving the location of points along the first dimension of Array. The default is 0, 1, 2,..., NX–1, where NX is the size of the first dimension. Y An optional vector of uniformly-spaced values giving the location of points along the second dimension of Array. The default is 0, 1, 2,..., NY–1, where NY is the size of the second dimension. WV_PLOT_MULTIRES IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 105 Keywords GROUP_LEADER The widget ID of an existing widget that serves as “group leader” for the newlycreated widget. When a group leader is killed, for any reason, all widgets in the group are also destroyed. A given widget can be in more than one group. The WIDGET_CONTROL procedure can be used to add additional group associations to a widget. See “WIDGET_CONTROL” (IDL Reference Guide) for more information. It is not possible to remove a widget from an existing group. TITLE A scalar string giving the label to be used for the widget. The default is ‘MRes:’. UNITS A scalar string giving the units of Array. XTITLE A scalar string giving the label to be used for the first dimension. XUNITS A scalar string giving the units of X. YTITLE A scalar string giving the label to be used for the y-axis (for a 1D vector) or for the second dimension (for a 2D array). YUNITS A scalar string giving the units of Array (for a 1D vector) or the units of Y (for a 2D array). Widget Keywords Accepted The WV_PLOT_MULTIRES function also accepts the following WIDGET_BASE keywords: DISPLAY_NAME, EVENT_FUNC, FRAME, KBRD_FOCUS_EVENTS, KILL_NOTIFY, MODAL, NOTIFY_REALIZE, RESOURCE_NAME, SCR_XSIZE, SCR_YSIZE, SPACE, TLB_FRAME_ATTR, IDL Wavelet Toolkit WV_PLOT_MULTIRES 106 Chapter 4: IDL Wavelet Toolkit Reference TRACKING_EVENTS, UNITS, XOFFSET, XSIZE, YOFFSET, YSIZE. See “WIDGET_BASE” (IDL Reference Guide) for more information. Version History 5.3 Introduced See Also WV_APPLET WV_PLOT_MULTIRES IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 107 WV_PWT The WV_PWT function returns the partial wavelet transform of the input vector A. The transform is done using a user-inputted wavelet filter. WV_PWT is called by WV_DWT. WV_PWT is based on the routine pwt described in section 13.10 of Numerical Recipes in C: The Art of Scientific Computing, 2nd ed. (Cambridge University Press), and is used by permission. Syntax Result = WV_PWT( A, Scaling, Wavelet, Ioff, Joff [, /DOUBLE] [, /INVERSE] ) Return Value The result is an output vector of the same length as A, containing one stage of the pyramidal algorithm (Mallat 1989). Arguments A The input vector. The length must be either less than four (4) or a power of two (2). Scaling A vector of scaling (father) coefficients, of length N. Wavelet A vector of wavelet (mother) coefficients, of length N. Ioff An integer that specifies the support offset for Scaling. To center the scaling function over each point in Array, set Ioff to –N/2+2. Joff An integer that specifies the support offset for Wavelet. To center the wavelet function over each point in Array, set Joff to –N/2+2. IDL Wavelet Toolkit WV_PWT 108 Chapter 4: IDL Wavelet Toolkit Reference Keywords DOUBLE Set this keyword to force the computation to be done in double-precision arithmetic. INVERSE If set, the inverse transform is computed. By default, the forward transform is computed. Method and Result Format The WV_PWT function computes the wavelet coefficients for one level of the pyramidal algorithm. For a one-dimensional vector with 16 elements, one level of the pyramid appears below: Array elements [ 0, 1, 2, 3, \ / \ / s0,d0 s1,d1 4, 5, \ / s2,d2 6, 7, \ / s3,d3 8, 9, 10, 11, 12, 13, 14, 15] \ / \ / \ / \ / s4,d4 s5,d5 s6,d6 s7,d7 where Si and Di are the scaling and wavelet coefficients and i represents the position. The wavelet coefficients are stored in Result in the following order: Result = [ s0, s1, s2, s3, s4, s5, s6, s7, d0, d1, d2, d3, d4, d5, d6, d7 ] Version History 5.3 Introduced See Also WV_DWT WV_PWT IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 109 WV_TOOL_DENOISE The WV_TOOL_DENOISE function runs the graphical user interface for wavelet filtering and denoising. WV_TOOL_DENOISE is accessible from the Tools Menu of WV_APPLET. Note The IDL Wavelet Toolkit must be licensed on your system to be able to use this function. Syntax Result = WV_TOOL_DENOISE( Array [, X] [, Y] [, GROUP_LEADER=widget_id] [, TITLE=string] [, UNITS=string] [, XTITLE=string] [, XUNITS=string] [, YTITLE=string] [, YUNITS=string]) Return Value The returned variable is the Widget ID of the newly-created widget. Arguments Array A one- or two-dimensional array of data to be analyzed. X An optional vector of uniformly-spaced values giving the location of points along the first dimension of Array. The default is 0, 1, 2,..., NX–1, where NX is the size of the first dimension. Y An optional vector of uniformly-spaced values giving the location of points along the second dimension of Array. The default is 0, 1, 2,..., NY–1, where NY is the size of the second dimension. IDL Wavelet Toolkit WV_TOOL_DENOISE 110 Chapter 4: IDL Wavelet Toolkit Reference Keywords GROUP_LEADER The widget ID of an existing widget that serves as "group leader" for the newlycreated widget. When a group leader is killed, for any reason, all widgets in the group are also destroyed. A given widget can be in more than one group. The WIDGET_CONTROL procedure can be used to add additional group associations to a widget. See “WIDGET_CONTROL” (IDL Reference Guide) for more information. It is not possible to remove a widget from an existing group. TITLE A scalar string giving the label to be used for the widget. The default is 'Denoise:'. UNITS A scalar string giving the units of Array. XTITLE A scalar string giving the label to be used for the first dimension. XUNITS A scalar string giving the units of X. YTITLE A scalar string giving the label to be used for the y-axis (for a 1D vector) or for the second dimension (for a 2D array). YUNITS A scalar string giving the units of Array (for a 1D vector) or the units of Y (for a 2D array). Widget Keywords Accepted The WV_TOOL_DENOISE function also accepts the following WIDGET_BASE keywords: DISPLAY_NAME, EVENT_FUNC, FRAME, KBRD_FOCUS_EVENTS, KILL_NOTIFY, MODAL, NOTIFY_REALIZE, RESOURCE_NAME, SCR_XSIZE, SCR_YSIZE, SPACE, TLB_FRAME_ATTR, WV_TOOL_DENOISE IDL Wavelet Toolkit Chapter 4: IDL Wavelet Toolkit Reference 111 TRACKING_EVENTS, UNITS, XOFFSET, XSIZE, YOFFSET, YSIZE. See “WIDGET_BASE” (IDL Reference Guide) for more information. Version History 5.3 Introduced See Also WV_APPLET, WV_DENOISE IDL Wavelet Toolkit WV_TOOL_DENOISE 112 WV_TOOL_DENOISE Chapter 4: IDL Wavelet Toolkit Reference IDL Wavelet Toolkit Index A adding Wavelet Toolkit tools, 45 confirm exit. See preferences continuous wavelet transform, 29, 48, 66 contours in wavelet power spectrum, 37 copyrights, 2 cumulative power plot, 43 B bandpass multiresolution plots, 39 C cascade plot. See multiresolution analysis coefficient power plot, 43 coiflet. See wavelet functions compact support, 29 compress save files. See preferences IDL Wavelet Toolkit D datasets mathematical expressions, 23 selecting variables, 24 variable information fields, 20 Daubechies. See wavelet functions default directory. See preferences denoising techniques coefficient power plot, 43 coefficient threshold, 43 113 114 color scaling, 42 cumulative power threshold, 43 denoise tool, 41 hard thresholding, 43, 51 MRI, 52 soft thresholding, 44, 52 theory, 51 wavelet coefficient method, 42 WV_DENOISE function, 69 WV_TOOL_DENOISE function, 109 detail multiresolution plots, 39 DIALOG_READ_IMAGE. See importing discrete wavelet transform, 29, 48, 74 drag quality, 34 in wavelet toolkit, 26 importing adding wavelet functions, 99 data from command line, 96 IDL command line data, 26 structure tags, 97 user-defined wavelet functions, 30 WAV audio files, 26 L legalities, 2 lego-style surface, 36 localization of wavelet functions, 48 low-pass multiresolution plots, 39 E e-folding time, 30 energy scaling, 35 G Gaussian See also wavelet functions. H Haar. See wavelet functions high-pass multiresolution plots, 39 I IDL Wavelet Toolkit main window, 12 menus, 14 status bar, 12 toolbar, 12 image compression. See denoising techniques images Index M Macintosh using mouse with wavelet toolkit, 37 Mallat. See pyramidal algorithm Marr wavelet See WV_FN_GAUSSIAN function mathematical expressions. See datasets Morlet. See wavelet functions MRI denoising technique, 52 multiresolution analysis, 104 about, 54 using, 39 N noise removal See also denoising techniques nonorthogonal wavelet functions, 29 O orthogonal wavelet functions, 29 IDL Wavelet Toolkit 115 P parameters passing to Wavelet Toolkit functions, 45 partial wavelet transform. See wavelet transform passing parameters, 45 Paul. See wavelet functions PCM format, 26 percent difference, 44 plotting multiresolution analysis, 39, 104 wavelet power spectrum, 32, 101 preferences compress save files, 18 confirm exit, 18 current directory selection, 18 default directory, 18 restoring defaults, 19 stride factor, 18 pyramidal algorithm result format, 75 returning, 107 importing wavelet data, 97 surfaces style, 36 symlet. See wavelet functions symmetry of wavelet functions, 29 T toolkit structure, 9 tools adding, 45 denoise function, 109 denoise tool, 41 user-defined, 16, 45 trademarks, 2 TrueColor (24-bit) images, 26 U user-defined tools, 45 V R regularity of wavelet functions, 30 remember current directory. See preferences RMS difference, 44 root-mean-square difference, 44 rough multiresolution plots, 39 S scaling functions, 28 starting wavelet toolkit, 12 statistical significance testing, 48 stride factor. See preferences structure tags IDL Wavelet Toolkit vanishing moments, 30 variable information wavelet dataset viewer, 20 variable selection. See datasets viewing wavelet functions, 28 W WAV audio files, 26 wavelet commands functions, 59 transform, 58 widgets, 58 wavelet functions coiflet, 78 Index 116 compact support, 29 Daubechies, 80 family, 64 Gaussian, 82 Haar, 85 Morlet, 87 nonorthogonal, 29 order, 64 orthogonal, 29 Paul, 90 regularity, 30 symlet, 93 symmetry, 29 user-defined, 30, 99 vanishing moments, 30 viewing, 28 wavelet power spectrum See also WV_PLOT3D_WPS function energy scaling, 35 plotting method, 49 rotation, translation, stretching, 37 theory, 49 viewer, 32 zero phase lines, 35 wavelet toolkit importing data, 25 status bar, 12 wavelet transform continuous, 29, 48, 66 discrete, 29, 48, 74 Index partial, 107 wavelet widget commands, 58 WV_APPLET procedure, 60 WV_CW_WAVELET function GET_VALUE, 64 reference, 62 SET_VALUE, 64 widget events generated, 64 WV_CWT function, 66 WV_DENOISE function, 69 WV_DWT function, 74 WV_FN_COIFLET function, 78 WV_FN_DAUBECHIES function, 80 WV_FN_GAUSSIAN function, 82 WV_FN_HAAR function, 85 WV_FN_MORLET function, 87 WV_FN_PAUL function, 90 WV_FN_SYMLET function, 93 WV_IMPORT_DATA procedure, 96 WV_IMPORT_WAVELET procedure, 99 WV_PLOT_MULTIRES function, 104 WV_PLOT3D_WPS function, 101 WV_PWT function, 107 WV_TOOL_DENOISE function, 109 Z zero phase lines, 35 IDL Wavelet Toolkit

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement