/Users/lyon/j4p/src/ip/color/Yiq.java

1    package ip.color; 
2     
3    import ip.gui.frames.ColorFrame; 
4    import math.Mat3; 
5     
6     
7    public class Yiq extends FloatPlane { 
8     
9    // for ntsc rgb, use 
10       double A[][] = { 
11           {0.2989, 0.5866, 0.1144}, 
12           {0.5959, -0.2741, -0.3218}, 
13           {0.2113, -0.5227, 0.3113} 
14       }; 
15    
16    
17       Mat3 rgbn2yiqMat = new Mat3(A); 
18       Mat3 yiq2rgbnMat = rgbn2yiqMat.invert(); 
19    
20       public Yiq(ColorFrame _cf) { 
21           super(_cf); 
22       } 
23    
24       public void fromRgb() { 
25           convertSpace(rgbn2yiqMat); 
26           System.out.println("yiq"); 
27           rgbn2yiqMat.print(); 
28       } 
29    
30       /** 
31        * if ((44 < Y < 223) && (0 < I  < 64)) 
32        * then we have skin 
33        */ 
34       public void skinChromaKey() { 
35           for (int x = 0; x < r.length; x++) 
36               for (int y = 0; y < r[0].length; y++) { 
37                   if ( 
38                           (r[x][y] < 223) && 
39                           (r[x][y] > 44) && 
40                           (g[x][y] > 0) && 
41                           (g[x][y] < 64) 
42                   ) 
43                       setPixel(x, y, 255); 
44                   else 
45                       setPixel(x, y, 0); 
46               } 
47    
48       } 
49    
50       public void setPixel(int x, int y, int v) { 
51           r[x][y] = v; 
52           g[x][y] = v; 
53           b[x][y] = v; 
54       } 
55    
56       public void toRgb() { 
57           convertSpace(yiq2rgbnMat); 
58       } 
59    
60   } 
61    
62    
63    
64    
65    
66    
67    
68