basicsr.utils.img_process_util

class basicsr.utils.img_process_util.USMSharp(radius=50, sigma=0)[source]

Bases: Module

forward(img, weight=0.5, threshold=10)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
basicsr.utils.img_process_util.filter2D(img, kernel)[source]

PyTorch version of cv2.filter2D

Parameters:
  • img (Tensor) – (b, c, h, w)

  • kernel (Tensor) – (b, k, k)

basicsr.utils.img_process_util.usm_sharp(img, weight=0.5, radius=50, threshold=10)[source]

USM sharpening.

Input image: I; Blurry image: B. 1. sharp = I + weight * (I - B) 2. Mask = 1 if abs(I - B) > threshold, else: 0 3. Blur mask: 4. Out = Mask * sharp + (1 - Mask) * I

Parameters:
  • img (Numpy array) – Input image, HWC, BGR; float32, [0, 1].

  • weight (float) – Sharp weight. Default: 1.

  • radius (float) – Kernel size of Gaussian blur. Default: 50.

  • threshold (int) –