AlexNet training on 3D matlab file data

4 visualizzazioni (ultimi 30 giorni)
paco coci
paco coci il 30 Gen 2022
Modificato: Soumya il 18 Giu 2025
Hi all, I have some data that I would like to train AlexNet on. I have the images in two types 2d png images and 3D data matfiles. The png files are not 227x227x3. They are RGB values but 61x61. they are about 100 images so I tried to convert them using the image batch processor but it converted them to 227x227x1 and lost the RGB. Is there a way to either convert the 61x61 to 227x227x3 all at once using the image batch processor or any other tool that converts all at the same time? or better, is there a way to train AlexNet on the 3D data matfiles?
Thank you so so much

Risposte (1)

Soumya
Soumya il 18 Giu 2025
Modificato: Soumya il 18 Giu 2025
There is a workaround to convert all your images into the size [227x227x3] all at once using the image batch processor. This process involves a custom function to ensure that all images are resized correctly while preserving the colour format required by ‘AlexNet’. Since your input images are in the RGB format from itself, we can simply resize it into [227x227] using imresize’ function. To get your desired format of images using image batch processor, you can follow the steps given below:
  • Go to the column ‘Batch Function’ in the image batch processor and click on Create Function.
  • The MATLAB Editor will open with a template function populated. Then add the following function to it:
function out = RGBresize(img)
if size(img, 3) == 3
out = imresize(img, [227 227]);
end
Now the output images will be converted to the format that you desired.
Another way to carry out size conversion is by using the augmentedImageDatastore function in with your AlexNet network. An augmented image datastore transforms batches of training, validation, test, or prediction data with optional preprocessing, such as resizing, rotation, and reflection. The following script can be used to perform the same:
imds = imageDatastore(folder_name);
augImds = augmentedImageDatastore([227 227], imds,'ColorPreprocessing', 'none');
For tasks involving 3D inputs, MATLAB does provide ‘resnet3dNetwork’ offering a more appropriate solution, as they are more specifically designed to handle volumetric data and are aligned for 3D deep learning applications.
Please find the attached documentations to get more information on the specific topics:
  1. Transfer Learning Using AlexNet: https://www.mathworks.com/help/deeplearning/ug/transfer-learning-using-alexnet.html
  2. Alexnet: https://www.mathworks.com/help/deeplearning/ref/alexnet.html
  3. Related MATLAB Answers post: https://www.mathworks.com/matlabcentral/answers/581307-transfer-learning-for-2d-image-using-alexnet
  4. resnet3dNetwork : https://www.mathworks.com/help/deeplearning/ref/resnet3dnetwork.html
  5. Image Batch Processor: https://www.mathworks.com/help/images/process-images-using-image-batch-processor-app-with-file-metadata.html
I hope this helps!

Categorie

Scopri di più su Deep Learning Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by