def _merge_high_res_patches(self, neighbor_patches, distances): """Get the high resolution patches by merging the neighboring patches with the given distance as weight. @param neighbor_patches: neighboring high resolution patches @type neighbor_patches: L{numpy.array} @param distances: distance vector associate with the neighboring patches @type distances: L{numpy.array} @return: high resolution patches by merging the neighboring patches @rtype: L{numpy.array} """ patch_number, neighbor_number, patch_dimension = np.shape(neighbor_patches) weights = sr_image_util.normalize(np.exp(-0.25*distances)) weights = weights[:, np.newaxis].reshape(patch_number, neighbor_number, 1) high_res_patches = np.sum(neighbor_patches*weights, axis=1) return high_res_patches
def _merge_high_res_patches(self, neighbor_patches, distances): """Get the high resolution patches by merging the neighboring patches with the given distance as weight. @param neighbor_patches: neighboring high resolution patches @type neighbor_patches: L{numpy.array} @param distances: distance vector associate with the neighboring patches @type distances: L{numpy.array} @return: high resolution patches by merging the neighboring patches @rtype: L{numpy.array} """ patch_number, neighbor_number, patch_dimension = np.shape(neighbor_patches) weights = sr_image_util.normalize(np.exp(distances)) weights = weights[:, np.newaxis].reshape(patch_number, neighbor_number, 1) high_res_patches = np.sum(neighbor_patches*weights, axis=1) return high_res_patches
def test_normalize(self): array = np.array([[1, 2, 3], [4, 5, 6]]) normalized_array = sr_image_util.normalize(array) self.assertTrue( np.array_equal(np.array([1.0, 1.0]), np.sum(normalized_array, 1)))
def test_normalize(self): array = np.array([[1, 2, 3], [4, 5, 6]]) normalized_array = sr_image_util.normalize(array) self.assertTrue(np.array_equal(np.array([1.0, 1.0]), np.sum(normalized_array, 1)))