From 306a4c1e78ad43249182307123c35ab35a5fdf14 Mon Sep 17 00:00:00 2001 From: Qintefbr8 <1104320156@qq.com> Date: Sat, 6 Nov 2021 18:44:35 +0800 Subject: [PATCH] ADD file via upload --- simplepreprocessor.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 simplepreprocessor.py diff --git a/simplepreprocessor.py b/simplepreprocessor.py new file mode 100644 index 0000000..e089fb4 --- /dev/null +++ b/simplepreprocessor.py @@ -0,0 +1,16 @@ +import cv2 +class SimplePreprocessor: + def __init__(self, width, height, inter=cv2.INTER_AREA): + self.width = width + self.height = height + self.inter = inter + + def preprocess(self, image): + return cv2.resize(image, (self.width, self.height), interpolation=self.inter) + +if __name__ == '__main__': + s = SimplePreprocessor(32, 32) + img = cv2.imread('D:/python/LearningMaterial/PetImages/Cat/9759.jpg') + cv2.imshow('src', img) + cv2.imshow("resize", s.preprocess(img)) + cv2.waitKey(0)