MATLAB Answers


saving images into ImageDatastore

Asked by Robert Eggleston on 13 Sep 2019 at 20:22
Latest activity Commented on by Walter Roberson
on 13 Sep 2019 at 20:40
Hello all, I am working with some code where I am tasked with recreating a new imageDatastore in order to retrain a neural network. The entire code is in a for loop and I am having trouble saving a reproduced image to a datastore without it getting overwritten every iteration. I need to save Irec into a datastore so that I can then move to retraning the neural network however I am at a bit of a loss regarding how to do this.
% set negative values to zero and scale reconstructed image
% to integers in range [0,255];
Irec = max(0,Irec);
Irecmax = max(max(Irec));
Irec = 255*Irec/Irecmax;
%Irec = floor(Irec+.5-eps);
imshow(Irec,[0 255]);
title(['Reconstructed with ' num2str(pview) ' views in [0, ' num2str(thetamax) ']']);
dr = classify(netTransfer,Irec);
xlabel(['Classified as: ' char(dr)]);
title(['Reconstruction: Plot of row ' num2str(plotrow)])

  1 Comment

Walter Roberson
on 13 Sep 2019 at 20:40
When you go through the image data store, if you use readImage instead of read, then you can be tracking which image you are reading. Use the image number to index into the Files property of the datastore in order to find the source for the current file. fileparts() to extract the directory and base name and extension, and create a modified version of the name, put the parts back together to get an output file name. Now save content to that output file.

Sign in to comment.

0 Answers