Skip to content
Snippets Groups Projects
Commit 21ad18a2 authored by niklasBr's avatar niklasBr
Browse files

Changed names of methods in KernelFactory.py and Image.py to snake case

parent 4bbfd259
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ class Image:
self.pixels = pixels
@icontract.require(lambda filename: filename.endswith(Image.PGM_FILE_EXTENSION), "provided filename should be in .pgm format")
def readFromFile(self, filename):
def read_from_file(self, filename):
file = open(filename, "r")
content = file.readlines()
content = Image.remove_comments(content)
......
......@@ -4,17 +4,17 @@ import icontract
class KernelFactory:
@staticmethod
def createVerticalPrewittKernel():
def create_vertical_prewitt_kernel():
return [-1, -1, -1, 0, 0, 0, 1, 1, 1]
@staticmethod
def createHorizontalPrewittKernel():
def create_horizontal_prewitt_kernel():
return [-1, 0, 1, -1, 0, 1, -1, 0, 1]
@staticmethod
@icontract.require(lambda radius: isinstance(radius, int) is True, f"wrong datatype for radius provided")
def createBoxFilter(radius):
def create_box_filter(radius):
dimension = ((2 * radius) + 1) ** 2
return [1 / dimension for _ in range(dimension)]
......@@ -7,14 +7,14 @@ from ClampingBorderBehavior import ClampingPaddingBorderBehavior
def aufgabe1():
d = Image()
d.readFromFile("Bild1.pgm")
d.read_from_file("Bild1.pgm")
zero_p_bb = ZeroPaddingBorderBehavior()
clamping_p_bb = ClampingPaddingBorderBehavior()
horizontal_pk = Kernel(KernelFactory().createHorizontalPrewittKernel())
vertical_pk = Kernel(KernelFactory().createVerticalPrewittKernel())
horizontal_pk = Kernel(KernelFactory().create_horizontal_prewitt_kernel())
vertical_pk = Kernel(KernelFactory().create_vertical_prewitt_kernel())
d.convolve(horizontal_pk, zero_p_bb, "./images/Ergebnis1-horizontal(zero-padding).pgm")
d.convolve(horizontal_pk, clamping_p_bb, "./images/Ergebnis1-horizontal(clamping-padding).pgm")
......@@ -27,10 +27,10 @@ def aufgabe2():
clamping_p_bb = ClampingPaddingBorderBehavior()
e = Image()
e.readFromFile("Bild2.pgm")
boxfilter_3 = Kernel(KernelFactory().createBoxFilter(1))
boxfilter_11 = Kernel(KernelFactory().createBoxFilter(5))
boxfilter_27 = Kernel(KernelFactory().createBoxFilter(13))
e.read_from_file("Bild2.pgm")
boxfilter_3 = Kernel(KernelFactory().create_box_filter(1))
boxfilter_11 = Kernel(KernelFactory().create_box_filter(5))
boxfilter_27 = Kernel(KernelFactory().create_box_filter(13))
e.convolve(boxfilter_3, zero_p_bb, "./images/Ergebnis2-3(zero-bb).pgm")
e.convolve(boxfilter_3, clamping_p_bb, "./images/Ergebnis2-3(clamping_p_bb).pgm")
e.convolve(boxfilter_11, clamping_p_bb, "./images/Ergebnis2-11.pgm")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment