split the large images from original_dataroot into small overlapped images with size (p_size)x(p_size), and save them into taget_dataroot; only the images with larger size than (p_max)x(p_max) will be splitted. Args: original_dataroot: taget_dataroot: p_size:
(original_dataroot, taget_dataroot, n_channels=3, p_size=800, p_overlap=96, p_max=1000)
| 123 | |
| 124 | |
| 125 | def split_imageset(original_dataroot, taget_dataroot, n_channels=3, p_size=800, p_overlap=96, p_max=1000): |
| 126 | """ |
| 127 | split the large images from original_dataroot into small overlapped images with size (p_size)x(p_size), |
| 128 | and save them into taget_dataroot; only the images with larger size than (p_max)x(p_max) |
| 129 | will be splitted. |
| 130 | Args: |
| 131 | original_dataroot: |
| 132 | taget_dataroot: |
| 133 | p_size: size of small images |
| 134 | p_overlap: patch size in training is a good choice |
| 135 | p_max: images with smaller size than (p_max)x(p_max) keep unchanged. |
| 136 | """ |
| 137 | paths = get_image_paths(original_dataroot) |
| 138 | for img_path in paths: |
| 139 | # img_name, ext = os.path.splitext(os.path.basename(img_path)) |
| 140 | img = imread_uint(img_path, n_channels=n_channels) |
| 141 | patches = patches_from_image(img, p_size, p_overlap, p_max) |
| 142 | imssave(patches, os.path.join(taget_dataroot,os.path.basename(img_path))) |
| 143 | #if original_dataroot == taget_dataroot: |
| 144 | #del img_path |
| 145 | |
| 146 | ''' |
| 147 | # -------------------------------------------- |
nothing calls this directly
no test coverage detected