Save data in jpg format in special folder

1 view (last 30 days)
Hello.
I wanted to make imagedatastore from .mat file.,(it consist of 1x1 struct:Data with 150x10000double and Labels with 150x1cell.)
My target was save figures in special format(for example, .j,pg, 224x224pixel) in special folder. Actually there are 3 subfolder(name of 3 category).
So i tried codes like this
load(fullfile(tempdir,'ECG','Data.mat')
parentDir = tempdir
dataDir = 'data'
imageRoot = fullfile(parentDir,)dataDir;
data = Data.Data
labels = Data.Labels
r = size(data,1)
for i = 1:r
cfs = abs(data(i,1:1000)
im = ind2rgb(im2uint8(rescale())cfs,jet(128))
imgLoc= fullfile(imageroot,char(labels()))i
imFileName= strcat(char(labels(i)),'_',num2str()i,''jpg)
imwrite(imresize(im,[224 224],fullfile(imgLoc,))
end
imFileName
  1 Comment
khadicha amonova
khadicha amonova on 19 Mar 2019
Edited: khadicha amonova on 19 Mar 2019
Furthermore, at the beginning I wanted to use plot and saveas function. But unfortunately There no possiblity to save in special folder automatically in saveas funtion.
At the result I used abow mentioned code and I get jpg files with terrible images! They look very strange! ?
only one things makes me happy that they are located in proper folders!,?
How I can plot my signal (there are150 signal data in one .mat file) and save them in proper folder automatically!
Please help me

Sign in to comment.

Answers (0)

Categories

Find more on Printing and Saving in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!