def main(): # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("image", help="path to the image file") args = ap.parse_args() image = cv2.imread(args.image) image = resize(image, width=2000) pts = detect_englobing_polygon(image) pts = [tuple(*el) for el in pts] warped = process(image, pts) pts = np.array(pts, np.int32) pts = pts.reshape((-1,1,2)) image = cv2.polylines(image,[pts],True,(0,255,255), 10) cv2.imshow("Original", resize(image, width=1000)) cv2.imshow("Warped", resize(warped, width=1000)) cv2.waitKey(0)
def main(): import sys # get image img = cv2.imread(sys.argv[1]) img = resize(img, width=500) cv2.namedWindow('test') fs = CvFilterStack(img, 'test') fs.filters = [GreyFilter(), GaussianFilter(), CannyFilter()] # fs.filters = [ResizeFilter(), GreyFilter(), GaussianFilter(), CannyFilter()] fs.create_trackbars() fs.imshow() cv2.waitKey(0)
def test_resize(): array = np.ndarray(shape=(2000, 3000), dtype='uint8') try: resize(array) assert False, "should have raise exception" except ValueError as e: pass assert (200, 300) == resize(array, ratio=0.1).shape[:2] assert (200, 300) == resize(array, height=200).shape[:2] assert (200, 300) == resize(array, width=300).shape[:2] assert (220, 330) == resize(array, height=220, width=330).shape[:2]
def apply(self, image): return resize(image, ratio=(self.ratio + 1) * .1)