This is not correct syntax:
title('I = imread(imds);
You need to have a string in the title argument, like
title('This is my image');
And your display loop needs to be like this:
rootFolder = '/Users/marinaghobrial/Downloads/compressed-2';
imds = imageDatastore (fullfile(rootFolder), ...
'LabelSource',"foldernames", 'IncludeSubfolders',true);
figure
allFileNames = imds.Files;
%allFileNames = allFileNames(1:16); % Show just the first 16.
numImages = length(allFileNames)
plotRows = ceil(sqrt(numImages))
allPossibleFormats = imformats;
validImageCount = 0;
for k = 1:numImages
thisFileName = allFileNames{k};
% Display the file as an image, if you can.
try
thisImage = imread(thisFileName);
validImageCount = validImageCount + 1;
subplot(plotRows, plotRows, validImageCount);
imshow(thisImage)
[folder, baseFileName, ext] = fileparts(thisFileName);
title([baseFileName, ext]);
drawnow;
catch
end
end
g = gcf;
g.WindowState = 'maximized'
