Commit 51bf48ba authored by Taddeüs Kroes's avatar Taddeüs Kroes

Fixed some whitespace issues.

parent e1d45d10
...@@ -8,11 +8,12 @@ class GaussianFilter: ...@@ -8,11 +8,12 @@ class GaussianFilter:
self.scale = scale self.scale = scale
def gaussian(self, x): def gaussian(self, x):
'''Return the value of a 1D Gaussian function for a given x and scale''' """Return the value of a 1D Gaussian function for a given x."""
return exp(-(x ** 2 / (2 * self.scale ** 2))) / (sqrt(2 * pi) * self.scale) return exp(-(x ** 2 / (2 * self.scale ** 2))) \
/ (sqrt(2 * pi) * self.scale)
def get_1d_gaussian_kernel(self): def get_1d_gaussian_kernel(self):
'''Sample a one-dimensional Gaussian function of scale s''' """Sample a one-dimensional Gaussian function of scale s."""
radius = int(ceil(3 * self.scale)) radius = int(ceil(3 * self.scale))
size = 2 * radius + 1 size = 2 * radius + 1
...@@ -25,7 +26,7 @@ class GaussianFilter: ...@@ -25,7 +26,7 @@ class GaussianFilter:
return result return result
def get_filtered_copy(self, image): def get_filtered_copy(self, image):
'''Apply a gaussian blur to an image, to suppress noise.''' """Apply a gaussian blur to an image, to suppress noise."""
kernel = self.get_1d_gaussian_kernel() kernel = self.get_1d_gaussian_kernel()
image = convolve1d(image.data, kernel, axis=0, mode='nearest') image = convolve1d(image.data, kernel, axis=0, mode='nearest')
return GrayscaleImage(None, convolve1d(image, kernel, axis=1, mode='nearest')) return GrayscaleImage(None, convolve1d(image, kernel, axis=1, mode='nearest'))
......
...@@ -8,7 +8,7 @@ class GrayscaleImage: ...@@ -8,7 +8,7 @@ class GrayscaleImage:
if image_path != None: if image_path != None:
self.data = imread(image_path) self.data = imread(image_path)
extension = image_path.split('.',3)[-1] extension = image_path.split('.', 3)[-1]
if extension == "jpg": if extension == "jpg":
self.data = self.data[::-1] self.data = self.data[::-1]
......
...@@ -15,3 +15,4 @@ class Histogram: ...@@ -15,3 +15,4 @@ class Histogram:
def get_bin_index(self, number): def get_bin_index(self, number):
return (number - self.min) / ((self.max - self.min) / len(self.bins)) return (number - self.min) / ((self.max - self.min) / len(self.bins))
...@@ -38,12 +38,12 @@ class LicensePlate: ...@@ -38,12 +38,12 @@ class LicensePlate:
matrix = array([ matrix = array([
[x0, y0, 1, 0, 0, 0, 0, 0, 0], [x0, y0, 1, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, x0, y0, 1, 0, 0, 0], [ 0, 0, 0, x0, y0, 1, 0, 0, 0],
[x1, y1, 1, 0, 0, 0, -M*x0, -M*y1, -M], [x1, y1, 1, 0, 0, 0, -M * x0, -M * y1, -M],
[ 0, 0, 0, x1, y1, 1, 0, 0, 0], [ 0, 0, 0, x1, y1, 1, 0, 0, 0],
[x2, y2, 1, 0, 0, 0, -M*x2, -M*y2, -M], [x2, y2, 1, 0, 0, 0, -M * x2, -M * y2, -M],
[ 0, 0, 0, x2, y2, 1, -N*x2, -N*y2, -N], [ 0, 0, 0, x2, y2, 1, -N * x2, -N * y2, -N],
[x3, y3, 1, 0, 0, 0, 0, 0, 0], [x3, y3, 1, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, x3, y3, 1, -N*x3, -N*y3, -N] [ 0, 0, 0, x3, y3, 1, -N * x3, -N * y3, -N]
]) ])
P = inv(self.get_transformation_matrix(matrix)) P = inv(self.get_transformation_matrix(matrix))
......
class Rectangle: class Rectangle:
def __init__(self, x, y, width, height): def __init__(self, x, y, width, height):
self.x = x; self.x = x
self.y = y; self.y = y
self.width = width; self.width = width
self.height = height; self.height = height
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment