view dsp/wignerdata.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents c3b0cd708782
children
line wrap: on
line source
function Z=wignerdata(m,X)
% sliding window wigner distribution. feature:
% - low pass filter because of undersampling of 
%   autocorrelation function
% - windowing of autocorrelation to avoid spectral leakage
% - temporal smoothing followed by down sampling

	N = 2*m+1; % frame size

	[ filtB, filtA ] = butter( 5, 0.5);

	% make sure frames are N samples long

	% lowpass signal, get autocorrelation in wigner form,
	% then short term average (exponential window) by 1st
	% order IIR.
	Im=m+1:2*m+1;
	Ip=m+1:-1:1;
	Z=map(@wiglocal,select(filtA,filtB,X));

	function z=wiglocal(m,Im,Ip,X)
		r=X(Ip,:).*X(Im,:);	
		%smoothing??
		smKernel = gauss_win(128,0.4)';
		wigR = spdiag(hgauss_win(m,0.5))*r;
		% must filter and subsample wigR here
		smRS = filter2(smKernel, wigR, 'valid');
		% subsample in time here?

		% take real fft using window
		z = abs(fft([smR(1:m,:); smR(m+1:-1:2,:)]));
	end
end