MATLAB: DICOM Image Resize Error

alexnetcreating images for alexnetdeep learningdicomresize

Hi,there. I'm new to matlab and programming.
Since resizing is needed for Alexnet and Googlenet, I`m now working on resizing Dicom File from 256*256*1 to 227*227*3.
Here is my directory:
main
— a
— image.dcm(10 dicom file)
 – b
  – image.dcm(10 dicom file)
 – c
  – image.dcm(10 dicom file)
— d
  – image.dcm(10 dicom file).
Here is my code:
%path = current directory
currentdirectory = pwd;
%% Create an ImageDatastore to help you manage the data.currentdirectory = pwd;
categories = {'a', 'b', 'c','d'};
%Because ImageDatastore operates on image file locations,
imds = imageDatastore(fullfile(currentdirectory, categories),'IncludeSubfolders',true,'FileExtensions','.dcm','LabelSource', 'foldernames','ReadFcn',@dicomread);
%resize
imdsResized = imresize3(imds, [227 227 3]);
However, it throws following error:
Error using imresize3
Expected input number 1, V, to be one of these types:
single, double, int8, int16, int32, uint8, uint16, uint32
Instead its type was matlab.io.datastore.ImageDatastore.
Anyone have answer about this situation, pls let me know.
Thanks in advance!

Best Answer

It is not possible to resize an entire imageDatastore. You would need to loop doing readimage() and resize them one by one, or else use readall() to get back a cell array that you could cellfun() a resize operation on.
Related Question