/Users/lyon/j4p/src/j2d/filters/GaussianSmoothingProcessor.java

1    package j2d.filters; 
2     
3    import j2d.ImageUtils; 
4    import ip.transforms.Gauss; 
5    import j2d.ImageProcessorInterface; 
6     
7    import java.awt.*; 
8     
9    import utils.Timer; 
10    
11    
12   public class GaussianSmoothingProcessor 
13           implements ImageProcessorInterface { 
14    
15       private int kernelWidth; 
16       private double sigma; 
17    
18    
19       public GaussianSmoothingProcessor( 
20               int _kernelWidth, 
21               double _sigma) { 
22    
23           kernelWidth = _kernelWidth; 
24           sigma = _sigma; 
25       } 
26    
27       public Image process(Image img) { 
28           Timer t = new Timer(); 
29           t.start(); 
30           Image i = gaussianSmooth(img); 
31           t.stop(); 
32           double f = t.getElapsedTime(); 
33           System.out.println( 
34                   "did convolution with " 
35                   +kernelWidth 
36                   + "kernel in " 
37                   + f 
38                   +" seconds."); 
39           return i; 
40    
41       } 
42    
43       private Image gaussianSmooth(Image img) { 
44           return ImageUtils.convolution(img, 
45                   Gauss.getGaussKernel( 
46                           kernelWidth, 
47                           kernelWidth, 
48                           sigma)); 
49       } 
50    
51   } 
52    
53