preprocessing
check_and_save_color_images(folder_path:str)
Check images in a folder and ensure they are saved as 3-channel color images. This function scans a given folder for image files and verifies if each image is a 3-channel color image (BGR). If an image has fewer channels (e.g., grayscale), it is converted to a 3-channel BGR format and saved in place.
Parameters:
folder_path
(str): The path to the folder containing image files.
Examples:
>>> check_and_save_color_images("images/")
Notes:
- Images that are already in color format will be left unmodified.
- The function prints messages for missing folders, failed reads, and conversions.
See_also:
- `cv2.imread`: Used for reading images.
- `cv2.cvtColor`: Used to convert grayscale to BGR.
- `cv2.imwrite`: Used to overwrite the original image with the new one.
Caution:
Only image files with extensions '.png', '.jpg', '.jpeg', or '.bmp'
will be processed. Non-image files are ignored.
Warning:
This function overwrites original grayscale images with their color-converted versions.
Labels:
src_PyThon_ContactAngle_CaMeasurer_preprocessing_check_and_save_color_images
make_folders(ad:str)
Create two subfolders 'SR_edge' and 'SR_result' inside the given directory. If either folder already exists, it is deleted and recreated to ensure a clean directory.
Parameters:
ad
(str): The path to the parent directory where subfolders will be created.
Examples:
>>> make_folders("/path/to/project")
Notes:
- The folders created are:
- 'SR_edge': Typically used to store edge detection outputs.
- 'SR_result': Typically used to store final super-resolution results.
- Uses `shutil.rmtree()` to forcefully delete existing directories before recreating.
See_also:
- `os.makedirs`: For creating directories.
- `shutil.rmtree`: For removing directories and their contents.
Caution:
This function will **delete** existing 'SR_edge' and 'SR_result' folders
along with all their contents, if they already exist.
Warning:
Any existing data in 'SR_edge' and 'SR_result' will be permanently lost if present.
Author:
- Sajjad Shumaly
Labels:
src_PyThon_ContactAngle_CaMeasurer_preprocessing_make_folders