This Python script is designed to load images from a specified directory using a ThreadPoolExecutor
for concurrent execution. It reads all .tif
files from the "tif" directory and processes them in parallel, utilizing multiple threads to speed up the image loading process.
✅Important Note: The order of the images is preserved throughout this process. The executor.map
method guarantees that the results are returned in the same order as the input paths, ensuring that the correspondence between the file paths and the loaded images is maintained.
- 🖥️ os (built-in): For interacting with the operating system to list files in a directory.
- 📷 cv2 (OpenCV, to be installed): For reading image files.
- 📁 pathlib (built-in): For manipulating filesystem paths in a platform-independent way.
- 🌐 concurrent.futures.ThreadPoolExecutor (built-in): For managing a pool of threads to execute calls asynchronously.