From 72169ac1f3d445844c2613d0b1e993101bb6c155 Mon Sep 17 00:00:00 2001 From: Tom Runia Date: Tue, 11 Dec 2018 15:18:41 +0100 Subject: [PATCH] minor fix --- examples/example_lena.py | 64 +++++++++++++++++++++++++++++++++++++ steerable/SCFpyr_PyTorch.py | 2 +- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 examples/example_lena.py diff --git a/examples/example_lena.py b/examples/example_lena.py new file mode 100644 index 0000000..c8d9703 --- /dev/null +++ b/examples/example_lena.py @@ -0,0 +1,64 @@ +# MIT License +# +# Copyright (c) 2018 Tom Runia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to conditions. +# +# Author: Tom Runia +# Date Created: 2018-12-04 + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import argparse +import cv2 + +from steerable.SCFpyr_NumPy import SCFpyr_NumPy +import steerable.utils as utils + +################################################################################ +################################################################################ + +if __name__ == "__main__": + + parser = argparse.ArgumentParser() + parser.add_argument('--image_file', type=str, default='./assets/patagonia.jpg') + parser.add_argument('--batch_size', type=int, default='1') + parser.add_argument('--image_size', type=int, default='200') + parser.add_argument('--pyr_nlevels', type=int, default='5') + parser.add_argument('--pyr_nbands', type=int, default='4') + parser.add_argument('--pyr_scale_factor', type=int, default='2') + parser.add_argument('--visualize', type=bool, default=True) + config = parser.parse_args() + + ############################################################################ + # Build the complex steerable pyramid + + pyr = SCFpyr_NumPy( + height=config.pyr_nlevels, + nbands=config.pyr_nbands, + scale_factor=config.pyr_scale_factor, + ) + + ############################################################################ + # Create a batch and feed-forward + + image = cv2.imread('./assets/lena.jpg', cv2.IMREAD_GRAYSCALE) + image = cv2.resize(image, dsize=(200,200)) + + coeff = pyr.build(image) + + grid = utils.make_grid_coeff(coeff, normalize=True) + + cv2.imwrite('./assets/coeff.png', grid) + cv2.imshow('image', image) + cv2.imshow('coeff', grid) + cv2.waitKey(0) + + \ No newline at end of file diff --git a/steerable/SCFpyr_PyTorch.py b/steerable/SCFpyr_PyTorch.py index 926ed9d..e1b4250 100644 --- a/steerable/SCFpyr_PyTorch.py +++ b/steerable/SCFpyr_PyTorch.py @@ -271,7 +271,7 @@ def _reconstruct_levels(self, coeff, log_rad, Xrcos, Yrcos, angle): dims = np.array(coeff[0][0].shape) lostart = (np.ceil((dims+0.5)/2) - - np.ceil((np.ceil((dims-0.5)/2)+0.5)/2)).astype(np.int32) + np.ceil((np.ceil((dims-0.5)/2)+0.5)/2)).astype(np.int32) loend = lostart + np.ceil((dims-0.5)/2).astype(np.int32) nlog_rad = log_rad[lostart[0]:loend[0], lostart[1]:loend[1]]