- Use parfor instead of the regular for loop, this would save time.
- While loading the generated dataset, make use of the imageDatastore or imageSet
What is the most efficient way to create a large image database from MATLAB plots or figures for use in Deep Learning?
5 views (last 30 days)
Show older comments
Cameron Huggins
on 21 Feb 2020
Commented: Cameron Huggins
on 24 Feb 2020
I am working with a large dataset and have created a looped code that:
- Creates a colourmap / surface plot from Continuous Wavelet Transform (cwt) data.
- Alters the image size and axes to make them suitable for use in 'Deep Learning Toolbox'.
- Writes the image, as a .png, to a file name and location using imwrite.
- Repeats for each set of data.
I have approximately 340,000 images to create and as you can imagine, this has been taking >2days to create and even though each file size is ~30kb, the total folder size is ~10Gb.
The code is as shown:
(Missing: DB2data = raw data; file_list = file name list; save_path = directory save path)
for m = 1:length(DB2data)
%% SIGNAL PROCESSING
fig = figure('visible','off');
[cfs,frq]=cwt(DB2data(m,:),fs);
surf(t,frq,abs(cfs),'edgecolor','none')
colormap parula %Set colour to 'parula'
view(2)
%% IMAGE SETTINGS
ylim([0.5 40]) %Set frequency axis
zlim([0 56.5]) %Set colourbar limits
xlim([0 5]) %Set time axis
axis off %Remove axes
colorbar off %Remove colorbar
set(gca,'LooseInset',get(gca,'TightInset')); %Remove background
set(gca,'units','normalized','position',[0 0 1 1]); %Remove additional background
fig2 = getframe(fig); %Get 'image' from figure
image = fig2.cdata; %Imgage data
image = imresize(image, [227 227]); %Resize image
imwrite(image, fullfile(save_path, strcat(file_list(m),'.png'))); %Save image
close(fig) %Close figure
end
Does anyone have any suggests on a more efficient way to create a large image database like this?
Thanks in advance.
0 Comments
Accepted Answer
Srivardhan Gadila
on 24 Feb 2020
The following suggestions might help you:
More Answers (0)
See Also
Categories
Find more on Blue 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!