Home Returning a 4D array from a function in MATLAB
Reply: 0

Returning a 4D array from a function in MATLAB

user984
1#
user984 Published in July 16, 2018, 2:45 am

I am trying to return a 4D array of image data from a function call in MATLAB. I'm not very advanced in MATLAB and I don't know what type of data I have to return from the function. Here is my function:

function classimg = loadImages(classdir,ext)
    % create array of all images in directory
    neg = dir([classdir ext]);
    % get size of array (to loop through images)
    numFileNeg = max(size(neg));
    % create a 4D array to store our images
    classimg = zeros(51,51,3,numFileNeg);
    % loop through directory
    for i=1:numFileNeg
        classimg(:,:,:,i) = imread([myDir neg(i).name]);
    end
end

Here is the function call:

negativeImgs = loadImages("C:\Users\example\Documents\TrainingImages\negatives\","*.jpg");

I cannot find any online documentation for the return type? Does anyone know what this would be? classimg is populated correctly so the code inner works.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.354981 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO