applyfilterfftsameLocalNorm

PURPOSE ^

applyfilterfftsameLocalNorm - Filter image by a bank of filters with local normalization.

SYNOPSIS ^

function allFiltered = applyfilterfftsameLocalNorm(I, allfilter, localRadiusProportion)

DESCRIPTION ^

 applyfilterfftsameLocalNorm - Filter image by a bank of filters with local normalization. 

 I: input images
 allfilter: filter bank
 threshold: filter response is set to zero if below threshold

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function allFiltered = applyfilterfftsameLocalNorm(I, allfilter, localRadiusProportion)
0002 % applyfilterfftsameLocalNorm - Filter image by a bank of filters with local normalization.
0003 %
0004 % I: input images
0005 % allfilter: filter bank
0006 % threshold: filter response is set to zero if below threshold
0007 
0008 numImage = size(I, 2);    % number of training images
0009 numOrient = length(allfilter);     % number of orientations
0010 allfilter = reshape(allfilter,[1 numOrient]);
0011 h = (size(allfilter{1}, 1)-1)/2;  % half size of filters
0012 [sx, sy] = size(I{1});  % size of images
0013 thresholdFactor = 0.01;
0014 
0015 allFiltered = cell(numImage, numOrient);  % filtered images
0016 for i = 1 : numImage
0017     fftI{i} = fft2(I{i}, sx+h+h, sy+h+h);
0018 end
0019 for o = 1 : numOrient
0020    fftf{o} = fft2(allfilter{1, o}, sx+h+h, sy+h+h); 
0021 end
0022 
0023 radius = floor((2*h+1)*localRadiusProportion);
0024 radius = max(20*2+1,radius);
0025 localHalfx = radius; localHalfy = radius;
0026 for i = 1 : numImage
0027    tot = 0.;
0028    fftIi = fftI{i}; 
0029    for o = 1 : numOrient
0030       fftfo = fftf{o}; 
0031       out = ifft2(fftIi.*fftfo); 
0032       filtered = out(h+1:h+sx, h+1:h+sy);
0033       re = real(filtered); im = imag(filtered); 
0034       energy = re.*re + im.*im;  % compute the local energy
0035       energy([1:h sx-h:sx],:) = 0.; energy(:,[1:h sy-h:sy]) = 0.;
0036       allFiltered{i, o} = energy; 
0037       tot = tot + sum(sum(energy((h+1):(sx-h-1), (h+1):(sy-h-1))))/(sx-2*h-1)/(sy-2*h-1); 
0038    end
0039    ave = tot/numOrient;
0040    for o = 1 : numOrient
0041        allFiltered{i, o} = single(allFiltered{i, o}/ave);  % normalizing by whitening
0042    end
0043        ClocalNormalizeSingle(sx, sy, numOrient, h, localHalfx, localHalfy, allFiltered(i, :), thresholdFactor); 
0044 end
0045

Generated on Sat 23-Jan-2010 22:26:10 by m2html © 2005