/Users/lyon/j4p/src/j2d/edge/FreiChenProcessor.java

1    /* 
2     * Created by DocJava, Inc. 
3     * User: lyon 
4     * Date: Mar 1, 2003 
5     * Time: 9:45:14 AM 
6     */ 
7    package j2d.edge; 
8     
9    import j2d.ImageUtils; 
10   import j2d.ImageProcessorInterface; 
11   import math.Mat2; 
12    
13   import java.awt.*; 
14    
15   public class FreiChenProcessor 
16           implements ImageProcessorInterface { 
17       public FreiChenProcessor() { 
18       } 
19    
20       public Image process(Image img) { 
21           float r2 = (float) Math.sqrt(2); 
22           float k1[][] = { 
23               {1, 0, -1}, 
24               {r2, 0, -r2}, 
25               {1, 0, -1} 
26           }; 
27    
28           float k2[][] = { 
29               {-1, -r2, -1}, 
30               {0, 0, 0}, 
31               {1, r2, 1} 
32           }; 
33           double s = 1 / (2 + r2); 
34           Mat2.scale(k1, s); 
35           Mat2.scale(k2, s); 
36           //printMaple(k1,"k1="); 
37           //printMaple(k2,"k2="); 
38           img = ImageUtils.convolution(img, k1); 
39           img = ImageUtils.convolution(img, k2); 
40    
41           return ImageUtils.combineBands(2f, 2f, 2f, img); 
42       } 
43    
44    
45   } 
46