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

📄 gfcreatefilterf2.html

📁 外国人写matlab 的gobor特征运算工具箱
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"                "http://www.w3.org/TR/REC-html40/loose.dtd"><html><head>  <title>Description of gfcreatefilterf2</title>  <meta name="keywords" content="gfcreatefilterf2">  <meta name="description" content="GFCREATEFILTERF2 Create normalized 2-D Gabor filter in the frequency domain.">  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">  <meta name="robots" content="index, follow">  <link type="text/css" rel="stylesheet" href="../m2html.css"></head><body><a name="_top"></a><div><a href="../index.html">Home</a> &gt;  <a href="index.html">gabortb-v0.4.1</a> &gt; gfcreatefilterf2.m</div><!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td><td align="right"><a href="index.html">Index for gabortb-v0.4.1&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>--><h1>gfcreatefilterf2</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>GFCREATEFILTERF2 Create normalized 2-D Gabor filter in the frequency domain.</strong></div><h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>function [g]=gfcreatefilterf2(f0, theta, gamma, eta, N,varargin) </strong></div><h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre class="comment">GFCREATEFILTERF2 Create normalized 2-D Gabor filter in the frequency domain.   [G] = GFCREATEFILTERF2(F0,THETA,GAMMA,ETA,N,...) creates a   two-dimensional normalized Gabor filter G with central   frequency F0, orientation THETA, normalized width GAMMA along   the wave orientation, normalized width ETA orthogonal to wave   orientation,  and size N. Also, a two element vector N = [NX   NY] can be used to specify the size.   G = GFCREATEFILTERF2(...,'PF',PF) determines that at least   P percent of the Gaussian envelope of the filter must be   included in the filter in frequency domain. For default,   PF=0.998.    G = GFCREATEFILTERF2(...,'PT',PT) determines that at least   P percent of the Gaussian envelope of the filter must be   included in the filter in spatial domain. For default,   PT=0.998.    Examples   See also <a href="gfcreatefilter2.html" class="code" title="function [g]=gfcreatefilter2(f0,theta,gamma,eta,n,varargin)">GFCREATEFILTER2</a>, <a href="gfcheckfilter2.html" class="code" title="function gfcheckfilter2(f0,theta,gamma,eta,n,pt,pf)">GFCHECKFILTER2</a>, <a href="gfcreatefilterf.html" class="code" title="function [g]=gfcreatefilterf(f0,gamma,N,varargin)">GFCREATEFILTERF</a>. References:   [1] Kamarainen, J.-K., Kyrki, V., Kalviainen, H., Gabor       Features for Invariant Object Recognition, Research       report 79, Department of Information Technology,       Lappeenranta University of Technology Author(s):    Joni Kamarainen &lt;Joni.Kamarainen@lut.fi&gt;    Ville Kyrki &lt;Ville.Kyrki@lut.fi&gt; Copyright:   The Gabor Features in Signal and Image Processing Toolbox is   Copyright (C) 2000 by Joni Kamarainen and Ville Kyrki.   $Name:  $ $Revision: 1.6 $  $Date: 2003-02-23 16:27:44 $</pre></div><!-- crossreference --><h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>This function calls:<ul style="list-style-image:url(../matlabicon.gif)"><li><a href="gfcheckfilter2.html" class="code" title="function gfcheckfilter2(f0,theta,gamma,eta,n,pt,pf)">gfcheckfilter2</a>	GFCHECKFILTER2 Check 2-d filter parameters.</li></ul>This function is called by:<ul style="list-style-image:url(../matlabicon.gif)"><li><a href="gfcreateinformationdiagram2.html" class="code" title="function [resps,freqs,orients] = gfcreateinformationdiagram2(img_, f0_,theta_, gamma_,eta_, varargin);">gfcreateinformationdiagram2</a>	GFCREATEINFORMATIONDIAGRAM2 Information diagram of 2-D signal</li><li><a href="gfdemo02.html" class="code" title="function [] = gfdemo02;">gfdemo02</a>	GFDEMO02 Demonstrate 2-D Gabor functionality</li></ul><!-- crossreference --><h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre>0001 <span class="comment">%GFCREATEFILTERF2 Create normalized 2-D Gabor filter in the frequency domain.</span>0002 <span class="comment">%</span>0003 <span class="comment">%   [G] = GFCREATEFILTERF2(F0,THETA,GAMMA,ETA,N,...) creates a</span>0004 <span class="comment">%   two-dimensional normalized Gabor filter G with central</span>0005 <span class="comment">%   frequency F0, orientation THETA, normalized width GAMMA along</span>0006 <span class="comment">%   the wave orientation, normalized width ETA orthogonal to wave</span>0007 <span class="comment">%   orientation,  and size N. Also, a two element vector N = [NX</span>0008 <span class="comment">%   NY] can be used to specify the size.</span>0009 <span class="comment">%</span>0010 <span class="comment">%   G = GFCREATEFILTERF2(...,'PF',PF) determines that at least</span>0011 <span class="comment">%   P percent of the Gaussian envelope of the filter must be</span>0012 <span class="comment">%   included in the filter in frequency domain. For default,</span>0013 <span class="comment">%   PF=0.998.</span>0014 <span class="comment">%</span>0015 <span class="comment">%   G = GFCREATEFILTERF2(...,'PT',PT) determines that at least</span>0016 <span class="comment">%   P percent of the Gaussian envelope of the filter must be</span>0017 <span class="comment">%   included in the filter in spatial domain. For default,</span>0018 <span class="comment">%   PT=0.998.</span>0019 <span class="comment">%</span>0020 <span class="comment">%   Examples</span>0021 <span class="comment">%</span>0022 <span class="comment">%   See also GFCREATEFILTER2, GFCHECKFILTER2, GFCREATEFILTERF.</span>0023 <span class="comment">%</span>0024 <span class="comment">% References:</span>0025 <span class="comment">%   [1] Kamarainen, J.-K., Kyrki, V., Kalviainen, H., Gabor</span>0026 <span class="comment">%       Features for Invariant Object Recognition, Research</span>0027 <span class="comment">%       report 79, Department of Information Technology,</span>0028 <span class="comment">%       Lappeenranta University of Technology</span>0029 <span class="comment">%</span>0030 <span class="comment">% Author(s):</span>0031 <span class="comment">%    Joni Kamarainen &lt;Joni.Kamarainen@lut.fi&gt;</span>0032 <span class="comment">%    Ville Kyrki &lt;Ville.Kyrki@lut.fi&gt;</span>0033 <span class="comment">%</span>0034 <span class="comment">% Copyright:</span>0035 <span class="comment">%</span>0036 <span class="comment">%   The Gabor Features in Signal and Image Processing Toolbox is</span>0037 <span class="comment">%   Copyright (C) 2000 by Joni Kamarainen and Ville Kyrki.</span>0038 <span class="comment">%</span>0039 <span class="comment">%</span>0040 <span class="comment">%   $Name:  $ $Revision: 1.6 $  $Date: 2003-02-23 16:27:44 $</span>0041 <span class="comment">%</span>0042 <a name="_sub0" href="#_subfunctions" class="code">function [g]=gfcreatefilterf2(f0, theta, gamma, eta, N,varargin)</a>0043 0044 <span class="comment">%</span>0045 <span class="comment">% Setting default values</span>0046 alpha = f0/gamma;0047 beta = f0/eta;0048 PT = 0.998;0049 PF = 0.998;0050 0051 <span class="comment">%</span>0052 <span class="comment">% Parameter parsing</span>0053 <span class="keyword">if</span> mod(length(varargin),2)&gt;0,0054   error(<span class="string">'Each parameter must be given a value.'</span>);0055 <span class="keyword">end</span>;0056 0057 currentarg = 1;0058 <span class="keyword">while</span> (length(varargin) &gt; currentarg)0059   [param,value]=deal(varargin{currentarg:currentarg+1});0060   <span class="keyword">switch</span> lower(param)0061    <span class="keyword">case</span> <span class="string">'pt'</span>0062     PT = value;0063    <span class="keyword">case</span> <span class="string">'pf'</span>0064     PF = value;0065    <span class="keyword">otherwise</span>0066     error([<span class="string">'Unknown parameter '''</span> param <span class="string">'''.'</span>]);0067   <span class="keyword">end</span>;0068   currentarg=currentarg+2;0069 <span class="keyword">end</span>;0070 0071 <span class="comment">% filter size</span>0072 <span class="keyword">if</span> length(N)&gt;1,0073   Nx=N(1);0074   Ny=N(2);0075 <span class="keyword">else</span>0076   Nx=N;0077   Ny=N;0078 <span class="keyword">end</span>;0079 0080 <span class="comment">% Check filter constraints</span>0081 <a href="gfcheckfilter2.html" class="code" title="function gfcheckfilter2(f0,theta,gamma,eta,n,pt,pf)">gfcheckfilter2</a>(f0,theta,gamma,eta,N,PT,PF);0082 0083 <span class="comment">% Check if save file exists and load it</span>0084 <span class="keyword">if</span> (isunix)0085      [status userName] = unix(<span class="string">'whoami'</span>);0086      <span class="keyword">if</span> (size(userName,2) &gt; 1)0087         useTempFiles = 1;0088         userName = userName(1,1:end-1);<span class="comment">% remove line change</span>0089         temporarySaveFileName = <span class="keyword">...</span>0090           fullfile(tempdir,[<span class="string">'gf-'</span> userName <span class="string">'-'</span> <span class="keyword">...</span>0091                   num2str(f0)  <span class="string">'-'</span> num2str(theta) <span class="keyword">...</span>0092                   <span class="string">'-'</span> num2str(gamma) <span class="string">'-'</span> num2str(eta) <span class="string">'-'</span> num2str(Nx) <span class="keyword">...</span>0093                   <span class="string">'-'</span> num2str(Ny) <span class="string">'-'</span> num2str(PT) <span class="string">'-'</span> num2str(PF) <span class="string">'.mat'</span>]);0094      <span class="keyword">else</span>0095     useTempFiles = 0;0096      <span class="keyword">end</span>;0097 <span class="keyword">else</span>0098      [status userName] = unix(<span class="string">'echo %USERNAME%'</span>);0099      <span class="keyword">if</span> (size(userName,2) &gt; 1)0100         useTempFiles = 1;0101         userName = userName(1,1:end-1);<span class="comment">% remove line change</span>0102         temporarySaveFileName = <span class="keyword">...</span>0103           fullfile(tempdir,[<span class="string">'gf-'</span> userName <span class="string">'-'</span> <span class="keyword">...</span>0104                   num2str(f0)  <span class="string">'-'</span> num2str(theta) <span class="keyword">...</span>0105                   <span class="string">'-'</span> num2str(gamma) <span class="string">'-'</span> num2str(eta) <span class="string">'-'</span> num2str(Nx) <span class="keyword">...</span>0106                   <span class="string">'-'</span> num2str(Ny) <span class="string">'-'</span> num2str(PT) <span class="string">'-'</span> num2str(PF) <span class="string">'.mat'</span>])0107      <span class="keyword">else</span>0108     useTempFiles = 0;0109      <span class="keyword">end</span>;0110 <span class="keyword">end</span>;0111 0112 <span class="comment">% THIS WAS OLD WAY BUT IT DIDNT WORK IN WINDOWS AND SUFFERED USMASKS BETWEEN</span>0113 <span class="comment">% DIFFERENT USERS IN THE SAME SYSTEM</span>0114 <span class="comment">%temporarySaveFileName = fullfile</span>0115 <span class="comment">%temporarySaveFileName = ['/tmp/gffilter-' num2str(f0)  '-' num2str(theta) ...</span>0116 <span class="comment">%            '-' num2str(gamma) '-' num2str(eta) '-' num2str(Nx) ...</span>0117 <span class="comment">%            '-' num2str(Ny) '-' num2str(PT) '-' num2str(PF) '.mat']</span>0118 0119 <span class="keyword">if</span> (useTempFiles==1 &amp; exist(temporarySaveFileName) == 2)0120   load(temporarySaveFileName);0121 <span class="keyword">else</span>0122     g = zeros(Ny,Nx);0123   0124   <span class="comment">% SOLUTION 1: easy to understand, but may need whole lotta memory</span>0125   nx = -Nx:1:Nx;0126   ny = -Ny:1:Ny;0127   u = nx/Nx; <span class="comment">% frequencies that bank contains</span>0128   v = ny/Ny;0129   [U,V]=meshgrid(u,v);0130   gf = exp(-pi^2*( (U*sin(theta)-V*cos(theta)).^2/beta^2 + <span class="keyword">...</span>0131            (U*cos(theta)+V*sin(theta)-f0).^2/alpha^2 ));0132   0133   <span class="comment">% Calculating the filter using aliasing</span>0134   g = g+gf(1:Ny,1:Nx); <span class="comment">% A_1</span>0135   g = g+gf(1:Ny,(Nx+1):(2*Nx)); <span class="comment">% A_2</span>0136   g = g+gf((Ny+1):(2*Ny),1:Nx); <span class="comment">% A_3</span>0137   g = g+gf((Ny+1):(2*Ny),(Nx+1):(2*Nx)); <span class="comment">% A_4</span>0138   0139   <span class="keyword">if</span> (useTempFiles) <span class="comment">% save this filter</span>0140     save(temporarySaveFileName, <span class="string">'g'</span>);0141   <span class="keyword">end</span>;0142 <span class="keyword">end</span>;0143   0144 0145   0146   0147 0148 0149 0150 0151</pre></div><hr><address>Generated on Fri 23-Nov-2007 14:52:42 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address></body></html>

⌨️ 快捷键说明

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