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

Function patches_from_image

ldm/modules/image_degradation/utils_image.py:93–109  ·  view source on GitHub ↗
(img, p_size=512, p_overlap=64, p_max=800)

Source from the content-addressed store, hash-verified

91
92
93def patches_from_image(img, p_size=512, p_overlap=64, p_max=800):
94 w, h = img.shape[:2]
95 patches = []
96 if w > p_max and h > p_max:
97 w1 = list(np.arange(0, w-p_size, p_size-p_overlap, dtype=np.int))
98 h1 = list(np.arange(0, h-p_size, p_size-p_overlap, dtype=np.int))
99 w1.append(w-p_size)
100 h1.append(h-p_size)
101# print(w1)
102# print(h1)
103 for i in w1:
104 for j in h1:
105 patches.append(img[i:i+p_size, j:j+p_size,:])
106 else:
107 patches.append(img)
108
109 return patches
110
111
112def imssave(imgs, img_path):

Callers 1

split_imagesetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected