scripts.data_preparation.extract_subimages¶
- scripts.data_preparation.extract_subimages.extract_subimages(opt)[source]¶
Crop images to subimages.
- Parameters:
opt (dict) – Configuration dict. It contains:
input_folder (str) – Path to the input folder.
save_folder (str) – Path to save folder.
n_thread (int) – Thread number.
- scripts.data_preparation.extract_subimages.main()[source]¶
A multi-thread tool to crop large images to sub-images for faster IO.
It is used for DIV2K dataset.
- Parameters:
opt (dict) – Configuration dict. It contains:
n_thread (int) – Thread number.
compression_level (int) – CV_IMWRITE_PNG_COMPRESSION from 0 to 9. A higher value means a smaller size and longer compression time. Use 0 for faster CPU decompression. Default: 3, same in cv2.
input_folder (str) – Path to the input folder.
save_folder (str) – Path to save folder.
crop_size (int) – Crop size.
step (int) – Step for overlapped sliding window.
thresh_size (int) – Threshold size. Patches whose size is lower than thresh_size will be dropped.
- Usage:
For each folder, run this script. Typically, there are four folders to be processed for DIV2K dataset.
DIV2K_train_HR
DIV2K_train_LR_bicubic/X2
DIV2K_train_LR_bicubic/X3
DIV2K_train_LR_bicubic/X4
After process, each sub_folder should have the same number of subimages.
Remember to modify opt configurations according to your settings.
- scripts.data_preparation.extract_subimages.worker(path, opt)[source]¶
Worker for each process.
- Parameters:
path (str) – Image path.
opt (dict) – Configuration dict. It contains:
crop_size (int) – Crop size.
step (int) – Step for overlapped sliding window.
thresh_size (int) – Threshold size. Patches whose size is lower than thresh_size will be dropped.
save_folder (str) – Path to save folder.
compression_level (int) – for cv2.IMWRITE_PNG_COMPRESSION.
- Returns:
Process information displayed in progress bar.
- Return type:
process_info (str)