Removed unnecessary filter parameters.
This commit is contained in:
@ -10,15 +10,13 @@ import cv2 as cv
|
|||||||
|
|
||||||
# Parent class for all the filters
|
# Parent class for all the filters
|
||||||
class filter:
|
class filter:
|
||||||
def __init__(self, input_file, output_file, img):
|
def __init__(self, img):
|
||||||
self.input_file = input_file
|
|
||||||
self.output_file = output_file
|
|
||||||
self.img = img
|
self.img = img
|
||||||
|
|
||||||
|
|
||||||
class average(filter):
|
class average(filter):
|
||||||
def __init__(self, input_file, output_file, img):
|
def __init__(self, img):
|
||||||
super().__init__(input_file, output_file, img)
|
super().__init__(img)
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
kernel = np.ones((3, 3), np.float32) / 9
|
kernel = np.ones((3, 3), np.float32) / 9
|
||||||
@ -26,51 +24,52 @@ class average(filter):
|
|||||||
|
|
||||||
|
|
||||||
class blur(filter):
|
class blur(filter):
|
||||||
def __init__(self, input_file, output_file, img):
|
def __init__(self, img):
|
||||||
super().__init__(input_file, output_file, img)
|
super().__init__(img)
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
self.img = cv.blur(self.img, (3, 3))
|
self.img = cv.blur(self.img, (3, 3))
|
||||||
|
|
||||||
|
|
||||||
class gaussian(filter):
|
class gaussian(filter):
|
||||||
def __init__(self, input_file, output_file, img):
|
def __init__(self, img):
|
||||||
super().__init__(input_file, output_file, img)
|
super().__init__(img)
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
self.img = cv.GaussianBlur(self.img, (3, 3), 0)
|
self.img = cv.GaussianBlur(self.img, (3, 3), 0)
|
||||||
|
|
||||||
|
|
||||||
class median(filter):
|
class median(filter):
|
||||||
def __init__(self, input_file, output_file, img):
|
def __init__(self, img):
|
||||||
super().__init__(input_file, output_file, img)
|
super().__init__(img)
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
self.img = cv.medianBlur(self.img, 1)
|
self.img = cv.medianBlur(self.img, 1)
|
||||||
|
|
||||||
|
|
||||||
class bilateral(filter):
|
class bilateral(filter):
|
||||||
def __init__(self, input_file, output_file, img):
|
def __init__(self, img):
|
||||||
super().__init__(input_file, output_file, img)
|
super().__init__(img)
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
self.img = cv.bilateralFilter(self.img, 1, 75, 75)
|
self.img = cv.bilateralFilter(self.img, 1, 75, 75)
|
||||||
|
|
||||||
|
|
||||||
class denoise(filter):
|
class denoise(filter):
|
||||||
def __init__(self, input_file, output_file, img):
|
def __init__(self, img):
|
||||||
super().__init__(input_file, output_file, img)
|
super().__init__(img)
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
pass
|
pass
|
||||||
#does not work
|
#does not work
|
||||||
#img = cv.cvtColor(self.img, cv.COLOR_GRAY2BGR)
|
self.img = np.uint8(self.img)
|
||||||
#self.img = cv.fastNlMeansDenoisingColored(img, h=3)
|
self.img = cv.fastNlMeansDenoising(
|
||||||
|
self.img, h=10, searchWindowSize=21, templateWindowSize=7)
|
||||||
|
|
||||||
|
|
||||||
class sharpen(filter):
|
class sharpen(filter):
|
||||||
def __init__(self, input_file, output_file, img):
|
def __init__(self, img):
|
||||||
super().__init__(input_file, output_file, img)
|
super().__init__(img)
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
kernel = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]])
|
kernel = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]])
|
||||||
@ -78,8 +77,8 @@ class sharpen(filter):
|
|||||||
|
|
||||||
|
|
||||||
class erode(filter):
|
class erode(filter):
|
||||||
def __init__(self, input_file, output_file, img):
|
def __init__(self, img):
|
||||||
super().__init__(input_file, output_file, img)
|
super().__init__(img)
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
kernel = np.ones((3, 3), np.uint8)
|
kernel = np.ones((3, 3), np.uint8)
|
||||||
@ -87,8 +86,8 @@ class erode(filter):
|
|||||||
|
|
||||||
|
|
||||||
class dilate(filter):
|
class dilate(filter):
|
||||||
def __init__(self, input_file, output_file, img):
|
def __init__(self, img):
|
||||||
super().__init__(input_file, output_file, img)
|
super().__init__(img)
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
kernel = np.ones((3, 3), np.uint8)
|
kernel = np.ones((3, 3), np.uint8)
|
||||||
@ -97,8 +96,8 @@ class dilate(filter):
|
|||||||
|
|
||||||
# Erosion, then dilatation
|
# Erosion, then dilatation
|
||||||
class opening(filter):
|
class opening(filter):
|
||||||
def __init__(self, input_file, output_file, img):
|
def __init__(self, img):
|
||||||
super().__init__(input_file, output_file, img)
|
super().__init__(img)
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
kernel = cv.getStructuringElement(cv.MORPH_RECT, (3, 3))
|
kernel = cv.getStructuringElement(cv.MORPH_RECT, (3, 3))
|
||||||
@ -107,8 +106,8 @@ class opening(filter):
|
|||||||
|
|
||||||
# Dilatation, then erosion
|
# Dilatation, then erosion
|
||||||
class closing(filter):
|
class closing(filter):
|
||||||
def __init__(self, input_file, output_file, img):
|
def __init__(self, img):
|
||||||
super().__init__(input_file, output_file, img)
|
super().__init__(img)
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
kernel = cv.getStructuringElement(cv.MORPH_RECT, (3, 3))
|
kernel = cv.getStructuringElement(cv.MORPH_RECT, (3, 3))
|
||||||
|
Reference in New Issue
Block a user