annotate matlab/bmm/carfac/SAI_BlendFrameIntoComposite.m @ 608:fc353426eaad

Better functionization of SAI, and new way to make picture with lag marginal and smoothed history of lag marginal.
author dicklyon@google.com
date Mon, 13 May 2013 21:15:56 +0000
parents ec3a1c74ec54
children b3118c9ed67f
rev   line source
dicklyon@604 1 % Copyright 2013, Google, Inc.
dicklyon@604 2 % Author: Richard F. Lyon
dicklyon@604 3 %
dicklyon@604 4 % This Matlab file is part of an implementation of Lyon's cochlear model:
dicklyon@604 5 % "Cascade of Asymmetric Resonators with Fast-Acting Compression"
dicklyon@604 6 % to supplement Lyon's upcoming book "Human and Machine Hearing"
dicklyon@604 7 %
dicklyon@604 8 % Licensed under the Apache License, Version 2.0 (the "License");
dicklyon@604 9 % you may not use this file except in compliance with the License.
dicklyon@604 10 % You may obtain a copy of the License at
dicklyon@604 11 %
dicklyon@604 12 % http://www.apache.org/licenses/LICENSE-2.0
dicklyon@604 13 %
dicklyon@604 14 % Unless required by applicable law or agreed to in writing, software
dicklyon@604 15 % distributed under the License is distributed on an "AS IS" BASIS,
dicklyon@604 16 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dicklyon@604 17 % See the License for the specific language governing permissions and
dicklyon@604 18 % limitations under the License.
dicklyon@604 19
dicklyon@608 20 function composite_frame = SAI_BlendFrameIntoComposite( ...
dicklyon@604 21 layer_struct, composite_frame)
dicklyon@604 22
dicklyon@608 23 new_frame = layer_struct.frame;
dicklyon@604 24 alpha = layer_struct.alpha;
dicklyon@604 25 lag_curve = layer_struct.lag_curve;
dicklyon@604 26 target_columns = layer_struct.target_indices;
dicklyon@604 27
dicklyon@604 28 frame_width = size(new_frame, 2);
dicklyon@604 29
dicklyon@604 30 % Lags are measured from 0 at the right.
dicklyon@604 31 stretched_frame = interp1(new_frame', frame_width - lag_curve)';
dicklyon@604 32 alpha = repmat(alpha, size(new_frame, 1), 1);
dicklyon@604 33 composite_frame(:, target_columns) = ...
dicklyon@604 34 (1 - alpha) .* composite_frame(:, target_columns) + ...
dicklyon@604 35 alpha .* stretched_frame;