MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / analytic_kernel

Function analytic_kernel

ldm/modules/image_degradation/bsrgan_light.py:48–61  ·  view source on GitHub ↗

Calculate the X4 kernel from the X2 kernel (for proof see appendix in paper)

(k)

Source from the content-addressed store, hash-verified

46
47
48def analytic_kernel(k):
49 """Calculate the X4 kernel from the X2 kernel (for proof see appendix in paper)"""
50 k_size = k.shape[0]
51 # Calculate the big kernels size
52 big_k = np.zeros((3 * k_size - 2, 3 * k_size - 2))
53 # Loop over the small kernel to fill the big one
54 for r in range(k_size):
55 for c in range(k_size):
56 big_k[2 * r:2 * r + k_size, 2 * c:2 * c + k_size] += k[r, c] * k
57 # Crop the edges of the big kernel to ignore very small values and increase run time of SR
58 crop = k_size // 2
59 cropped_big_k = big_k[crop:-crop, crop:-crop]
60 # Normalize to 1
61 return cropped_big_k / cropped_big_k.sum()
62
63
64def anisotropic_Gaussian(ksize=15, theta=np.pi, l1=6, l2=6):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected