How to save separate '.mat' files with the image name including it ?
Show older comments
I am creating the data base for the Microscopic cell 400 images that extracts the alive and dead cells by calling gerect func. I need to save the result in the .mat files starting with image name.I am using 'try' and 'catch' to generate the database. my code as follows:
[fname path]=uigetfile('.jpg','open a cell pic');
fname=strcat(path,fname);
a=imread(fname);
im=rgb2gray(a);
imshow(im);
title('input image');
while(1)
rect=datapoints(im); % calling getrect function to extract points
%c=input('enter the label: \n');
try
load data
trainSets=[rect c];
data=[data; trainSets];
save data.mat data;
catch
data=[rect c];
save data.mat data
end
this program creating only one .mat File name named as 'data.mat' , but i need .mat for each image i open.as image1.mat, then image2.mat and so on Plz help !!!!!!
1 Comment
You need use the function version of save, rather than the command form, and create a new filename each time you call the function. I would recommend that you use fullfile to create the full filename.
Accepted Answer
More Answers (0)
Categories
Find more on Convert Image Type 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!