Why my "arraystore" will change the dimension of the images data set

조회 수: 2 (최근 30일)
畅 孙
畅 孙 2022년 3월 13일
댓글: 畅 孙 2022년 3월 13일
I imported images data from my local file use "imread", and use "arraystore" to convert it, but when I use "read" to check it I found that the dimensions of images set have been changed.
This is my code:
---------------------------------------
files = dir(fullfile('F:\\work\\MyImageData\\','*.jpg'));
lengthFiles = length(files);
for i = 1:lengthFiles
I(:,:,:,i)= imread(strcat('F:\work\MyImageData\',files(i).name));
end
inputImage=im2double(I);
dsinputImage = arrayDatastore(inputImage);
readdsinputImage=read(dsinputImage);
----------------------------------------
The dimensions of "inputImage" are {343×344×3×200 double}, which constains 200 images with dimension [343 344 3], but the dimension of "readdsinputImage" are {1×344×3×200 double}
I want to realization the example "Train Network with Multiple Outputs" while the only different is that the images dimensions example used are [28 28 1], and my images dimensions are [343 344 3], but is seems that i get a problem at the data preparation stage

채택된 답변

Simon Chan
Simon Chan 2022년 3월 13일
For your case where the data are images, better to use the following:
The default ReadSize is 1 and hence it reads only 1 row of the data.
IterationDimension set to 4 so that it stores an entire image each time.
dsinputImage = arrayDatastore(inputImage,'ReadSize',343,'IterationDimension',4);
  댓글 수: 3
Simon Chan
Simon Chan 2022년 3월 13일
Please accept the answer if you find it useful.Thank you.
畅 孙
畅 孙 2022년 3월 13일
Of course,thanks again

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by