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

Function modcrop

ldm/modules/image_degradation/utils_image.py:494–507  ·  view source on GitHub ↗
(img_in, scale)

Source from the content-addressed store, hash-verified

492
493
494def modcrop(img_in, scale):
495 # img_in: Numpy, HWC or HW
496 img = np.copy(img_in)
497 if img.ndim == 2:
498 H, W = img.shape
499 H_r, W_r = H % scale, W % scale
500 img = img[:H - H_r, :W - W_r]
501 elif img.ndim == 3:
502 H, W, C = img.shape
503 H_r, W_r = H % scale, W % scale
504 img = img[:H - H_r, :W - W_r, :]
505 else:
506 raise ValueError('Wrong img ndim: [{:d}].'.format(img.ndim))
507 return img
508
509
510def shave(img_in, border=0):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected