|
|
@ -8,9 +8,10 @@ import cv2 as cv
|
|
|
|
from skimage import filters as skiflt
|
|
|
|
from skimage import filters as skiflt
|
|
|
|
from skimage import restoration as skirest
|
|
|
|
from skimage import restoration as skirest
|
|
|
|
from skimage import morphology as skimorph
|
|
|
|
from skimage import morphology as skimorph
|
|
|
|
# from scipy import signal as sig
|
|
|
|
from scipy import ndimage
|
|
|
|
from PIL import Image, ImageFilter
|
|
|
|
from PIL import Image, ImageFilter
|
|
|
|
import bm3d
|
|
|
|
import bm3d
|
|
|
|
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class filter:
|
|
|
|
class filter:
|
|
|
@ -133,7 +134,7 @@ class nlmeans(filter):
|
|
|
|
# Size of patches used for denoising
|
|
|
|
# Size of patches used for denoising
|
|
|
|
patch_size = int(params["patch_size"]) if params["patch_size"] else 5
|
|
|
|
patch_size = int(params["patch_size"]) if params["patch_size"] else 5
|
|
|
|
|
|
|
|
|
|
|
|
# Distance in pixels where to search patches
|
|
|
|
# Distance in pixels where to search for patches
|
|
|
|
patch_distance = int(params["patch_distance"]
|
|
|
|
patch_distance = int(params["patch_distance"]
|
|
|
|
) if params["patch_distance"] else 3
|
|
|
|
) if params["patch_distance"] else 3
|
|
|
|
|
|
|
|
|
|
|
@ -210,7 +211,7 @@ class unsharp_mask_scikit(filter):
|
|
|
|
str(radius) + " amount: " + str(amount))
|
|
|
|
str(radius) + " amount: " + str(amount))
|
|
|
|
self.img = skiflt.unsharp_mask(self.img, radius=radius,
|
|
|
|
self.img = skiflt.unsharp_mask(self.img, radius=radius,
|
|
|
|
amount=amount, channel_axis=None)
|
|
|
|
amount=amount, channel_axis=None)
|
|
|
|
self.img = np.uint8(self.img * 255.0) # converting back to uintknapsack
|
|
|
|
self.img = np.uint8(self.img * 255.0) # converting back to uint
|
|
|
|
|
|
|
|
|
|
|
|
# ------------------- EDGE DETECTION FILTERS -------------------#
|
|
|
|
# ------------------- EDGE DETECTION FILTERS -------------------#
|
|
|
|
|
|
|
|
|
|
|
@ -319,6 +320,16 @@ class binarize(filter):
|
|
|
|
self.img = cv.threshold(self.img, threshold, maxval, type)[1]
|
|
|
|
self.img = cv.threshold(self.img, threshold, maxval, type)[1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class binarize_otsu(filter):
|
|
|
|
|
|
|
|
''' Otsu binarization filter from opencv.
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
def init(self, img):
|
|
|
|
|
|
|
|
super().__init__(img)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def apply(self, _):
|
|
|
|
|
|
|
|
self.img = cv.threshold(self.img, 0, 255, cv.THRESH_BINARY + cv.THRESH_OTSU)[1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class add_margin(filter):
|
|
|
|
class add_margin(filter):
|
|
|
|
def init(self, img):
|
|
|
|
def init(self, img):
|
|
|
|
super().__init__(img)
|
|
|
|
super().__init__(img)
|
|
|
|