Spaces:
Running
on
Zero
Running
on
Zero
File size: 729 Bytes
bfa59ab |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Power by Zongsheng Yue 2021-12-07 21:37:58
import cv2
import numpy as np
def modcrop(im, sf):
h, w = im.shape[:2]
h -= (h % sf)
w -= (w % sf)
return im[:h, :w,]
#-----------------------------------------Transform--------------------------------------------
class Bicubic:
def __init__(self, scale=None, out_shape=None, matlab_mode=True):
self.scale = scale
self.out_shape = out_shape
def __call__(self, im):
out = cv2.resize(
im,
dsize=self.out_shape,
fx=self.scale,
fy=self.scale,
interpolation=cv2.INTER_CUBIC,
)
return out
|