|
|
|
@ -4,11 +4,10 @@
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
#import matplotlib.pyplot as plt
|
|
|
|
|
import cv2 as cv
|
|
|
|
|
from skimage import filters as skiflt
|
|
|
|
|
from skimage import restoration as skirest
|
|
|
|
|
from scipy import signal as sig
|
|
|
|
|
#from scipy import signal as sig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Parent class for all the filters
|
|
|
|
@ -142,22 +141,27 @@ class denoise_bilateral(filter):
|
|
|
|
|
super().__init__(img)
|
|
|
|
|
|
|
|
|
|
def apply(self, params):
|
|
|
|
|
|
|
|
|
|
# Standard deviation for grayvalue/color distance.
|
|
|
|
|
# A larger value results in averaging of pixels with larger radiometric differences.
|
|
|
|
|
sigmaColor = float(params["sigmaColor"]
|
|
|
|
|
) if params["sigmaColor"] else 0.1
|
|
|
|
|
|
|
|
|
|
# Standard deviation for range distance.
|
|
|
|
|
# A larger value results in averaging of pixels with larger spatial differences.
|
|
|
|
|
|
|
|
|
|
sigmaSpace = float(params["sigmaSpace"]
|
|
|
|
|
) if params["sigmaSpace"] else 15.0
|
|
|
|
|
channelAxis = int(params["channelAxis"]
|
|
|
|
|
) if params["channelAxis"] else None
|
|
|
|
|
# Repetition of filter application.
|
|
|
|
|
iterations = int(params["iterations"]) if params["iterations"] else 1
|
|
|
|
|
|
|
|
|
|
#print("with params: sigma_color: " + str(sigmaColor) +
|
|
|
|
|
# " sigma_spatial: " + str(sigmaSpace) + " channel_axis: " +
|
|
|
|
|
# str(channelAxis) + " iterations: " + str(iterations))
|
|
|
|
|
# " sigma_spatial: " + str(sigmaSpace) + " iterations: " + str(iterations))
|
|
|
|
|
|
|
|
|
|
for i in range(iterations):
|
|
|
|
|
self.img = skirest.denoise_bilateral(
|
|
|
|
|
self.img, sigma_color=sigmaColor,
|
|
|
|
|
sigma_spatial=sigmaSpace, channel_axis=channelAxis)
|
|
|
|
|
sigma_spatial=sigmaSpace, channel_axis=None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class denoise_tv_chambolle(filter):
|
|
|
|
@ -171,16 +175,18 @@ class denoise_tv_chambolle(filter):
|
|
|
|
|
super().__init__(img)
|
|
|
|
|
|
|
|
|
|
def apply(self, params):
|
|
|
|
|
|
|
|
|
|
# Denoising weight. The greater weight, the more denoising.
|
|
|
|
|
weight = float(params["weight"]) if params["weight"] else 0.1
|
|
|
|
|
channelAxis = int(params["channelAxis"]
|
|
|
|
|
) if params["channelAxis"] else None
|
|
|
|
|
|
|
|
|
|
# Maximal number of iterations used for the optimization.
|
|
|
|
|
iterations = int(params["iterations"]) if params["iterations"] else 1
|
|
|
|
|
|
|
|
|
|
#print("with params: weight: " + str(weight) +
|
|
|
|
|
# " channel_axis: " + str(channelAxis) + " iterations: " + str(iterations))
|
|
|
|
|
# " iterations: " + str(iterations))
|
|
|
|
|
for i in range(iterations):
|
|
|
|
|
self.img = skirest.denoise_tv_chambolle(
|
|
|
|
|
self.img, weight=weight, channel_axis=channelAxis)
|
|
|
|
|
self.img, weight=weight, channel_axis=None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class sharpen(filter):
|
|
|
|
@ -235,6 +241,7 @@ class unsharp_mask_scikit(filter):
|
|
|
|
|
def apply(self, params):
|
|
|
|
|
radius = int(params["radius"]) if params["radius"] else 3
|
|
|
|
|
amount = float(params["amount"]) if params["amount"] else 1
|
|
|
|
|
# TODO: i have no idea what this is or how to use it
|
|
|
|
|
channelAxis = int(params["channelAxis"]
|
|
|
|
|
) if params["channelAxis"] else None
|
|
|
|
|
|
|
|
|
|