Question about imageDatastore input

조회 수: 2 (최근 30일)
Rui Xiang
Rui Xiang 2018년 1월 12일
댓글: khadicha amonova 2019년 3월 19일
Hi, I am using matlab neural network toolbox to do image classification. But what we have as train data now is .mat files instead of .jpg files. Every .mat file contains a 3D double matrix.
One way I am doing now is that for a .mat file I use imwrite function to transfer it into an image.And then use the standard way to input the data
trainImages = imageDatastore('DataImage\224M225\TrJPG','IncludeSubfolders',true,'LabelSource','foldernames');
trainImages.ReadFcn = @(loc)imresize(imread(loc),[224,224]);
But eventually what is used in the neural network is just a 3D matrix, is there any way I can directly input my .mat files without saving it as an image first? (because imwrite function makes the matrix different from the original one, lots of information is lost)
  댓글 수: 4
Krishna Bindumadhavan
Krishna Bindumadhavan 2018년 1월 18일
편집: Krishna Bindumadhavan 2018년 1월 18일
Did you try using the nnstart command by typing
>> nnstart
at the MATLAB command line?
In case you are trying to solve a classification problem, you can select Pattern recognition and import data from a variety of formats including .mat files.
When you say your input data is a three dimensional matrix of doubles, could you clarify exactly how the data is structured , i.e how are the predictors referenced in this case?
Rui Xiang
Rui Xiang 2018년 1월 22일
So my task is to classify a set of many 3D matrix. nnstart treats row or col vectors as one sample but mine is actually a whole matrix. So I dunt think nnstart can help here.

댓글을 달려면 로그인하십시오.

답변 (1개)

Raphael Ruschel
Raphael Ruschel 2018년 10월 5일
Hello, I had a similar problem and solved it like this:
train_images = imageDatastore(train_path,'IncludeSubfolders',true,'FileExtensions','.mat','ReadFcn',@loadmydata);
function data = loadmydata(filename)
load(filename)
end
On my case, I had my matrices saved as 'data' inside my .mat so I only needed to call load(filename)
  댓글 수: 9
Raphael Ruschel
Raphael Ruschel 2019년 2월 11일
I recommend you rename the variables inside your .mat in a way that everyone has the same name, as this would make it easier to load the variables using the loadmydata function
khadicha amonova
khadicha amonova 2019년 3월 19일
I used so this code as you corrected, but error occured
Error using training option
ImageDatastore has no labels.
My mat file is consist of 1x1struct with Data 125 x60000 double and Labels 1x125 cell.
Did i make any error?
please help

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by