Save a matrix to Image and then extract the same matrix from Image

1 次查看(过去 30 天)
Greetings everyone.
Above is the link from which I am trying to implement a process. I want to convert stft magnitude of audio to spectrogram and from the spectrogram, I want to regenerate the stft magnitude of audio. Saving the stft magnitude of audio in the spectrogram is easy through imwrite command but I can not recreate the same matrix when I try to convert the spectrogram back to audio. Not sure where I am missing some crucial information that is required to implement this process. Attaching the audio2 file for reference. Audio is attached as a zip file due to file sharing format restrictions. Any help will be highly appreciated.
clear all
close all
clc
[y,Fs]=audioread('audio2.wav');
sound(y,Fs) %To hear the sound
ty = (0:length(y)-1)/Fs;
wind = hamming(128);
olen = 64;
nfft = 1024;
stft(y,Fs,'Window',wind,'OverlapLength',olen,'FFTLength',nfft);
s=stft(y,Fs,'Window',wind,'OverlapLength',olen,'FFTLength',nfft);
smag=abs(s);
sphs=angle(s);
imwrite(smag,'FigureNew',jpg);
imshow(smag);

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Digital Input and Output 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by