Creating a Filter bank?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I need help with creating a filter bank. Here's some ideas on how my code goes:
% Filter Bank
% Filter parameters are a, b, c, and d
c = [0 1];
for a = 1:5 % 5 different a's
for b = 1:5 % 5 different b's
for d = 1:5 % 5 different d's
filter_bank{a,b,c,d} = filter_function(a,b,c(1),d)+ ...
1i * filter_function(a,b,c(2),d)
end
end
end
It gives me this error: ??? The right hand side of this assignment has too few values to satisfy the left hand side.
Any help is appreciated. Thanks!
Edit1: I think I'll just put down the actual codes here. It's the Gabor Filter function posted on MATLAB Central: File Exchange. I don't know how to properly cite the author's work, so please advise too!
% Copyright (c) 2009, Gao Yang
% All rights reserved
% Gabor Filter parameters
lambda = 8;
theta = 0;
psi = [0 pi/2];
gamma = 0.5;
bw = 1;
N = 8;
for n = 1:N
gb = gabor_fn(bw,gamma,psi(1),lambda,theta)+ 1i * ...
gabor_fn(bw,gamma,psi(2),lambda,theta); % gb is the n-th gabor filter
% Then the filtering goes here
end
Here is the function gabor_fn.
function gb=gabor_fn(bw,gamma,psi,lambda,theta)
% bw = bandwidth, (1)
% gamma = aspect ratio, (0.5)
% psi = phase shift, (0)
% lambda= wave length, (>=2)
% theta = angle in rad, [0 pi)
sigma = lambda/pi*sqrt(log(2)/2)*(2^bw+1)/(2^bw-1);
sigma_x = sigma;
sigma_y = sigma/gamma;
sz=fix(8*max(sigma_y,sigma_x));
if mod(sz,2)==0, sz=sz+1;end
% alternatively, use a fixed size
% sz = 60;
[x y]=meshgrid(-fix(sz/2):fix(sz/2),fix(sz/2):-1:fix(-sz/2));
% x (right +)
% y (up +)
% Rotation
x_theta=x*cos(theta)+y*sin(theta);
y_theta=-x*sin(theta)+y*cos(theta);
gb=exp(-0.5*(x_theta.^2/sigma_x^2+y_theta.^2/sigma_y^2)).*cos(2*pi/lambda*x_theta+psi);
Edit2: Here's what I tried.
for bw = 1:1:8 % total: 8
for gamma = 0.5:0.5:3 % total: 6
for lambda = 1:1:10 % total 10
for theta = 0:pi/6:pi % total: 7
gf_bank{bw,gamma,lambda,theta} = gabor_fn(bw,gamma,psi(1),lambda,theta) + 1i * gabor_fn(bw,gamma,psi(2),lambda,theta);
end
end
end
end
5 comentarios
Walter Roberson
el 30 de Jun. de 2011
Legally speaking, "all rights reserved" includes prohibiting others from making "derivative works". Look, however, at the download page for that file: a few years ago Mathworks changed their rules to insist that any contributions be under one of the open-source licenses. If the contribution does not predate that change-over, then the open-source license would have been mentioned in the download page and you can use that license.
Respuesta aceptada
Walter Roberson
el 28 de Jun. de 2011
c is a constant array with more than one element, so subscript {a,b,c,d} designates more than one location, but the right hand side only generates a single value.
Warning: using a subscript of 0 is going to lead you to grief...
11 comentarios
Walter Roberson
el 30 de Jun. de 2011
gammavals = 0.5:0.5:3;
thetavals = 0:pi/6:pi;
for bw = 1:1:8 % total: 8
for gammaidx = 1:length(gammavals)
for lambda = 1:1:10 % total 10
for thetaidx = 1:length(thetavals)
gf_bank{bw,gammaidx,lambda,thetaidx} = gabor_fn(bw,gammavals(gammaidx),psi(1),lambda,thetavals(thetaidx)) + 1i * gabor_fn(bw,gammavals(gammaidx),psi(2),lambda,thetavals(thetaidx));
end
end
end
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Filter Banks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!