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

5 ビュー (過去 30 日間)
Fareed Jamali
Fareed Jamali 2021 年 5 月 28 日
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 件)

Community Treasure Hunt

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

Start Hunting!

Translated by