In a folder I have a PNGFiles subfolder and several jpeg and overlay files. I want to read the png files with the same name as the .OVERLAY.
Can anyone help?Thanks.

 採用された回答

Image Analyst
Image Analyst 2021 年 10 月 11 日

0 投票

Untested code:
filePattern = fullfile(pwd, '**\*.png'); % Wildcard recurses into subfolders
fileList = dir(filePattern);
for k = 1 : numel(fileList)
% Build the full filename of the PNG file in the PNG folder.
pngFullFileName = fullfile(fileList(k).folder, fileList(k).name);
% Get the base filename of the PNG file, without the extension.
[folder, baseFileNameNoExt, ext] = fileparts(pngFullFileName);
% Get the overlay file for this image in the current folder (one level up)
ovlFullFileName = fullfile(pwd, [baseFileNameNoExt, '.overlay'])
% If it doesn't exist, skip this file.
if ~isfile(ovlFullFileName)
warningMessage = sprintf('Warning: Overlay file does not exist:\n%s', ovlFullFileName);
uiwait(warndlg(warningMessage));
contiue;
end
overlayImage = imread(ovlFullFileName);
% Do something with the PNG file and the overlay file.
end

その他の回答 (0 件)

質問済み:

2021 年 10 月 11 日

回答済み:

2021 年 10 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by