GaussianFilter.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # import
  2. # ------------------------------------------------------------------------------------------
  3. from . import Processing
  4. from .. import image
  5. import colour, copy
  6. from scipy import ndimage
  7. import numpy as np
  8. # ------------------------------------------------------------------------------------------
  9. # MIAM project 2020
  10. # ------------------------------------------------------------------------------------------
  11. # author: remi.cozot@univ-littoral.fr
  12. # ------------------------------------------------------------------------------------------
  13. class GaussianFilter(Processing.Processing):
  14. """description of class"""
  15. def __init__(self):
  16. pass
  17. def compute(self, img, **kwargs):
  18. """
  19. compute method:
  20. @params:
  21. self - Required: (MIAM.processing.LaplaceFilter)
  22. img: - Required: image on which Laplace is computed (MIAM.image.IMAGE)
  23. kwargs - Optionnal: optionnal parameter (dict)
  24. 'sigma'= scalar or sequence of scalars
  25. """
  26. res = copy.deepcopy(img)
  27. # taking into account optional parameters
  28. if not kwargs: kwargs = {'sigma': 10} # default value
  29. sigma = kwargs['sigma']
  30. # compute lapalce filter
  31. res.colorData = imgGaussian=ndimage.gaussian_filter(res.colorData,sigma, mode='reflect', cval=0.0)
  32. return res