⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.html

📁 信号处理系列导航
💻 HTML
字号:
<!DOCTYPE html  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"><html xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">   <head>      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">         <!--This HTML is auto-generated from an M-file.To make changes, update the M-file and republish this document.      -->      <title>Image Approximation with Wavelets</title>      <meta name="generator" content="MATLAB 7.4">      <meta name="date" content="2008-10-15">      <meta name="m-file" content="index">      <LINK REL="stylesheet" HREF="style.css" TYPE="text/css">   </head>   <body>      <div class="content">         <h1>Image Approximation with Wavelets</h1>         <introduction>            <p>This numerical tour uses wavelets to perform both linear and non-linear image approximation.</p>         </introduction>         <h2>Contents</h2>         <div>            <ul>               <li><a href="#1">Installing toolboxes and setting up the path.</a></li>               <li><a href="#8">Wavelet transform of an image.</a></li>               <li><a href="#14">Linear Wavelet Approximation</a></li>               <li><a href="#17">Non-linear Approximation</a></li>            </ul>         </div>         <h2>Installing toolboxes and setting up the path.<a name="1"></a></h2>         <p>You need to download the <a href="../toolbox_general.zip">general purpose toolbox</a> and the <a href="../toolbox_signal.zip">signal toolbox</a>.         </p>         <p>You need to unzip these toolboxes in your working directory, so that you have <tt>toolbox_general/</tt> and <tt>toolbox_signal/</tt> in your directory.         </p>         <p><b>For Scilab user:</b> you must replace the Matlab comment '%' by its Scilab counterpart '//'.         </p>         <p><b>Recommandation:</b> You should create a text file named for instance <tt>numericaltour.sce</tt> (in Scilabe) or <tt>numericaltour.m</tt> to write all the Scilab/Matlab command you want to execute. Then, simply run <tt>exec('numericaltour.sce');</tt> (in Scilab) or <tt>numericaltour;</tt> (in Matlab) to run the commands.         </p>         <p>Execute this line only if you are using Matlab.</p><pre class="codeinput">getd = @(p)path(path,p); <span class="comment">% scilab users must *not* execute this</span></pre><p>Then you can add these toolboxes to the path.</p><pre class="codeinput"><span class="comment">% Add some directories to the path</span>getd(<span class="string">'toolbox_signal/'</span>);getd(<span class="string">'toolbox_general/'</span>);</pre><h2>Wavelet transform of an image.<a name="8"></a></h2>         <p>First we load an image.</p><pre class="codeinput">n = 256;M = load_image(<span class="string">'lena'</span>, []);M = rescale(crop(M,n));</pre><p>You can perform a wavelet transform, which corresponds to a 7/9 biorthogonal wavelet transform.</p><pre class="codeinput">Jmin = 4;MW = perform_wavelet_transf(M,Jmin,+1);</pre><p><i>Exercice 1:</i> (the solution is <a href="../private/wavelet_approximation/exo1.m">exo1.m</a>) Display the wavelet transform of the image. Display also the residual low frequencies (size <tt>2^Jmin x 2^Jmin</tt>. Can you recognize the layout of the coefficients through the scales and orientations ?         </p><pre class="codeinput">exo1;</pre><img vspace="5" hspace="5" src="index_01.png"> <p>To better see the distribution of the coefficients, it is possible to enhance the contrast of each wavelet orientation and            wavelet scale.         </p><pre class="codeinput">clf;plot_wavelet(MW,Jmin);</pre><img vspace="5" hspace="5" src="index_02.png"> <p><i>Exercice 2:</i> (the solution is <a href="../private/wavelet_approximation/exo2.m">exo2.m</a>) A separable wavelet transform is obtained by applying a 1D wavelet transform to each columnes and then each row of the image.            Compute the transformed coefficients <tt>MWsep</tt> of <tt>M</tt>. Display the resulting set of coefficients. Use the function <tt>plot_wavelet</tt> with an options field <tt>options.separable=1</tt> to display the coefficients.         </p><pre class="codeinput">exo2;</pre><img vspace="5" hspace="5" src="index_03.png"> <h2>Linear Wavelet Approximation<a name="14"></a></h2>         <p>Linear approximation is performed by setting to zero the fine scale wawelets coefficients and then performing the inverse            wavelet transform.         </p><pre class="codeinput">eta = 4;MWlin = zeros(n,n);MWlin(1:n/eta,1:n/eta) = MW(1:n/eta,1:n/eta);Mlin = perform_wavelet_transf(MWlin,Jmin,-1);</pre><p>You can compare the original image with the linear approximation, and compute the approximation error.</p><pre class="codeinput">elin = snr(M,Mlin);clf;imageplot(M, <span class="string">'Original'</span>, 1,2,1);imageplot(Mlin, strcat([<span class="string">'Linear, SNR='</span> num2str(elin)]), 1,2,2);</pre><img vspace="5" hspace="5" src="index_04.png"> <h2>Non-linear Approximation<a name="17"></a></h2>         <p>Non-linear approximation is obtained by keeping only the largest coefficients of the signal.</p>         <p><i>Exercice 3:</i> (the solution is <a href="../private/wavelet_approximation/exo3.m">exo3.m</a>) Compute a set of wavelet coefficients <tt>MWnlin</tt> that has the same number of non-zero coefficients as <tt>MWlin</tt>, but that is optimal for non-linear approximation.         </p><pre class="codeinput">exo3;</pre><p><i>Exercice 4:</i> (the solution is <a href="../private/wavelet_approximation/exo4.m">exo4.m</a>) Display linear and non-linear approximations alltogether and do a visual comparison. Compute the SNR of the two approximations.         </p><pre class="codeinput">exo4;</pre><img vspace="5" hspace="5" src="index_05.png"> <p><i>Exercice 5:</i> (the solution is <a href="../private/wavelet_approximation/exo5.m">exo5.m</a>) Display the curve of the approximation error with respect of the number of coefficients. Hint for exercice 5: use the conservation            of the energy (the transform is orthogonal - or very close to orthogonal for the 7/9 biorthogonal transform). You can display            the error in log scale. To better see the difference, you need to do the computation on a full size (256 x 256) image. You            need to plot the approximation for a number of pixels <tt>M/n^2</tt> in the range <tt>[10^-3, 10^-1]</tt> typically.         </p><pre class="codeinput">exo5;</pre><img vspace="5" hspace="5" src="index_06.png"> <p><i>Exercice 6:</i> (the solution is <a href="../private/wavelet_approximation/exo6.m">exo6.m</a>) Display the approximation curve for another, less regular, image (for instance <tt>mandrill</tt>). Compare with the <tt>boat</tt> image.         </p><pre class="codeinput">exo6;</pre><img vspace="5" hspace="5" src="index_07.png"> <p><i>Exercice 7:</i> (the solution is <a href="../private/wavelet_approximation/exo7.m">exo7.m</a>) Compare visually and in term of SNR the non-linear approximation in an isotropic (3 orientation) wavelet basis, in a separable            wavelet basis.         </p><pre class="codeinput">exo7;</pre><img vspace="5" hspace="5" src="index_08.png"> <p><i>Exercice 8:</i> (the solution is <a href="../private/wavelet_approximation/exo8.m">exo8.m</a>) Display the approximation curves for isotropic wavelets, separable wavelets and in a Fourier basis (using function <tt>fft2</tt>).         </p><pre class="codeinput">exo8;</pre><img vspace="5" hspace="5" src="index_09.png"> <p class="footer"><br>            Copyright  &reg; 2008 Gabriel Peyre<br></p>      </div>      <!--##### SOURCE BEGIN #####%% Image Approximation with Wavelets% This numerical tour uses wavelets to perform both linear and non-linear% image approximation.%% Installing toolboxes and setting up the path.%%% You need to download the % <../toolbox_general.zip general purpose toolbox>% and the <../toolbox_signal.zip signal toolbox>.%%% You need to unzip these toolboxes in your working directory, so% that you have |toolbox_general/| and |toolbox_signal/| in your directory.%%% *For Scilab user:* you must replace the Matlab comment '%' by its Scilab% counterpart '//'.%%% *Recommandation:* You should create a text file named for instance% |numericaltour.sce| (in Scilabe) or |numericaltour.m| to write all the% Scilab/Matlab command you want to execute. Then, simply run% |exec('numericaltour.sce');| (in Scilab) or |numericaltour;| (in Matlab)% to run the commands. %%% Execute this line only if you are using Matlab.getd = @(p)path(path,p); % scilab users must *not* execute this%%% Then you can add these toolboxes to the path.% Add some directories to the pathgetd('toolbox_signal/');getd('toolbox_general/');%% Wavelet transform of an image.%%% First we load an image.n = 256;M = load_image('lena', []);M = rescale(crop(M,n));%%% You can perform a wavelet transform, which corresponds to a 7/9 biorthogonal wavelet transform.Jmin = 4;MW = perform_wavelet_transf(M,Jmin,+1);%%% _Exercice 1:_ (the solution is <../private/wavelet_approximation/exo1.m exo1.m>)% Display the wavelet transform of the image. Display also the residual low% frequencies (size |2^Jmin x 2^Jmin|.% Can you recognize the layout of the coefficients through the scales and% orientations ?exo1;%%% To better see the distribution of the coefficients, it is possible to enhance % the contrast of each wavelet orientation% and wavelet scale.clf;plot_wavelet(MW,Jmin);%%% _Exercice 2:_ (the solution is <../private/wavelet_approximation/exo2.m exo2.m>)% A separable wavelet transform is obtained by applying a 1D wavelet% transform to each columnes and then each row of the image. Compute the% transformed coefficients |MWsep| of |M|.% Display the% resulting set of coefficients. Use the function |plot_wavelet| with an% options field |options.separable=1| to display the coefficients.exo2;%% Linear Wavelet Approximation%%% Linear approximation is performed by setting to zero the fine scale wawelets coefficients% and then performing the inverse wavelet transform.eta = 4;MWlin = zeros(n,n);MWlin(1:n/eta,1:n/eta) = MW(1:n/eta,1:n/eta);Mlin = perform_wavelet_transf(MWlin,Jmin,-1);%%% You can compare the original image with the linear approximation, and compute the approximation error.elin = snr(M,Mlin);clf;imageplot(M, 'Original', 1,2,1); imageplot(Mlin, strcat(['Linear, SNR=' num2str(elin)]), 1,2,2);%% Non-linear Approximation%%% Non-linear approximation is obtained by keeping only the largest coefficients of the signal.%%% _Exercice 3:_ (the solution is <../private/wavelet_approximation/exo3.m exo3.m>)% Compute a set of wavelet coefficients |MWnlin| that has the same number of non-zero coefficients% as |MWlin|, but that is optimal for non-linear approximation.exo3;%%% _Exercice 4:_ (the solution is <../private/wavelet_approximation/exo4.m exo4.m>)% Display linear and non-linear approximations alltogether and do a visual comparison.% Compute the SNR of the two approximations.exo4;%%% _Exercice 5:_ (the solution is <../private/wavelet_approximation/exo5.m exo5.m>)% Display the curve of the approximation error with respect of the number of coefficients.% Hint for exercice 5: use the conservation of the energy (the transform is orthogonal - or very close to orthogonal for the % 7/9 biorthogonal transform). You can display the error in log scale. To% better see the difference, you need to do the computation on a full size% (256 x 256) image. You need to plot the approximation for a number of% pixels |M/n^2| in the range |[10^-3, 10^-1]| typically.exo5;%%% _Exercice 6:_ (the solution is <../private/wavelet_approximation/exo6.m exo6.m>)% Display the approximation curve for another, less regular,% image (for instance |mandrill|). Compare with the |boat| image.exo6;%%% _Exercice 7:_ (the solution is <../private/wavelet_approximation/exo7.m exo7.m>)% Compare visually and in term of SNR the non-linear approximation in an% isotropic (3 orientation) wavelet basis, in a separable wavelet basis.exo7;%%% _Exercice 8:_ (the solution is <../private/wavelet_approximation/exo8.m exo8.m>)% Display the approximation curves for isotropic wavelets, separable% wavelets and in a Fourier basis (using function |fft2|).exo8;##### SOURCE END #####-->   </body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -