MCPcopy Create free account
hub / github.com/IceClear/StableSR / convfft

Function convfft

scripts/util_image.py:537–551  ·  view source on GitHub ↗

Convolution with FFT Input: im: h1 x w1 x c numpy array weight: h2 x w2 numpy array Output: out: h1 x w1 x c numpy array

(im, weight)

Source from the content-addressed store, hash-verified

535 return {'gradx': gradx, 'grady': grady, 'grad':grad}
536
537def convfft(im, weight):
538 '''
539 Convolution with FFT
540 Input:
541 im: h1 x w1 x c numpy array
542 weight: h2 x w2 numpy array
543 Output:
544 out: h1 x w1 x c numpy array
545 '''
546 axes = (0,1)
547 otf = psf2otf(weight, im.shape[:2])
548 if im.ndim == 3:
549 otf = np.tile(otf[:, :, None], (1,1,im.shape[2]))
550 out = fft.ifft2(fft.fft2(im, axes=axes) * otf, axes=axes).real
551 return out
552
553def psf2otf(psf, shape):
554 """

Callers 1

imgrad_fftFunction · 0.85

Calls 1

psf2otfFunction · 0.85

Tested by

no test coverage detected