GaussianFilter.py 678 Bytes
Newer Older
1
from GrayscaleImage import GrayscaleImage
2
from scipy.ndimage import gaussian_filter
3
from pylab import ceil, zeros, pi, exp, sqrt, array
4 5 6 7 8

class GaussianFilter:

    def __init__(self, scale):
        self.scale = scale
9

10
    def get_filtered_copy(self, image):
11
        """Apply a gaussian blur to an image, to suppress noise."""
12 13
        image = gaussian_filter(image.data, self.scale)
        return GrayscaleImage(None, image)
14

15
    def filter(self, image):
16
        image.data = gaussian_filter(image.data, self.scale)
17

18 19
    def get_scale(self):
      return self.scale
20

21 22 23
    def set_scale(self, scale):
        self.scale = float(scale)

24
    scale = property(get_scale, set_scale)