imageFolderContent

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Images
Introduced first in SolidGeometry 4.9, Creation date: 2020-03-27, Last change: 2025-09-14

finds all image files within a folder

Description

very slow function since it really tries to open all files as image
without considering the extensions

See Also:

Example Illustration

 missing image of imageFolderContent(DirName)

Syntax

ImFileList=imageFolderContent([DirName])

Input Parameter

DirName: folder name

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

Output Results

Algorithm Steps

  1. The function begins by retrieving the directory name from the input parameters using getfuncparams.
  2. It checks if the provided directory name is valid using isfolder. If not, it returns an empty list and issues a warning.
  3. The function retrieves the content of the directory using dir and converts the names to a cell array.
  4. It initializes two logical arrays, inlist and imlist, to keep track of valid files and image files, respectively.
  5. 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.
  6. 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.
  7. 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