From 5a5cfb2b2fe54b0da06d92184c055a100cb505d5 Mon Sep 17 00:00:00 2001 From: mario Date: Wed, 25 Mar 2020 12:25:08 +0100 Subject: [PATCH] moved creating mask entirely to constructor --- simple_sampling.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/simple_sampling.py b/simple_sampling.py index 7ad35b3..b02f06a 100644 --- a/simple_sampling.py +++ b/simple_sampling.py @@ -50,7 +50,8 @@ def create_mapping(self, parameters): vf_angle = np.angle(vf_x + vf_y * 1j) vf_radius = np.abs(vf_x + vf_y * 1j) - self.mask = vf_radius <= num_cells + mask = vf_radius <= num_cells + self.mask = np.tile(mask, (3,1)).transpose() new_radius = self.fii(vf_radius) / degree_per_pixel @@ -102,11 +103,8 @@ def __adjust_image_dims__(image): def distort_image(self, image): image = self.__adjust_image_dims__(image) - - msk = np.tile(self.mask, (3,1)).transpose() - image = np.reshape(image, (self.num_pixels_in, 3)) - output = np.multiply(sparse.dot(self.W, image), msk) + output = np.multiply(sparse.dot(self.W, image), self.mask) output = np.reshape(output, (self.resolution_out, self.resolution_out, 3)).astype(np.uint8) return output