Undesirable size of resized images

1 Ansicht (letzte 30 Tage)
Daeyeon Koh
Daeyeon Koh am 12 Jan. 2022
Beantwortet: Geoff Hayes am 21 Jan. 2022
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;
OGspectrogram=spectrogram(AudioData{i}, windowSize, windowOverlap, freqRange, Fs, 'yaxis');
spectrogram(AudioData{i}, windowSize, windowOverlap, freqRange, Fs, 'yaxis');
for i = 1:numel(Directory00)
F = fullfile(SPTRGM_Address,Directory00(i).name);
Mod_SPTRGMimage{i,1}=imresize(SPTRGMimage{i,1},[224 224]);
imshow( Mod_SPTRGMimage{i,1});
imds = imageDatastore(SPTRGM_Address,'IncludeSubfolders',true,'LabelSource','foldernames');
img = readimage(imds,1);
ans =
656 875 3

Antworten (1)

Geoff Hayes
Geoff Hayes am 21 Jan. 2022
@Daeyeon Koh - I think that you are saving the figure rather than the image that is displayed in the figure to the file
and so it makes sense that the size is not what you expect it to be? I suspect if you open the image, you will see the axes, labels, and other components of the figure. Is this intentional or do you want to be saving the image Mod_SPTRGMimage{i,1} to file as

Community Treasure Hunt

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

Start Hunting!

Translated by