MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / split_imageset

Function split_imageset

ldm/modules/image_degradation/utils_image.py:125–144  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

123
124
125def 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# --------------------------------------------

Callers

nothing calls this directly

Calls 4

get_image_pathsFunction · 0.85
imread_uintFunction · 0.85
patches_from_imageFunction · 0.85
imssaveFunction · 0.85

Tested by

no test coverage detected