% function [oe,zcrs,par,FIo,FIe,FBo,FBe] = quadeg(I,par); % Input: % I = image % par = vector for 4 parameters, default = [8,1,21,3] % [number of filter orientations, number of scales, filter size, elongation] % To use any of the default values, put 0. % Output: % oe = orientation energy % zcrs = zero crossing % par = actual par used % [FIo,FIe] = odd and even filter responses % [FBo,FBe] = odd and even filters % % Stella X. Yu, July 9 2003 function [oe,zcrs,par,FIo,FIe,FBo,FBe] = quadeg(I,par); [r,c,k] = size(I); if k>1, I = rgb2gray(I); end % any missing parameter is substituted by a default value def_par = [8,1,21,3]; if nargin<2 | isempty(par), par = def_par; end par(end+1:4)=0; j = (par>0); par = par .* j + def_par .* not(j); % make the filter size an odd number so that the responses are not skewed if mod(par(3),2)==0, par(3) = par(3)+1; end j = num2cell(par); [n_filter,n_scale,winsz,enlong] = deal(j{:}); % filter the image with quadrature filters FBo = make_filterbank_odd2(n_filter,n_scale,winsz,enlong); FBe = make_filterbank_even2(n_filter,n_scale,winsz,enlong); n = ceil(winsz/2); f = [fliplr(I(:,2:n+1)), I, fliplr(I(:,c-n:c-1))]; f = [flipud(f(2:n+1,:)); f; flipud(f(r-n:r-1,:))]; FIo = fft_filt_2(f,FBo,1); FIo = FIo(n+[1:r],n+[1:c],:); FIe = fft_filt_2(f,FBe,1); FIe = FIe(n+[1:r],n+[1:c],:); % pick up the maximum energy across scale and orientation [oe,max_id] = max(FIo.^2+FIe.^2,[],3); oe = oe / max(oe(:)); np = r * c; zcrs = reshape(FIe([1:np]'+(max_id(:)-1)*np),[r,c]); zcrs = (zcrs>=0) - (zcrs<0);