Undesirable size of resized images
Ältere Kommentare anzeigen
Hi.
I transformed audio files to spectrogram images and saved them in the folder.
To apply the images to open source MATLAB deep learning code, I resized them in [224 224 3].
However, the size of stored resized images was an undesirable size: [656 875 3]
How can I store images resized as desired?
Audio_Address = 'C:\Users\KOH\Desktop\MATLABcode\Audiofiles_RabbitLab';
SPTRGM_Address = 'C:\Users\KOH\Desktop\MATLABcode\RL_SpectrogramData';
Directory0 = dir(fullfile(Audio_Address,'RabbitSimul_0.0cc*.wav'));
Directory00 = dir(fullfile(SPTRGM_Address,'RabbitSimul_0.0cc*.jpg'));
ImageData_Address00 = 'C:\Users\KOH\Desktop\MATLABcode\RL_SpectrogramData(resize)\00';
windowSize = 256;
windowOverlap = [];
freqRange = 1000:20000;
for i = 1:numel(Directory0)
F = fullfile(Audio_Address,Directory0(i).name);
[y,Fs] = audioread(F);
endtime = numel(y)/(2*Fs);
t = 1/Fs:1/Fs:endtime;
AudioData{i}=y(:,1);
OGspectrogram=spectrogram(AudioData{i}, windowSize, windowOverlap, freqRange, Fs, 'yaxis');
spectrogram(AudioData{i}, windowSize, windowOverlap, freqRange, Fs, 'yaxis');
saveas(gcf,fullfile(SPTRGM_Address,sprintf('RabbitSimul_0.0cc_%d.jpg',i)));
end
for i = 1:numel(Directory00)
F = fullfile(SPTRGM_Address,Directory00(i).name);
SPTRGMimage{i,1}=imread(F);
Mod_SPTRGMimage{i,1}=imresize(SPTRGMimage{i,1},[224 224]);
imshow( Mod_SPTRGMimage{i,1});
saveas(gcf,fullfile(ImageData_Address00,sprintf('RabbitSimul_0.0cc_%d.jpg',i)));
end
imds = imageDatastore(SPTRGM_Address,'IncludeSubfolders',true,'LabelSource','foldernames');
img = readimage(imds,1);
size(img)
ans =
656 875 3
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!