view graphics/tfdimage.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 82075c94eed1
children
line wrap: on
line source
function tfdimage(TFD,N,m,fs,range,varargin)
% TFDIMAGE:	image of time frequency distribution with correct axes
%
% tfdimage(TFD,N,M,fs[,range])
%
% TFD:	image matrix
% fs:	sampling rate in Hz
% N:		frame size (used to determine frequency scale)
% m:		hop size (used to derermine time scale)
% range: if present, determines manual colour scaler. range(1)=dBs of dynamic range,
%        and range(2) is max value.
%        if range=[], uses default manual offset (13.5).

if nargin<4, fs=1; end
opts=options('offset',0,varargin{:});
	
[T,F]=tfscale(fs,N,m,size(TFD));
if fs>1000,
	imagesc(T+opts.offset,F/1000,10*log10(TFD));
else
	imagesc(T+opts.offset,F,10*log10(TFD));
end
if nargin>=5
	if isempty(range), range=13.5; end
	
	dBs=range(1);
	cax=caxis; cax(1)=cax(2)-dBs;
	if length(range)>1,
		cax=cax+range(2)-cax(2);
	end
	caxis(cax);
end
axis xy
xlabel('time/s');
if fs>1000,
	ylabel('frequency/kHz');
else
	ylabel('frequency/Hz');
end