- 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 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Srivardhan Gadila
2020-2-24
The following suggestions might help you:
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!