Exemplo n.º 1
0
 def testBasicUsage(self):
     with self.session():
         image = np.array([[[5], [2], [4], [0], [3]]]).astype(np.float32)
         tabulated_functions = np.array([[10, 11, 12, 13, 14, 15, 16,
                                          17]]).astype(np.float32)
         out_image = augmentation_ops.apply_tabulated_functions(
             image, tabulated_functions)
         self.assertAllEqual(np.array([[[15], [12], [14], [10], [13]]]),
                             out_image.eval())
 def testInterpolationExtrapolation(self):
   with self.session():
     image = np.array([[[-1], [2.7], [4.2], [0.3], [8.5]]]).astype(np.float32)
     tabulated_functions = np.array([[10, 11, 12, 13, 14, 15, 16,
                                      17]]).astype(np.float32)
     out_image = augmentation_ops.apply_tabulated_functions(
         image, tabulated_functions)
     self.assertAllClose(
         np.array([[[9], [12.7], [14.2], [10.3], [18.5]]]), out_image.eval())
Exemplo n.º 3
0
 def testMult(self):
     with self.session():
         image = np.array([[[5, 2], [2, 4], [4, 1], [0, 1],
                            [3, 0]]]).astype(np.float32)
         tabulated_functions = np.array([[10, 11, 12, 13, 14, 15, 16, 17],
                                         [0, 10, 20, 30, 40, 50, 60,
                                          70]]).astype(np.float32)
         out_image = augmentation_ops.apply_tabulated_functions(
             image, tabulated_functions)
         self.assertAllEqual(
             np.array([[[15, 20], [12, 40], [14, 10], [10, 10], [13, 0]]]),
             out_image.eval())
Exemplo n.º 4
0
 def testShape(self):
     image = np.random.random([10, 7, 3]).astype(np.float32)
     tabulated_functions = np.random.random([3, 256]).astype(np.float32)
     out_image = augmentation_ops.apply_tabulated_functions(
         image, tabulated_functions)
     self.assertAllEqual(out_image.get_shape(), image.shape)