%% Haar Transform 2D % David Ruch and Patrick J. Van Fleet % Minicourse #4, January 2008 Joint Mathematics Meetings % San Diego, CA %% Objective % In this m-file, we will explore the two-dimensional discrete Haar % wavelet transform. %% Conventions % This m-file uses the DiscreteWavelets Toolbox. Help is available on all % functions in the toolbox by accessing the Help menu and clicking on the % DiscreteWavelets Toolbox. % % Demos are also available. Click the Demos tab under Help to access all % demos. %% Available Images % The DiscreteWavelets packages comes with 18 grayscale images. You can % see information about these images (name, size, etc.) by issuing the % command ImageList. ImageList('ImageType','GrayScale'); %% % You can also get a look at these images by using the command % ShowThumbnails. ShowThumbnails('ImageType','GrayScale'); %% % No matter where you installed the DiscreteWavelets package on your % computer, you can retrieve the absolute path and file name for each % included image. The command ImageNames produces a list of file names. gray = ImageNames('ImageType','GrayScale'); disp(gray{1}); %% Loading and Plotting Images % Once you have the list of file names, it is very easy to load and plot % images. Let's load the first image in the list. A = ImageRead(gray{1}); close; ImagePlot(A); %% Using HWT2D % In the cell below, we compute and plot the two-dimensional HWT of image % A. We compute the transform of N[A] to speed up the computation. B = HWT2D(A,1); close; WaveletDensityPlot(B,1,'DivideLinesThickness',2); %% Using IHWT2D % In the cell below, we compute the inverse transform of the image. B = HWT2D(A,1); WaveletDensityPlot(B,1,'DivideLinesThickness',2) origA = IHWT2D(B,1); figure; ImagePlot(origA); %% Iterating the Process % Just as with the one-dimensional HWT, we can iterate the two-dimensional % HWT. In this case, the HWT2D is applied the approximation (blur) % portion of the transform. % % Warning: Make sure to know the maximum amount of iterations you can % compute before proceeding!! You can use ImageList to display the % maximum number of iterations that can be performed on each of the % included images. ImageList('ImageType','GrayScale'); %% % Here we compute four iterations of the Haar wavelet transformation. its = 4; B = HWT2D(A, its); close; WaveletDensityPlot(B,its,'DivideLinesThickness',[2 2 2 2]); %% % You can plot various portions of the transform. Here is the vertical % portion of the third iteration. WaveletDensityPlot(B,its,'Iteration',3,'Region','Vertical'); %% % Here is the horizontal portion of the first iteration. close; WaveletDensityPlot(B,its,'Iteration',1,'Region','Horizontal'); %% % Here is the blur. close; WaveletDensityPlot(B,its,'Region','Blur'); %% % We can "blow up" the blur. close; WaveletDensityPlot(B,its,'Region','Blur','Magnification',8) %% close all; displayEndOfDemoMessage(mfilename)