Creating a Filter bank?

조회 수: 14 (최근 30일)
Jason
Jason 2011년 6월 28일
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
Jason
Jason 2011년 6월 30일
By the way, forgive me if I am mistaken, I thought it's permissible to modify the code, I just needed to retain the copyright notice. I was needing help with modifying the code to suit the intended application. Is this whole thread inappropriate?
Walter Roberson
Walter Roberson 2011년 6월 30일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2011년 6월 28일
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
Jason
Jason 2011년 6월 28일
Thanks for the reply. Please refer to above, the 'Subscript indices must either be real positive integers or logicals' error points to the line: gf_bank{bw,gamma,lambda,theta} = gabor_fn(bw,gamma,psi(1),lambda,theta) + 1i * gabor_fn(bw,gamma,psi(2),lambda,theta);
Walter Roberson
Walter Roberson 2011년 6월 30일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Filter Banks에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by