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

Function analytic_kernel

ldm/modules/image_degradation/bsrgan.py:49–62  ·  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

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