dicklyon@462: function stage_state = CARFAC_Spatial_Smooth(coeffs, stage, stage_state) dicklyon@462: % function AGC_state = CARFAC_Spatial_Smooth( ... dicklyon@462: % n_taps, n_iterations, FIR_coeffs, AGC_state) dicklyon@462: dicklyon@462: n_iterations = coeffs.AGC_spatial_iterations(stage); dicklyon@462: dicklyon@462: use_FIR = n_iterations < 4; % or whatever condition we want to try dicklyon@462: dicklyon@462: if use_FIR dicklyon@462: FIR_coeffs = coeffs.AGC_spatial_FIR(:,stage); dicklyon@462: switch coeffs.AGC_n_taps(stage) dicklyon@462: case 3 dicklyon@462: for iter = 1:n_iterations dicklyon@462: stage_state = ... dicklyon@462: FIR_coeffs(1) * stage_state([1, 1:(end-1)], :) + ... dicklyon@462: FIR_coeffs(2) * stage_state + ... dicklyon@462: FIR_coeffs(3) * stage_state([2:end, end], :); dicklyon@462: end dicklyon@462: case 5 % 5-tap smoother duplicates first and last coeffs: dicklyon@462: for iter = 1:n_iterations dicklyon@462: stage_state = ... dicklyon@462: FIR_coeffs(1) * (stage_state([1, 1, 1:(end-2)], :) + ... dicklyon@462: stage_state([1, 1:(end-1)], :)) + ... dicklyon@462: FIR_coeffs(2) * stage_state + ... dicklyon@462: FIR_coeffs(3) * (stage_state([2:end, end], :) + ... dicklyon@462: stage_state([3:end, end, end], :)); dicklyon@462: end dicklyon@462: otherwise dicklyon@462: error('Bad n_taps in CARFAC_Spatial_Smooth'); dicklyon@462: end dicklyon@462: else dicklyon@462: % use IIR method, back-and-forth firt-order smoothers: dicklyon@462: stage_state = SmoothDoubleExponential(stage_state, ... dicklyon@462: coeffs.AGC_polez1(stage), coeffs.AGC_polez2(stage)); dicklyon@462: end