Smoothing 3D surface in Matlab -
i struggling optimization of displayed 3d object. want achieve make 3d spectrogram of audio file. what's more want have black , white , nice looking. nice looking means - this:
this sample image - aware spectrogram won't that
this code used generating surface reduced number of faces:
[y,fs,nbits]=wavread('audio.wav'); [s f t]= spectrogram(y(:,1),256,100,256,fs); clear y [x,y]=meshgrid(t,f); z=log10(abs(s)); rskip = round(linspace(1,size(z,1),80)); cskip = round(linspace(1,size(z,2),64)); surf(x,y,z,'facecolor','white','edgecolor','none'); hold on surf(x(rskip,:),y(rskip,:),z(rskip,:),'facecolor','none','meshstyle','row'); surf(x(:,cskip),y(:,cskip),z(:,cskip),'facecolor','none','meshstyle','column'); hold off view(-65.5, 28);
the main problem audio file , reason why using reduced number of faces size of x,y,z arrays - 129 269065. pc has 8gb of ram , around 1gb used other applications (including os) leaving around 6-7 gb matlab.
this image created after code run:
can advice me how can make smoother? sample image.
if purely aesthetic reasons, quick dirty way smoother image apply gaussian filter power matrix returned spectrogram function.
clear; [file,path] = uigetfile('*.wav'); % use gui select file [y,fs,~] = wavread([path file]); [p,f,t] = spectrogram(y(:,1),256,100,256,fs); % create gaussian filter hsize = [5 5] , sigma = 2 g = fspecial('gaussian',[5 5],2); % apply gaussian filter db values pblur = imfilter(real(10*log10(p)),g,'same'); %# show resulting spectograms (filtered on top, origional on bottom) figure(2); imagesc([pblur; real(10*log10(p))]); colormap jet;
you can change hsize
, sigma
adjust blur properties.
Comments
Post a Comment