Syntax
ImFileList=imageFolderContent([DirName])
Input Parameter
Output Parameter
ImFileList : | | cell list of image files |
Examples
imageFolderContent(desktopdir)
Copyright 2020-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, imageFolderContent
, is designed to find all image files within a specified directory. It is part of the SolidGeometry library and was introduced in version 4.9. The function is known to be slow because it attempts to open each file to verify if it is an image.
Input Parameters
- DirName: The name of the directory to search for image files. This is the only input parameter and is expected to be a valid directory path.
Output Results
- ImFileList: A cell array containing the names of image files found in the specified directory.
Algorithm Steps
- The function begins by retrieving the directory name from the input parameters using
getfuncparams
.
- It checks if the provided directory name is valid using
isfolder
. If not, it returns an empty list and issues a warning.
- The function retrieves the content of the directory using
dir
and converts the names to a cell array.
- It initializes two logical arrays,
inlist
and imlist
, to keep track of valid files and image files, respectively.
- For each file in the directory, it constructs the full file path and checks if it is a folder. If it is a folder and not the current or parent directory, it marks it in
imlist
.
- It attempts to read each file as an image using
imread
. If successful, the file is marked as valid in inlist
. If an error occurs, the file is marked as invalid.
- The function returns a list of valid image files by filtering
Dcontent
with inlist
.
Example Usage
To use the function, call it with a directory path:
imageFolderContent('C:\Users\YourName\Desktop')
Algorithm explaination created using ChatGPT on 2025-08-19 08:18. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21