def test_gaussian_kernel(self):
     gaussian_kernel = sr_image_util.create_gaussian_kernel(2, 0.1)
     expected_size = (5, 5)
     self.assertEqual(expected_size, np.shape(gaussian_kernel))
     normalized = (np.sum(gaussian_kernel) > 0.99
                   and np.sum(gaussian_kernel) <= 1.01)
     self.assertTrue(normalized)
Exemple #2
0
    def _create_gaussian_kernel(self, radius=2, sigma=1.0):
        """Create a gaussian kernel with the given radius and sigma. Only support radius=1, 2.

        @param radius: radius for gaussian kernel
        @type radius: int
        @param sigma:
        @type sigma: float
        @return: gaussian kernel
        @rtype: L{PIL.ImageFilter.Kernel}
        """
        gaussian_kernel = sr_image_util.create_gaussian_kernel(radius, sigma)
        size = np.shape(gaussian_kernel)
        return Kernel(size, list(gaussian_kernel.flatten()))
Exemple #3
0
 def __init__(self):
     self._method_type = "iccv09"
     self._kernel = sr_image_util.create_gaussian_kernel()
Exemple #4
0
 def __init__(self):
     self._method_type = "iccv09"
     self._kernel = sr_image_util.create_gaussian_kernel()
Exemple #5
0
 def test_gaussian_kernel(self):
     gaussian_kernel = sr_image_util.create_gaussian_kernel(2, 0.1)
     expected_size = (5, 5)
     self.assertEqual(expected_size, np.shape(gaussian_kernel))
     normalized = np.sum(gaussian_kernel) > 0.99 and np.sum(gaussian_kernel) <= 1.01
     self.assertTrue(normalized)