MATLAB: Does image reading is wrong?fullFilename contains the path of the image along with image extension

start_path = fullfile('F:', '\matlab\new\SignaturesDataBase');
topLevelFolder = uigetdir(start_path);
if topLevelFolder == 0
return;
end
allSubFolders = genpath(topLevelFolder);
remain = allSubFolders;
listOfFolderNames = {};
while true
[singleSubFolder, remain] = strtok(remain, ';');
if isempty(singleSubFolder)
break;
end
listOfFolderNames = [listOfFolderNames singleSubFolder];
end
numberOfFolders = length(listOfFolderNames);
for k = 1 : numberOfFolders
thisFolder = listOfFolderNames{k};
% Get PNG files.
filePattern = sprintf('%s/*.png', thisFolder);
baseFileNames = dir(filePattern);
% Add on TIF files.
filePattern = sprintf('%s/*.tif', thisFolder);
baseFileNames = [baseFileNames; dir(filePattern)];
% Add on BMP files.
filePattern = sprintf('%s/*.bmp', thisFolder);
baseFileNames = [baseFileNames; dir(filePattern)];
numberOfImageFiles = length(baseFileNames);
if numberOfImageFiles >= 1
for f = 1 : numberOfImageFiles
fullFileName = fullfile(thisFolder, baseFileNames(f).name);
%fprintf('PreProcessing image file %s\n', fullFileName);
img=imread('fullFileName');
img=Preprocessing1(img);
figure,imshow(img);
end
end
end

Best Answer

Well what would you want it to contain? It sounds right to me. However this is wrong:
img=imread('fullFileName');
It should be without quotes. When you added single quotes around it, that make a literal string - the string was 'fullFileName' instead of 'F:\My Images\foobar.png' or whatever. Here is the fix:
img=imread(fullFileName);