Commit faf30fd9 authored by Jayke Meijer's avatar Jayke Meijer

Checnged Gaussian to standard method of NDimage.

parent 18251667
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
\title{Local Binary Patterns} \title{Local Binary Patterns}
\begin{document} \begin{document}
\section{Wat zijn Local Binary Patterns} \section{Wat zijn Local Binary Patterns}
\begin{frame} \begin{frame}
......
from GrayscaleImage import GrayscaleImage from GrayscaleImage import GrayscaleImage
from scipy.ndimage import convolve1d from scipy.ndimage import gaussian_filter
from pylab import ceil, zeros, pi, exp, sqrt, array from pylab import ceil, zeros, pi, exp, sqrt, array
class GaussianFilter: class GaussianFilter:
...@@ -27,14 +27,11 @@ class GaussianFilter: ...@@ -27,14 +27,11 @@ class GaussianFilter:
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() image = gaussian_filter(image.data, self.scale)
image = convolve1d(image.data, kernel, axis=0, mode='nearest') return GrayscaleImage(None, image)
return GrayscaleImage(None, convolve1d(image, kernel, axis=1, mode='nearest'))
def filter(self, image): def filter(self, image):
kernel = self.get_1d_gaussian_kernel() image.data = gaussian_filter(image.data, self.scale)
image.data = convolve1d(image.data, kernel, axis=0, mode='nearest')
image.data = convolve1d(image.data, kernel, axis=1, mode='nearest')
def get_scale(self): def get_scale(self):
return self.scale return self.scale
......
from FilterNoise import GaussianFilter from GaussianFilter import GaussianFilter
from GrayscaleImage import GrayscaleImage from GrayscaleImage import GrayscaleImage
image = GrayscaleImage('../images/plate.png') image = GrayscaleImage('../images/plate.png')
......
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