2014-02-19 263 views
2

我正在使用現在包含Matching Pursuit算法的MATLAB 2013。 它有一個功能叫wmpdictionary創建一個字典。據我所知,能夠使用下一個函數來創建在字典中的原子:MATLAB匹配使用Gabor或自定義原子的追蹤wmpdictionary

  • 離散餘弦變換-II基礎
  • 正弦
  • 餘弦
  • 多項式
  • 移位的Kronecker符號
  • 一個有效的正交或雙正交小波族

我想/需要使用Gabor原子。

有人知道如何在wmpdictionary中使用Gabor或者定製新種類的原子嗎?

------------------最終解決------------------ 那麼我找到了一個公式Gabor原子在紙上[1]。 我生成使用這些函數的字典:

function atom = getGaborAtom(N,scale,timeShift,frequency,phase) 
%This function obtains a Gabor atom of given parameters 
%N- Length of the signal 
%scale- must be in number of samples 
%timeShift - must be in number of samples 
%frequency - its normalized frequency from 0 to 0.5 f/fs; 
%Phase - a value from 0 to 2 pi 
%This version uses the number of samples but seconds can also be used. 

atom =zeros(N,1); 
for n=1:N 
    atom(n,1) = (1/sqrt(scale))*exp(-pi*(n-timeShift)^2/scale^2) * cos(2*pi*frequency* (n-timeShift)+phase); 
end 
atom = (1/norm(atom)) .* atom; %Normalization 
end 

function [dictionary parameters]=constructDictionaryGabor() 
%Construct a Gabor dictionary 
%parameters are scale timeshift and frequency 

N=256; %Size of the atom 
scales = [2^1 2^2 2^3 2^4]; %More scales can be added 
freqs = [0 .001 .002 .05 .1 .2 .3 .4 .5]; % f/fs normalized frequency. More freqs can be added 
timeShifts = [0 64 128]; %More time shifts can be added 
phase =0; %More phase values can be added, here I'm fixinf phase to 0 


dictionary = zeros(N,length(scales)*length(freqs)*length(timeShifts)*length(phase)); 
parameters = zeros(3,length(scales)*length(freqs)*length(timeShifts)*length(phase); 
contador = 1; 

for t=1:length(timeShifts) 
    for f=1:length(freqs) 
     for s=1:length(scales) 
      dictionary(:,contador) = getGaborAtom(N,scales(s),timeShifts(t),freqs(f),phase); 
      parameters(:,contador) = [scales(s) timeShifts(t) freqs(f)]; 
      contador = contador+1; 
     end 
    end 
end 
end 

該字典可以用函數wmpdictionary使用,基質parameteres具有每每個原子的參數。

[1]環境聲音識別隨着時間頻率的音頻特性

回答

2

你應該下載並安裝MPTK,這個工具包有幾個特點,比wmpalg更快。您還可以進行多渠道分解並輕鬆定義您自己的字典。

-1

你必須改變這一行

atom(n,1) = (1/sqrt(scale))*exp(-pi*(n-timeShift)^2/scale^2) * cos(2*pi*frequency* (n-timeShift)+phase); 

atom(n,1) = (1/sqrt(scale))*exp(-pi*(n-timeShift)^2/scale^2) * cos(2*pi*frequency* (n-timeShift)/N+phase);