changes
authorjzhou <jzhou>
Mon, 16 Nov 2009 02:29:53 +0000 (02:29 +0000)
committerjzhou <jzhou>
Mon, 16 Nov 2009 02:29:53 +0000 (02:29 +0000)
12 files changed:
Robust/src/Benchmarks/Scheduling/Tracking/IDX.java [new file with mode: 0644]
Robust/src/Benchmarks/Scheduling/Tracking/IXL.java
Robust/src/Benchmarks/Scheduling/Tracking/IXLM.java
Robust/src/Benchmarks/Scheduling/Tracking/IXLMR.java [new file with mode: 0644]
Robust/src/Benchmarks/Scheduling/Tracking/IXLR.java [new file with mode: 0644]
Robust/src/Benchmarks/Scheduling/Tracking/IYL.java
Robust/src/Benchmarks/Scheduling/Tracking/IYLM.java
Robust/src/Benchmarks/Scheduling/Tracking/IYLMR.java [new file with mode: 0644]
Robust/src/Benchmarks/Scheduling/Tracking/IYLR.java [new file with mode: 0644]
Robust/src/Benchmarks/Scheduling/Tracking/Lambda.java
Robust/src/Benchmarks/Scheduling/Tracking/TrackDemo.java
Robust/src/Benchmarks/Scheduling/Tracking/TrackingBench.java

diff --git a/Robust/src/Benchmarks/Scheduling/Tracking/IDX.java b/Robust/src/Benchmarks/Scheduling/Tracking/IDX.java
new file mode 100644 (file)
index 0000000..f508a21
--- /dev/null
@@ -0,0 +1,130 @@
+public class IDX {
+    flag toprocess;
+    flag tomergeIDX;
+    flag finish;
+    
+    /* current processing image related */
+    float[] m_image;
+    int m_rows;
+    int m_cols;
+    int m_r;
+    
+    /* results related */
+    int m_rows_rs;
+    int m_rows_re;
+    int m_cols_r;
+    int[] m_ind;
+    
+    /* benchmark constants */
+    public int N_FEA;
+    
+    /* id indicating the piece # */
+    int m_id;  
+    int m_range;
+
+    /* constructor */
+    public IDX(int nfea,
+               int id,
+               int range,
+               float[] data,
+               int rows,
+               int cols,
+               int r) {
+      this.N_FEA = nfea;
+      
+      this.m_id = id;
+      this.m_range = range;
+      
+      this.m_image = data;
+      this.m_rows = rows;
+      this.m_cols = cols;
+      this.m_r = r;
+
+      this.m_rows_rs = this.m_id * this.m_range;
+      this.m_rows_re = (this.m_id + 1) * this.m_range;
+      this.m_cols_r = cols;
+      
+      this.m_ind = new int[(this.m_rows_re - this.m_rows_rs) * this.m_cols_r];
+    }
+    
+    public int getR() {
+      return this.m_r;
+    }
+    
+    public int getRows() {
+      return this.m_rows;
+    }
+    
+    public int getCols() {
+      return this.m_cols;
+    }
+    
+    public float[] getImage() {
+      return this.m_image;
+    }
+    
+    public int[] getInd() {
+      return this.m_ind;
+    }
+    
+    public int getRowsRS() {
+      return this.m_rows_rs;
+    }
+    
+    public int getRowsRE() {
+      return this.m_rows_re;
+    }
+    
+    public int getColsR() {
+      return this.m_cols_r;
+    }
+    
+    public void fSortIndices() {
+      int i, j, k, startRow, endRow;
+      int[] ind;
+      int rows_i, cols_i;
+      float[] image;
+
+      image = this.m_image;
+      
+      rows_i = this.m_rows;
+      cols_i = this.m_cols;
+      ind = this.m_ind;
+
+      startRow = this.m_rows_rs;  
+      endRow = this.m_rows_re;
+
+      int ii = 0;
+      for(k=0; k<cols_i; k++) {
+        for(i=0; i<rows_i; i++) {
+          float local = image[i * cols_i + k];
+          ii = 0;
+          for(j=startRow; j<endRow; j++) {
+            if(local <= image[j*cols_i+k]) {
+              ind[ii * cols_i + k]++;
+            }
+            ii++;
+          }
+        }
+      }
+    }
+    
+    public void printImage() {
+      //    result validation
+      for(int i=0; i<this.m_rows; i++) {
+          for(int j=0; j<this.m_cols; j++) {
+              System.printI((int)(this.m_image[i * this.m_cols + j]*10));
+          }
+      }
+    }
+    
+    public void printInd() {
+      //    result validation
+      System.printI(44444444);
+      for(int i=0; i<this.m_rows_re-this.m_rows_rs; i++) {
+          for(int j=0; j<this.m_cols_r; j++) {
+              System.printI((int)(this.m_ind[i * this.m_cols_r + j]*10));
+          }
+      }
+    }
+}
\ No newline at end of file
index ff55ceb2e22c758ecb6b0dcdf9a2e9681080ad96..7693fcd83e4a246b8fa6e51467ba213300fecbf5 100644 (file)
@@ -13,9 +13,7 @@ public class IXL {
     int m_rows_rs;
     int m_rows_re;
     int m_cols_r;
-    
-    /* processing type */
-    int m_id_t; // 0--Ipyr1; 1--Ipyr2;
+
     /* id indicating the piece # */
     int m_id;  
     int m_range;
@@ -23,13 +21,11 @@ public class IXL {
     /* constructor */
     public IXL(int id,
                int range,
-               int tid,
                float[] data,
                int rows,
                int cols) {
       this.m_id = id;
       this.m_range = range;
-      this.m_id_t = tid;
       this.m_image = data;
       this.m_rows = rows;
       this.m_cols = cols;
@@ -39,10 +35,6 @@ public class IXL {
       return this.m_id;
     }
     
-    public int getIdT() {
-      return this.m_id_t;
-    }
-    
     public float[] getResult() {
       return this.m_result;
     }
index b6a99f89baa6de8bd3c97af186f1beb3ce85a2fa..d4dabb1edbd5d3a672cfd52517e45c6d307de3ac 100644 (file)
@@ -1,6 +1,6 @@
 public class IXLM {
     flag tomergeIXL;
-    flag toaddIXL;
+    flag tocalcT;
     flag finish;
     
     /* current processing image related */
@@ -15,16 +15,11 @@ public class IXLM {
     
     int m_counter;
     
-    /* processing type */
-    int m_id_t; // 0--Ipyr1; 1--Ipyr2;
-    
     /* constructor */
-    public IXLM(int tid,
-                int counter,
+    public IXLM(int counter,
                 float[] data,
                 int rows,
                 int cols) {
-      this.m_id_t = tid;
       this.m_counter = counter;
       this.m_rows = this.m_rows_r = rows;
       this.m_cols = this.m_cols_r = cols;
@@ -32,10 +27,6 @@ public class IXLM {
       this.m_result = new float[rows * cols];
     }
     
-    public int getIdT() {
-      return this.m_id_t;
-    }
-    
     public int getRows() {
       return this.m_rows;
     }
diff --git a/Robust/src/Benchmarks/Scheduling/Tracking/IXLMR.java b/Robust/src/Benchmarks/Scheduling/Tracking/IXLMR.java
new file mode 100644 (file)
index 0000000..081a498
--- /dev/null
@@ -0,0 +1,146 @@
+public class IXLMR {
+    flag tomergeIXLR;
+    flag tocalcT;
+    flag finish;
+    
+    /* current processing image related */
+    float[] m_image;
+    int m_rows;
+    int m_cols;
+    
+    /* current processing image related */
+    float[] m_result;
+    int m_rows_r;
+    int m_cols_r;
+    
+    int m_counter;
+    
+    /* constructor */
+    public IXLMR(int counter,
+                 float[] data,
+                 int rows,
+                 int cols) {
+      this.m_counter = counter;
+      this.m_rows = this.m_rows_r = rows;
+      this.m_cols = this.m_cols_r = cols;
+      this.m_image = data;
+      this.m_result = new float[rows * cols];
+    }
+    
+    public int getRows() {
+      return this.m_rows;
+    }
+    
+    public int getCols() {
+      return this.m_cols;
+    }
+    
+    public float[] getImage() {
+      return this.m_image;
+    }
+    
+    public int getRowsR() {
+      return this.m_rows_r;
+    }
+    
+    public int getColsR() {
+      return this.m_cols_r;
+    }
+    
+    public float[] getResult() {
+      return this.m_result;
+    }
+    
+    public boolean addCalcSobelResult(IXLR ixl) {
+      int startRow = ixl.getRowsRS();
+      int endRow = ixl.getRowsRE();
+      int i, j, k, cols;
+      float[] image, r;
+      
+      image = this.m_result;
+      this.m_counter--;
+      cols = this.m_cols_r;
+      
+      // clone data piece      
+      r = ixl.getResult();
+      k = 0;
+      for(i = startRow; i < endRow; i++) {
+        for(j = 0; j < cols; j++) {
+          image[i * cols + j] = r[k * cols + j];
+        }
+        k++;
+      }
+      
+      return (0 == this.m_counter);
+    }
+    
+    public void calcSobel_dX() {
+      int rows_k1, cols_k1, rows_k2, cols_k2;
+      int[] kernel_1, kernel_2;
+      float temp;
+      int kernelSize, startCol, endCol, halfKernel, startRow, endRow;
+      int k, i, j, kernelSum_1, kernelSum_2;
+      float[] result, image;
+      int rows = this.m_rows_r;
+      int cols = this.m_cols_r;
+
+      image = this.m_result;
+      
+      rows_k1 = 1;
+      cols_k1 = 3;
+      kernel_1 = new int[rows_k1 * cols_k1];
+      rows_k2 = 1;
+      cols_k2 = 3;
+      kernel_2 = new int[rows_k2 * cols_k2];   
+
+      kernel_1[0] = 1;
+      kernel_1[1] = 2;
+      kernel_1[2] = 1;
+
+      kernelSize = 3;
+      kernelSum_1 = 4;
+      
+      kernel_2[0] = 1;
+      kernel_2[1] = 0;
+      kernel_2[2] = -1;
+
+      kernelSum_2 = 2;
+
+      startCol = 1;           //((kernelSize)/2);
+      endCol = cols - 1;      //(int)(cols - (kernelSize/2));
+      halfKernel = 1;         //(kernelSize-1)/2;
+
+      startRow = 1;       //(kernelSize)/2;
+      endRow = (rows-1);  //(rows - (kernelSize)/2);
+
+      for(i=startRow; i<endRow; i++) {
+          for(j=startCol; j<endCol; j++) {
+              temp = 0;
+              for(k=-halfKernel; k<=halfKernel; k++) {
+                  temp += (float)(image[(i+k) * cols + j] 
+                                         * (float)(kernel_1[k+halfKernel]));
+              }
+              image[i * cols + j] = (float)(temp/kernelSum_1);
+              image[i * cols + j] = (float)(image[i * cols + j] + 128);
+          }
+      }
+    }
+    
+    public void printImage() {
+      //    result validation
+      for(int i=0; i<this.m_rows; i++) {
+          for(int j=0; j<this.m_cols; j++) {
+              System.printI((int)(this.m_image[i * this.m_cols + j]*10));
+          }
+      }
+    }
+    
+    public void printResult() {
+      //    result validation
+      for(int i=0; i<this.m_rows_r; i++) {
+          for(int j=0; j<this.m_cols_r; j++) {
+              System.printI((int)(this.m_result[i * this.m_cols_r + j]*10));
+          }
+      }
+    }
+}
\ No newline at end of file
diff --git a/Robust/src/Benchmarks/Scheduling/Tracking/IXLR.java b/Robust/src/Benchmarks/Scheduling/Tracking/IXLR.java
new file mode 100644 (file)
index 0000000..36009cf
--- /dev/null
@@ -0,0 +1,132 @@
+public class IXLR {
+    flag toprocess;
+    flag tomergeIXLR;
+    flag finish;
+    
+    /* current processing image related */
+    float[] m_image;
+    int m_rows;
+    int m_cols;
+    
+    /* results related */
+    float[] m_result;
+    int m_rows_rs;
+    int m_rows_re;
+    int m_cols_r;
+    
+    /* id indicating the piece # */
+    int m_id;  
+    int m_range;
+    
+    /* constructor */
+    public IXLR(int id,
+                int range,
+                float[] data,
+                int rows,
+                int cols) {
+      this.m_id = id;
+      this.m_range = range;
+      this.m_image = data;
+      this.m_rows = rows;
+      this.m_cols = cols;
+    }
+    
+    public int getId() {
+      return this.m_id;
+    }
+    
+    public float[] getResult() {
+      return this.m_result;
+    }
+    
+    public int getRowsRS() {
+      return this.m_rows_rs;
+    }
+    
+    public int getRowsRE() {
+      return this.m_rows_re;
+    }
+    
+    public int getColsR() {
+      return this.m_cols_r;
+    }
+    
+    public int getRows() {
+      return this.m_rows;
+    }
+    
+    public int getCols() {
+      return this.m_cols;
+    }
+    
+    public void calcSobel_dX() {
+      int rows_k1, cols_k1, rows_k2, cols_k2;
+      int[] kernel_1, kernel_2;
+      float temp;
+      int kernelSize, startCol, endCol, halfKernel, startRow, endRow;
+      int k, i, j, kernelSum_1, kernelSum_2;
+      float[] result, image;
+      int rows = this.m_rows;
+      int cols = this.m_cols;
+
+      image = this.m_image;
+      
+      this.m_rows_rs = this.m_id * this.m_range;
+      this.m_rows_re = (this.m_id + 1) * this.m_range;
+      this.m_cols_r = cols;
+      result=this.m_result=new float[(this.m_rows_re-this.m_rows_rs)*this.m_cols_r];
+      
+      rows_k1 = 1;
+      cols_k1 = 3;
+      kernel_1 = new int[rows_k1 * cols_k1];
+      rows_k2 = 1;
+      cols_k2 = 3;
+      kernel_2 = new int[rows_k2 * cols_k2];   
+
+      kernel_1[0] = 1;
+      kernel_1[1] = 2;
+      kernel_1[2] = 1;
+
+      kernelSize = 3;
+      kernelSum_1 = 4;
+      
+      kernel_2[0] = 1;
+      kernel_2[1] = 0;
+      kernel_2[2] = -1;
+
+      kernelSum_2 = 2;
+
+      startCol = 1;           //((kernelSize)/2);
+      endCol = cols - 1;      //(int)(cols - (kernelSize/2));
+      halfKernel = 1;         //(kernelSize-1)/2;
+
+      if((this.m_rows_re < 1) || (this.m_rows_rs > rows - 1)) {
+        return;
+      }
+      startRow = (1>this.m_rows_rs)?1:(this.m_rows_rs);       //(kernelSize)/2;
+      endRow = ((rows-1)<this.m_rows_re)?(rows-1):(this.m_rows_re);  //(rows - (kernelSize)/2);
+
+      int ii = startRow - this.m_rows_rs;
+      for(i=startRow; i<endRow; i++) {
+          for(j=startCol; j<endCol; j++) {
+              temp = 0;
+              for(k=-halfKernel; k<=halfKernel; k++) {
+                  temp += (float)(image[i * cols + (j+k)] 
+                                        * (float)(kernel_2[k+halfKernel]));
+              }
+              result[ii * cols + j] = (float)(temp/kernelSum_2);
+          }
+          ii++;
+      }
+    }
+    
+    public void printResult() {
+      //    result validation
+      System.printI(11111111);
+      for(int i=0; i<this.m_rows_re-this.m_rows_rs; i++) {
+          for(int j=0; j<this.m_cols_r; j++) {
+              System.printI((int)(this.m_result[i * this.m_cols_r + j]*10));
+          }
+      }
+    }
+}
\ No newline at end of file
index d3234fd9fe4bc9d2ca5d5f71ff6e80603f458450..c2be76a92d45dea97d87ecfe0a4a9d574d8b6987 100644 (file)
@@ -14,8 +14,6 @@ public class IYL {
     int m_rows_re;
     int m_cols_r;
     
-    /* processing type */
-    int m_id_t; // 0--Ipyr1; 1--Ipyr2;
     /* id indicating the piece # */
     int m_id;  
     int m_range;
@@ -23,13 +21,11 @@ public class IYL {
     /* constructor */
     public IYL(int id,
                int range,
-               int tid,
                float[] image,
                int rows,
                int cols) {
       this.m_id = id;
       this.m_range = range;
-      this.m_id_t = tid;
       this.m_image = image;
       this.m_rows = rows;
       this.m_cols = cols;
@@ -39,10 +35,6 @@ public class IYL {
       return this.m_id;
     }
     
-    public int getIdT() {
-      return this.m_id_t;
-    }
-    
     public int getRowsRS() {
       return this.m_rows_rs;
     }
index e6200c132972a9baa84f6b1c87610a06c2ddfd2b..e0ce92796c34ffec1c1287d9af17e31220310437 100644 (file)
@@ -1,6 +1,6 @@
 public class IYLM {
     flag tomergeIYL;
-    flag toaddIYL;
+    flag tocalcT;
     flag finish;
     
     /* current processing image related */
@@ -15,16 +15,11 @@ public class IYLM {
     
     int m_counter;
     
-    /* processing type */
-    int m_id_t; // 0--Ipyr1; 1--Ipyr2;
-    
     /* constructor */
-    public IYLM(int tid,
-                int counter,
+    public IYLM(int counter,
                 float[] data,
                 int rows,
                 int cols) {
-      this.m_id_t = tid;
       this.m_counter = counter;
       this.m_rows = this.m_rows_r = rows;
       this.m_cols = this.m_cols_r = cols;
@@ -32,10 +27,6 @@ public class IYLM {
       this.m_result = new float[rows * cols];
     }
     
-    public int getIdT() {
-      return this.m_id_t;
-    }
-    
     public int getRows() {
       return this.m_rows;
     }
diff --git a/Robust/src/Benchmarks/Scheduling/Tracking/IYLMR.java b/Robust/src/Benchmarks/Scheduling/Tracking/IYLMR.java
new file mode 100644 (file)
index 0000000..470931d
--- /dev/null
@@ -0,0 +1,148 @@
+public class IYLMR {
+    flag tomergeIYLR;
+    flag tocalcT;
+    flag finish;
+    
+    /* current processing image related */
+    float[] m_image;
+    int m_rows;
+    int m_cols;
+    
+    /* current processing image related */
+    float[] m_result;
+    int m_rows_r;
+    int m_cols_r;
+    
+    int m_counter;
+    
+    /* constructor */
+    public IYLMR(int counter,
+                 float[] data,
+                 int rows,
+                 int cols) {
+      this.m_counter = counter;
+      this.m_rows = this.m_rows_r = rows;
+      this.m_cols = this.m_cols_r = cols;
+      this.m_image = data;
+      this.m_result = new float[rows * cols];
+    }
+    
+    public int getRows() {
+      return this.m_rows;
+    }
+    
+    public int getCols() {
+      return this.m_cols;
+    }
+    
+    public float[] getImage() {
+      return this.m_image;
+    }
+    
+    public int getRowsR() {
+      return this.m_rows_r;
+    }
+    
+    public int getColsR() {
+      return this.m_cols_r;
+    }
+    
+    public float[] getResult() {
+      return this.m_result;
+    }
+    
+    public boolean addCalcSobelResult(IYLR iyl) {
+      int startRow = iyl.getRowsRS();
+      int endRow = iyl.getRowsRE();
+      int i, j, k, cols;
+      float[] image, r;
+      
+      image = this.m_result;
+      this.m_counter--;
+      cols = this.m_cols_r;
+      
+      // clone data piece      
+      r = iyl.getResult();
+      k = 0;
+      for(i = startRow; i < endRow; i++) {
+        for(j = 0; j < cols; j++) {
+          image[i * cols + j] = r[k * cols + j];
+        }
+        k++;
+      }
+      
+      return (0 == this.m_counter);
+    }
+    
+    public void calcSobel_dY() {
+      int rows_k1, cols_k1, rows_k2, cols_k2;
+      int[] kernel_1, kernel_2;
+      float temp;
+      int kernelSize, startCol, endCol, halfKernel, startRow, endRow;
+      int k, i, j, kernelSum_1, kernelSum_2;
+      float[] result, image;
+      int rows = this.m_rows_r;
+      int cols = this.m_cols_r;
+      
+      // level 1 is the base image.
+      
+      image = this.m_result;
+      
+      rows_k1 = 1;
+      cols_k1 = 3;
+      kernel_1 = new int[rows_k1 * cols_k1];
+      rows_k2 = 1;
+      cols_k2 = 3;
+      kernel_2 = new int[rows_k2 * cols_k2];
+
+      kernel_1[0] = 1;
+      kernel_1[1] = 0;
+      kernel_1[2] = -1;
+
+      kernelSize = 3;
+      kernelSum_1 = 2;
+      
+      kernel_2[0] = 1;
+      kernel_2[1] = 2;
+      kernel_2[2] = 1;
+
+      kernelSum_2 = 4;
+
+      startCol = 1;       //(kernelSize/2);
+      endCol = cols - 1;  //(int)(cols - (kernelSize/2));
+      halfKernel = 1;     //(kernelSize-1)/2;
+
+      startRow = 1;       //(kernelSize)/2;
+      endRow = (rows-1);  //(rows - (kernelSize)/2);
+
+      for(i=startRow; i<endRow; i++) {
+          for(j=startCol; j<endCol; j++) {
+              temp = 0;
+              for(k=-halfKernel; k<=halfKernel; k++) {
+                  temp += (float)(image[(i+k) * cols + j] 
+                                         * (float)(kernel_1[k+halfKernel]));
+              }
+              image[i * cols + j] = (float)(temp/kernelSum_1);
+              image[i * cols + j] = (float)(image[i * cols + j] + 128);
+          }
+      }
+    }
+    
+    public void printImage() {
+      //    result validation
+      for(int i=0; i<this.m_rows; i++) {
+          for(int j=0; j<this.m_cols; j++) {
+              System.printI((int)(this.m_image[i * this.m_cols + j]*10));
+          }
+      }
+    }
+    
+    public void printResult() {
+      //    result validation
+      for(int i=0; i<this.m_rows_r; i++) {
+          for(int j=0; j<this.m_cols_r; j++) {
+              System.printI((int)(this.m_result[i * this.m_cols_r + j]*10));
+          }
+      }
+    }
+}
\ No newline at end of file
diff --git a/Robust/src/Benchmarks/Scheduling/Tracking/IYLR.java b/Robust/src/Benchmarks/Scheduling/Tracking/IYLR.java
new file mode 100644 (file)
index 0000000..1956c3b
--- /dev/null
@@ -0,0 +1,128 @@
+public class IYLR {
+    flag toprocess;
+    flag tomergeIYLR;
+    flag finish;
+    
+    /* current processing image related */
+    float[] m_image;
+    int m_rows;
+    int m_cols;
+    
+    /* results related */
+    float[] m_result;
+    int m_rows_rs;
+    int m_rows_re;
+    int m_cols_r;
+    
+    /* id indicating the piece # */
+    int m_id;  
+    int m_range;
+    
+    /* constructor */
+    public IYLR(int id,
+                int range,
+                float[] image,
+                int rows,
+                int cols) {
+      this.m_id = id;
+      this.m_range = range;
+      this.m_image = image;
+      this.m_rows = rows;
+      this.m_cols = cols;
+    }
+    
+    public int getId() {
+      return this.m_id;
+    }
+    
+    public int getRowsRS() {
+      return this.m_rows_rs;
+    }
+    
+    public int getRowsRE() {
+      return this.m_rows_re;
+    }
+
+    public int getColsR() {
+      return this.m_cols_r;
+    }
+    
+    public float[] getResult() {
+      return this.m_result;
+    }
+    
+    public int getRows() {
+      return this.m_rows;
+    }
+    
+    public int getCols() {
+      return this.m_cols;
+    }
+    
+    public float[] getImage() {
+      return this.m_image;
+    }
+    
+    public void calcSobel_dY() {
+      int rows_k1, cols_k1, rows_k2, cols_k2;
+      int[] kernel_1, kernel_2;
+      float temp;
+      int kernelSize, startCol, endCol, halfKernel, startRow, endRow;
+      int k, i, j, kernelSum_1, kernelSum_2;
+      float[] result, image;
+      int rows = this.m_rows;
+      int cols = this.m_cols;
+      
+      // level 1 is the base image.
+      
+      image = this.m_image;
+      
+      this.m_rows_rs = this.m_id * this.m_range;
+      this.m_rows_re = (this.m_id + 1) * this.m_range;
+      this.m_cols_r = cols;
+      result=this.m_result=new float[(this.m_rows_re-this.m_rows_rs)*this.m_cols_r];
+      
+      rows_k1 = 1;
+      cols_k1 = 3;
+      kernel_1 = new int[rows_k1 * cols_k1];
+      rows_k2 = 1;
+      cols_k2 = 3;
+      kernel_2 = new int[rows_k2 * cols_k2];
+
+      kernel_1[0] = 1;
+      kernel_1[1] = 0;
+      kernel_1[2] = -1;
+
+      kernelSize = 3;
+      kernelSum_1 = 2;
+      
+      kernel_2[0] = 1;
+      kernel_2[1] = 2;
+      kernel_2[2] = 1;
+
+      kernelSum_2 = 4;
+
+      startCol = 1;       //(kernelSize/2);
+      endCol = cols - 1;  //(int)(cols - (kernelSize/2));
+      halfKernel = 1;     //(kernelSize-1)/2;
+      
+      if((this.m_rows_re < 1) || (this.m_rows_rs > rows - 1)) {
+        return;
+      }
+      startRow = (1>this.m_rows_rs)?1:(this.m_rows_rs);       //(kernelSize)/2;
+      endRow = ((rows-1)<this.m_rows_re)?(rows-1):(this.m_rows_re);  //(rows - (kernelSize)/2);
+
+      int ii = startRow - this.m_rows_rs;
+      for(i=startRow; i<endRow; i++) {
+          for(j=startCol; j<endCol; j++) {
+              temp = 0;
+              for(k=-halfKernel; k<=halfKernel; k++) {
+                  temp += (float)(image[i * cols + (j+k)] 
+                                        * (float)(kernel_2[k+halfKernel]));
+              }
+              result[ii * cols + j] = (float)(temp/kernelSum_2);
+          }
+          ii++;
+      }
+    }
+}
\ No newline at end of file
index a504fb99dc59f77ed4ae3ce00608d99f16ee212a..d69b97730b0741e5dd820ce3ee59f92d94dc47f5 100644 (file)
@@ -1,19 +1,15 @@
 public class Lambda {
     flag tocalcGF;
-    flag toaddLMDA;
+    flag tocalcInd;
     flag finish;
     
     /* current processing image related */
     float[] m_image;
     int m_rows;
     int m_cols;
+    int m_r;
     
-    /* results related */
-    float[][] m_result;
-    int m_rows_r;
-    int m_cols_r;
-    int m_num;
-    int[] m_ind;
+    int m_num_p;
     
     /* benchmark constants */
     int WINSZ;
@@ -22,38 +18,31 @@ public class Lambda {
     /* constructor */
     public Lambda(int winsz,
                   int nfea,
-                  int pnum) {
+                  int pnum,
+                  int nump) {
       this.WINSZ = winsz;
       this.N_FEA = nfea;
-
-      this.m_num = 3;
-      this.m_result = new float[this.m_num][this.N_FEA];
-      this.m_rows_r = this.N_FEA;
-      this.m_cols_r = 1;
-    }
-    
-    public int getRows() {
-      return this.m_rows;
+      this.m_num_p = nump;
     }
     
-    public int getCols() {
-      return this.m_cols;
+    public int getNumP() {
+      return this.m_num_p;
     }
     
-    public int getNum() {
-      return this.m_num;
+    public int getR() {
+      return this.m_r;
     }
     
-    public float[] getResult(int index) {
-      return this.m_result[index];
+    public int getRows() {
+      return this.m_rows;
     }
     
-    public int getRowsR(int index) {
-      return this.m_rows_r;
+    public int getCols() {
+      return this.m_cols;
     }
     
-    public int getColsR(int index) {
-      return this.m_cols_r;
+    public float[] getImage() {
+      return this.m_image;
     }
     
     public void calcGoodFeature(ImageXM imxm,
@@ -178,7 +167,7 @@ public class Lambda {
       return ret; 
     }
     
-    public int reshape() {
+    public void reshape() {
       float[] out, image;
       int i, j, k;
       int r, c;
@@ -198,93 +187,9 @@ public class Lambda {
       this.m_image = out;
       this.m_rows = r * c;
       this.m_cols = 1;
-      return r;
-    }
-
-    public void sortInd(int r) {
-      float[] image;
-      int i, j, k;
-      int[] ind;
-      int rows_i, cols_i;
-      float[][] result;
-
-      // fDeepCopy
-      image = new float[this.m_image.length];
-      for(i = 0; i < this.m_image.length; i++) {
-        image[i] = this.m_image[i];
-      }
-      result = this.m_result;
-      
-      rows_i = this.m_rows;
-      cols_i = this.m_cols;
-      ind = this.m_ind = new int[rows_i * cols_i];
-
-      for(k=0; k<cols_i; k++) {
-        for(i=0; i<rows_i; i++) {
-          float localMax = image[i * cols_i + k];
-          int localIndex = i+1;
-          ind[i * cols_i + k] = i+1;
-          for(j=0; j<rows_i; j++) {
-            if(localMax < image[j*cols_i+k]) {
-              localMax = image[j * cols_i + k];
-              localIndex = j+1;
-            }
-          }
-          ind[i * cols_i + k] = localIndex;
-          image[(localIndex-1) * cols_i + k] = 0;
-        }
-      }
-
-      // set the results
-      for(i=0; i<this.N_FEA; i++) {
-        result[0][i] = Math.ceilf((float)(ind[i] / (float)r));
-        result[1][i] = (float)ind[i] - (result[0][i]-1)
-                                       * (float)r * (float)1.0;
-      }
+      this.m_r= r;
     }
 
-    public void fSortIndices() {
-      int i, j, k;
-      int[] ind;
-      int rows_i, cols_i;
-      float[][] result;
-      float[] image;
-
-      // fDeepCopy
-      image = new float[this.m_image.length];
-      for(i = 0; i < this.m_image.length; i++) {
-        image[i] = this.m_image[i];
-      }
-      result = this.m_result;
-
-      rows_i = this.m_rows;
-      cols_i = this.m_cols;
-      ind = this.m_ind;
-      for(i = 0; i < ind.length; i++) {
-        ind[i] = 0;
-      }
-
-      for(k=0; k<cols_i; k++) {
-        for(i=0; i<rows_i; i++) {
-          float localMax = image[i * cols_i + k];
-          int localIndex = i;
-          ind[i * cols_i + k] = i;
-          for(j=0; j<rows_i; j++) {
-            if(localMax < image[j*cols_i+k]) {
-              ind[i * cols_i + k] = j;
-              localMax = image[j * cols_i + k];
-              localIndex = j;
-            }
-          }
-          image[localIndex * cols_i + k] = 0;
-        }
-      }
-
-      // set the results
-      for(i=0; i<this.N_FEA; i++) {
-        result[2][i] = this.m_image[ind[i]];
-      }
-    }
     
     public void printImage() {
       //    result validation
@@ -294,25 +199,4 @@ public class Lambda {
           }
       }
     }
-    
-    public void printInd() {
-      //    result validation
-      for(int i=0; i<this.m_rows; i++) {
-          for(int j=0; j<this.m_cols; j++) {
-              System.printI((int)(this.m_ind[i * this.m_cols + j]*10));
-          }
-      }
-    }
-    
-    public void printResult() {
-      //    result validation
-      for(int k=0; k<3; k++) {
-        System.printI(k+100000000);
-        for(int i=0; i<this.m_rows_r; i++) {
-          for(int j=0; j<this.m_cols_r; j++) {
-            System.printI((int)(this.m_result[k][i * this.m_cols_r + j]*10));
-          }
-        }
-      }
-    }
 }
\ No newline at end of file
index e33693ac74e1a6e3d8505080231e9abfd20832f9..272cf1bf659741756fb9ff177ea8c115525022ee 100644 (file)
@@ -2,13 +2,11 @@ public class TrackDemo {
     flag toaddBP;
     flag topreresize;
     flag toresize;
-    flag toaddLMDA;
+    flag tomergeIDX;
     flag tocalcF;
     flag tostartL;
     flag toaddBP2;
     flag toresize2;
-    flag toaddIXL;
-    flag toaddIYL;
     flag tocalcT;
     flag finish;
     
@@ -26,6 +24,8 @@ public class TrackDemo {
     
     /* BP related */
     int m_num_bp;
+    /* BPL related */
+    int m_num_bpl;
     
     /* feature related */
     float[] m_features;
@@ -34,15 +34,10 @@ public class TrackDemo {
     
     /*  */
     float[][] m_3f;
-    int m_rows_3f[];
-    int m_cols_3f[];
+    int m_rows_3f;
+    int m_cols_3f;
     int m_counter_3f;
-    
-    /* */
-    float[][] m_Ipyrs; // Ipyr1, Ipyr2, dxPyr1, dyPyr1, dxPyr2, dyPyr2;
-    int[] m_rows_i, m_cols_i;
-    int m_counter_ix;
-    int m_counter_iy;
+    int m_num_p;
     
     /* benchmark constants */
     public int WINSZ;
@@ -53,36 +48,27 @@ public class TrackDemo {
     float accuracy;
     
     /* constructor */
-    public TrackDemo() {
+    public TrackDemo(int nump) {
       this.m_inputs = new int[2][];
  
-      int rows = 8;
-      int cols = 12;
+      int rows = 10 * 60 * 2;
+      int cols = 12 * 5;
       int offset = 0;
       this.m_inputs[0] = this.makeImage(rows, cols, offset);
       offset = 100;
       this.m_inputs[1] = this.makeImage(rows, cols, offset);
       this.m_count = 0;
       
-      this.m_3f = new float[3][];
-      this.m_rows_3f = new int[3];
-      this.m_cols_3f = new int[3];
-      this.m_counter_3f = 3;
-      
-      this.m_Ipyrs = new float[6][];
-      this.m_rows_i = new int[6];
-      this.m_cols_i = new int[6];
-      this.m_counter_ix = 2;
-      this.m_counter_iy = 2;
-      
       this.m_num_bp = 0;
       
       this.WINSZ = 8;
-      this.N_FEA = 1600;
+      this.N_FEA = 16; //00;
       this.SUPPRESION_RADIUS = 10;
       this.LK_ITER = 20;
+      this.accuracy = (float)0.03;
+      this.m_counter = 2;
 //    #ifdef test
-      this.WINSZ = 2;
+      /*this.WINSZ = 2;
       this.N_FEA = 10;
       this.LK_ITER = 1;
       this.m_counter = 2;
@@ -100,6 +86,15 @@ public class TrackDemo {
           this.LK_ITER = 4;
           this.counter = 2;
       */
+      this.m_3f = new float[3][this.N_FEA];
+      this.m_rows_3f = this.N_FEA;
+      this.m_cols_3f = this.N_FEA;
+      this.m_counter_3f = 3;
+      this.m_num_p = nump;
+    }
+    
+    public int getNumP() {
+      return this.m_num_p;
     }
     
     public boolean isFinish() {
@@ -143,6 +138,10 @@ public class TrackDemo {
       this.m_num_bp = num;
     }
     
+    public void setBPLNum(int num) {
+      this.m_num_bpl = num;
+    }
+    
     public int[] makeImage(int rows, 
                            int cols, 
                            int offset) {
@@ -192,6 +191,33 @@ public class TrackDemo {
       return (0 == this.m_num_bp);
     }
     
+    public boolean addBPL(BlurPieceL bpl) {
+      int startRow = bpl.getRowsRS();
+      int endRow = bpl.getRowsRE();
+      int i, j, k, cols;
+      float[] image, input;
+      
+      if(this.m_image == null) {
+        this.m_rows = bpl.getRows();
+        this.m_cols = bpl.getCols();
+        this.m_image = new float[this.m_rows * this.m_cols];
+      }
+      image = this.m_image;
+      cols = this.m_cols;
+      
+      input = bpl.getResult();
+      k = 0;
+      for(i = startRow; i < endRow; i++) {
+        for(j = 0; j < cols; j++) {
+          image[i * cols + j] = input[k * cols + j];
+        }
+        k++;
+      }
+      
+      this.m_num_bpl--;
+      return (0 == this.m_num_bpl);
+    }
+    
     public void postBlur() {
       int rows, cols;
       float temp;
@@ -312,15 +338,85 @@ public class TrackDemo {
       }
     }
     
-    public void addLMDA(Lambda lmda) {
+    public boolean addIDX(IDX idx) {
       float[][] m3f = this.m_3f;
-      int[] rows = this.m_rows_3f;
-      int[] cols = this.m_cols_3f;
-      for(int i = 0; i < lmda.getNum(); i++) {
-        m3f[i] = lmda.getResult(i);
-        rows[i] = lmda.getRowsR(i);
-        cols[i] = lmda.getColsR(i);
+      int rows = idx.getRowsRS();
+      int rowe = idx.getRowsRE();
+      int threshold = this.N_FEA;
+      int[] ind = idx.getInd();
+      float[] image = idx.getImage();
+      int r = idx.getR();
+      int nfea = this.N_FEA;
+      int length = this.m_rows * this.m_cols;
+      int[] h_ind = new int[this.N_FEA];
+      boolean[] f_ind = new boolean[this.N_FEA];
+      for(int i = 0; i < this.N_FEA; i++) {
+        f_ind[i] = false;
       }
+      
+      int j = 0;
+      int localindex = 0;
+      int rindex = 0;
+      for(int i = rows; i < rowe; i++) {
+        rindex = length - ind[j];
+        if(rindex < nfea) {
+          localindex = j + rows;
+          if(!f_ind[rindex]) {  
+            // empty
+            m3f[2][rindex] = image[localindex];
+            h_ind[rindex] = localindex;
+            localindex++;
+            m3f[0][rindex] = Math.ceilf((float)(localindex / (float)r));
+            m3f[1][rindex] = (float)localindex
+                            -(m3f[0][rindex]-1)*(float)r*(float)1.0;
+            f_ind[rindex] = true;
+          } else {
+            // previously held by some others with the same value
+            int k = rindex; // the place to insert
+            int k1 = rindex; // the first one which is not set
+            for(; k1 < nfea; k1++) {
+              if(h_ind[k1] > localindex) {
+                k = k1;
+              }
+              if(!f_ind[k1]) {
+                break;
+              }
+            }
+            if(k == nfea) {
+              System.printI(77777777);
+              return false;
+            } else if(k == rindex) {
+              k = k1;
+            }
+            if(f_ind[k] && (m3f[2][k] != image[localindex])) {
+              System.printI(88888888);
+              return false;
+            }
+            // move all things after k behind
+            int p  = k1;
+            for(; p > k; p--) {
+              m3f[2][p] = m3f[2][p-1];
+              h_ind[p] = h_ind[p-1];
+              m3f[0][p] = m3f[0][p-1];
+              m3f[1][p] = m3f[1][p-1];
+              f_ind[p] = true;
+            }
+            // insert
+            m3f[2][p] = image[localindex];
+            h_ind[p] = localindex;
+            localindex++;
+            m3f[0][p] = Math.ceilf((float)(localindex / (float)r));
+            m3f[1][p] = (float)localindex
+                            -(m3f[0][p]-1)*(float)r*(float)1.0;
+            f_ind[p] = true;
+          }
+        }
+        j++;
+      }
+
+      this.m_num_p--;
+      
+      return (0 == this.m_num_p);
     }
     
     public void calcFeatures() {
@@ -335,12 +431,12 @@ public class TrackDemo {
       f1 = this.m_3f[0];
       f2 = this.m_3f[1];
       f3 = this.m_3f[2];
-      rows_f1 = this.m_rows_3f[0];
-      rows_f2 = this.m_rows_3f[1];
-      rows_f3 = this.m_rows_3f[2];
-      cols_f1 = this.m_cols_3f[0];
-      cols_f2 = this.m_cols_3f[1];
-      cols_f3 = this.m_cols_3f[2];
+      rows_f1 = this.m_rows_3f;
+      rows_f2 = this.m_rows_3f;
+      rows_f3 = this.m_rows_3f;
+      cols_f1 = this.m_cols_3f;
+      cols_f2 = this.m_cols_3f;
+      cols_f3 = this.m_cols_3f;
       
       interestPnts = this.getANMs(f1, 
                                   rows_f1,
@@ -694,8 +790,6 @@ public class TrackDemo {
     public void startTrackingLoop() {
       this.m_image = null;
       this.m_image_resized = null;
-      this.m_counter_ix = 2;
-      this.m_counter_iy = 2;
     }
     
     public float[] getInterpolatePatch(float[] src, 
@@ -918,74 +1012,38 @@ public class TrackDemo {
       return valid;
     }
     
-    public boolean addIXLM(IXLM ixlm) {
-      float[][] Ipyrs = this.m_Ipyrs; // Ipyr1, Ipyr2, dxPyr1, dyPyr1, dxPyr2, dyPyr2;
-      int[] rows, cols;
-      int i, j, k;
-      rows = this.m_rows_i;
-      cols = this.m_cols_i;
-
-      if(0 == ixlm.getIdT()) {
-//      for Ipyr1
-        i = 0;
-      } else if(1 == ixlm.getIdT()) {
-//      for Ipyr2
-        i = 1;
-      }
-      // dx
-      j = 2 * (i + 1);
-      Ipyrs[i] = ixlm.getImage();
-      rows[i] = ixlm.getRows();
-      cols[i] = ixlm.getCols();
-      Ipyrs[j] = ixlm.getResult();
-      rows[j] = ixlm.getRowsR();
-      cols[j] = ixlm.getColsR();
-      
-      this.m_counter_ix--;
-
-      return (0 == this.m_counter_ix);
-    }
-    
-    public boolean addIYLM(IYLM iylm) {
-      float[][] Ipyrs = this.m_Ipyrs; // Ipyr1, Ipyr2, dxPyr1, dyPyr1, dxPyr2, dyPyr2;
-      int[] rows, cols;
-      int i, j, k;
-      rows = this.m_rows_i;
-      cols = this.m_cols_i;
-
-      if(0 == iylm.getIdT()) {
-//      for Ipyr1
-        i = 0;
-      } else if(1 == iylm.getIdT()) {
-//      for Ipyr2
-        i = 1;
-      }
-      // dy
-      j = 2 * (i + 1) + 1;
-      Ipyrs[i] = iylm.getImage();
-      rows[i] = iylm.getRows();
-      cols[i] = iylm.getCols();
-      Ipyrs[j] = iylm.getResult();
-      rows[j] = iylm.getRowsR();
-      cols[j] = iylm.getColsR();
-
-      this.m_counter_iy--;
-
-      return (0 == this.m_counter_iy);
-    }
-    
-    public void calcTrack() {
-      float[][] Ipyrs;
-      int[] rows, cols;
+    public void calcTrack(IXLM ixlm,
+                          IYLM iylm,
+                          IXLMR ixlmr,
+                          IYLMR iylmr) {
+      float[][] Ipyrs  = new float[6][];
+      int[] rows  = new int[6];
+      int[] cols = new int[6];
       float[] newpoints, features, np_temp;
       int rows_n, cols_n, rows_np, cols_np, i, j, k, m, n, numFind;
       int[] status;
       int rows_s, cols_s;
+
+      Ipyrs[0] = ixlm.getImage();
+      rows[0] = ixlm.getRows();
+      cols[0] = ixlm.getCols();
+      Ipyrs[2] = ixlm.getResult();
+      rows[2] = ixlm.getRowsR();
+      cols[2] = ixlm.getColsR();
+      Ipyrs[3] = iylm.getResult();
+      rows[3] = iylm.getRowsR();
+      cols[3] = iylm.getColsR();
       
-      Ipyrs = this.m_Ipyrs;
-      rows = this.m_rows_i;
-      cols = this.m_cols_i;
-      
+      Ipyrs[1] = ixlmr.getImage();
+      rows[1] = ixlmr.getRows();
+      cols[1] = ixlmr.getCols();
+      Ipyrs[4] = ixlmr.getResult();
+      rows[4] = ixlmr.getRowsR();
+      cols[4] = ixlmr.getColsR();
+      Ipyrs[5] = iylmr.getResult();
+      rows[5] = iylmr.getRowsR();
+      cols[5] = iylmr.getColsR();
+
       features = this.m_features;
       rows_n = 2;
       cols_n = this.m_cols_f;
@@ -1062,6 +1120,22 @@ public class TrackDemo {
       }
     }
     
+    public void print3f() {
+      //    result validation
+      System.printI(11111111);
+      for(int j=0; j<this.N_FEA; j++) {
+        System.printI((int)(this.m_3f[0][j]*10));
+      }
+      System.printI(22222222);
+      for(int j=0; j<this.N_FEA; j++) {
+        System.printI((int)(this.m_3f[1][j]*10));
+      }
+      System.printI(33333333);
+      for(int j=0; j<this.N_FEA; j++) {
+        System.printI((int)(this.m_3f[2][j]*10));
+      }
+    }
+    
     public void printFeatures() {
       //    result validation
       for(int i=0; i<this.m_rows_f; i++) {
index 1dd44444d7d602b7907b009a44d5c8b9680d7b81..1bba7e2d9223310ccc20c311416b9142e799a20b 100644 (file)
@@ -8,10 +8,11 @@
 task startup(StartupObject s{initialstate}) {
   //System.printString("task startup\n");
  
-  TrackDemo tdmo = new TrackDemo(){toaddBP};
+  int nump = 60;
+  TrackDemo tdmo = new TrackDemo(nump){toaddBP};
   
   int[] input = tdmo.getInput(false);
-  int pnum = 4;
+  int pnum = 60;
   int range = (input[0]) / pnum;
   for(int i = 0; i < pnum; i++) {
     BlurPiece bp = new BlurPiece(i,
@@ -53,7 +54,7 @@ task preresize(TrackDemo tdmo{topreresize}) {
 
   float[] Icur = tdmo.getImage();
 
-  int pnum = 4;
+  int pnum = 30;
   int range = (tdmo.getRows()) / pnum;
   int rows = tdmo.getRows();
   int cols = tdmo.getCols();
@@ -82,7 +83,8 @@ task preresize(TrackDemo tdmo{topreresize}) {
 //create a Lambda to aggregate results from the ImageXs
   Lambda lda = new Lambda(tdmo.WINSZ,
                           tdmo.N_FEA,
-                          pnum){tocalcGF};
+                          pnum,
+                          tdmo.getNumP()){tocalcGF};
 
   taskexit(tdmo{!topreresize, toresize});
 }
@@ -92,7 +94,7 @@ task resize(TrackDemo tdmo{toresize}) {
   
   tdmo.resize();
   
-  taskexit(tdmo{!toresize, toaddLMDA});
+  taskexit(tdmo{!toresize, tomergeIDX});
 }
 
 task processImageX(ImageX imx{toprocess}) {
@@ -146,135 +148,167 @@ task mergeY(ImageYM imym{tomergeY},
 task calcGoodFeature(Lambda lda{tocalcGF},
                      ImageXM imxm{tocalcGF},
                      ImageYM imym{tocalcGF}) {
-//System.printString("task reshape\n");
+//System.printString("task calcGoodFeature\n");
   
   lda.calcGoodFeature(imxm, imym);
   // validation
   //lda.printImage();
-  int r = lda.reshape();
+  lda.reshape();
   // validation
   //lda.printImage();
-  lda.sortInd(r);
-  // validation
-  //lda.printResult();
-  lda.fSortIndices();
-  // validation
-  //lda.printResult();
   
-  taskexit(lda{!tocalcGF, toaddLMDA},
+  taskexit(lda{!tocalcGF, tocalcInd},
            imxm{!tocalcGF, finish},
            imym{!tocalcGF, finish});
+} 
+
+task calcInd(Lambda lda{tocalcInd}) {
+//System.printString("task calcInd\n");
+  
+  int r = lda.getR();
+  float[] data = lda.getImage();
+  int rows = lda.getRows();
+  int cols = lda.getCols();
+  int pnum = lda.getNumP();
+  int range = rows / pnum;
+  for(int i = 0; i < pnum; i++) {
+    IDX idx = new IDX(lda.N_FEA,
+                      i,
+                      range,                 
+                      data,
+                      rows,
+                      cols,
+                      r){toprocess};
+  }
+                    
+  taskexit(lda{!tocalcInd, finish});
 }
 
-task addLMDA(TrackDemo tdmo{toaddLMDA}, 
-             Lambda lmda{toaddLMDA}) {
-//System.printString("task addLMDA\n");
+task processIDX(IDX idx{toprocess}) {
+//System.printString("task processIDX\n");
+  
+  idx.fSortIndices();
+  // validation
+  //idx.printInd();
+  
+  taskexit(idx{!toprocess, tomergeIDX});
+}
 
-  tdmo.addLMDA(lmda);
+task addIDX(TrackDemo tdmo{tomergeIDX}, 
+            IDX idx{tomergeIDX}) {
+//System.printString("task addIDX\n");
 
-  taskexit(tdmo{!toaddLMDA, tocalcF},
-           lmda{!toaddLMDA, finish});
+  boolean isfinished = tdmo.addIDX(idx);
+  //validation
+  //idx.printInd();tdmo.print3f();
+
+  if(isfinished) {
+    //tdmo.print3f();
+    taskexit(tdmo{!tomergeIDX, tocalcF},
+             idx{!tomergeIDX, finish});
+  } else {
+    taskexit(idx{!tomergeIDX, finish});
+  }
 }
 
 task calcFeatures(TrackDemo tdmo{tocalcF}) {
-  //System.printString("task calcFeatures\n");
-  
+//System.printString("task calcFeatures\n");
+
   tdmo.calcFeatures();
-  
+
   taskexit(tdmo{!tocalcF, tostartL});
 }
 
 task startTrackingLoop(TrackDemo tdmo{tostartL}) {
 //System.printString("task startTrackingLoop\n");
 
-  int pnum1 = 4;
+  int pnum1 = 15 * 2;
   float[] data = tdmo.getImage();
   int rows = tdmo.getRows();
   int cols = tdmo.getCols();
   int range = rows / pnum1;
   
-  tag t1=new tag(link);
   for(int i = 0; i < pnum1; i++) {
     IXL ixl = new IXL(i,
                       range,
-                      0, 
                       data,
                       rows,
-                      cols){toprocess}{t1};
+                      cols){toprocess};
     IYL iyl = new IYL(i,
                       range,
-                      0,
                       data,
                       rows,
-                      cols){toprocess}{t1};
+                      cols){toprocess};
   }
-  IXLM ixlm1 = new IXLM(0,
-                        pnum1,
+  IXLM ixlm1 = new IXLM(pnum1,
                         data,
                         rows,
-                        cols){tomergeIXL}{t1};
-  IYLM iylm1 = new IYLM(0,
-                        pnum1,
+                        cols){tomergeIXL};
+  IYLM iylm1 = new IYLM(pnum1,
                         data,
                         rows,
-                        cols){tomergeIYL}{t1};
+                        cols){tomergeIYL};
            
   data = tdmo.getImageR();
   rows = tdmo.getRowsR();
   cols = tdmo.getColsR(); 
   range = rows / pnum1;
-  tag t2=new tag(link);
   for(int i = 0; i < pnum1; i++) {
-    IXL ixl = new IXL(i,
-                      range,
-                      1, 
-                      data,
-                      rows,
-                      cols){toprocess}{t2};
-    IYL imy = new IYL(i,
-                      range,
-                      1,
-                      data,
-                      rows,
-                      cols){toprocess}{t2};
-  }
-  IXLM ixlm2 = new IXLM(1,
-                        pnum1,
+    IXLR ixl = new IXLR(i,
+                        range,
                         data,
                         rows,
-                        cols){tomergeIXL}{t2};
-  IYLM iylm2 = new IYLM(1,
-                        pnum1,
+                        cols){toprocess};
+    IYLR imy = new IYLR(i,
+                        range,
                         data,
                         rows,
-                        cols){tomergeIYL}{t2};
+                        cols){toprocess};
+  }
+  IXLMR ixlm2 = new IXLMR(pnum1,
+                          data,
+                          rows,
+                          cols){tomergeIXLR};
+  IYLMR iylm2 = new IYLMR(pnum1,
+                          data,
+                          rows,
+                          cols){tomergeIYLR};
                                  
-  int pnum2 = 4;
+  int pnum2 = 60 * 2;
   int[] input = tdmo.getInput(true);
   range = (input[0]) / pnum2;
   for(int i = 0; i < pnum2; i++) {
-    BlurPiece bp = new BlurPiece(i,
-                                 range,
-                                 input){toblur};
+    BlurPieceL bpl = new BlurPieceL(i,
+                                    range,
+                                    input){toblur};
   }
-  tdmo.setBPNum(pnum2);                      
+  tdmo.setBPLNum(pnum2);  
   tdmo.startTrackingLoop();
   
   taskexit(tdmo{!tostartL, toaddBP2});
 }
 
+task blurL(BlurPieceL bpl{toblur}) {
+  //System.printString("task blurL\n");
+  
+  //bpl.printImage();
+  bpl.blur();
+  
+  taskexit(bpl{!toblur, toaddBP});
+}
+
 task addBPL(TrackDemo tdmo{toaddBP2},
-            BlurPiece bp{toaddBP}) {
+            BlurPieceL bpl{toaddBP}) {
 //System.printString("task addBPL\n");
   
-  boolean isfinished = tdmo.addBP(bp);
+  boolean isfinished = tdmo.addBPL(bpl);
 
   if(isfinished) {
     tdmo.postBlur();
     taskexit(tdmo{!toaddBP2, toresize2},
-             bp{!toaddBP, finish});
+             bpl{!toaddBP, finish});
   } else {
-    taskexit(bp{!toaddBP, finish});
+    taskexit(bpl{!toaddBP, finish});
   }
 }
 
@@ -283,7 +317,7 @@ task resizeL(TrackDemo tdmo{toresize2}) {
   
   tdmo.resize();
   
-  taskexit(tdmo{!toresize2, toaddIXL, toaddIYL});
+  taskexit(tdmo{!toresize2, tocalcT});
 }
 
 task processIXL(IXL ixl{toprocess}) {
@@ -302,72 +336,104 @@ task processIYL(IYL iyl{toprocess}) {
   taskexit(iyl{!toprocess, tomergeIYL});
 }
 
-task mergeIXL(IXLM ixlm{tomergeIXL}{link t}
-              IXL ixl{tomergeIXL}{link t}) {
+task mergeIXL(IXLM ixlm{tomergeIXL}, 
+              IXL ixl{tomergeIXL}) {
 //System.printString("task mergeIXL\n");
 
   boolean isfinished = ixlm.addCalcSobelResult(ixl);
 
   if(isfinished) {
     ixlm.calcSobel_dX();
-    taskexit(ixlm{!tomergeIXL, toaddIXL}, 
+    taskexit(ixlm{!tomergeIXL, tocalcT}, 
              ixl{!tomergeIXL, finish});
   } else {
     taskexit(ixl{!tomergeIXL, finish});
   }
 }
 
-task mergeIYL(IYLM iylm{tomergeIYL}{link t}
-              IYL iyl{tomergeIYL}{link t}) {
+task mergeIYL(IYLM iylm{tomergeIYL}, 
+              IYL iyl{tomergeIYL}) {
 //System.printString("task mergeIYL\n");
 
   boolean isfinished = iylm.addCalcSobelResult(iyl);
 
   if(isfinished) {
     iylm.calcSobel_dY();
-    taskexit(iylm{!tomergeIYL, toaddIYL}, 
+    taskexit(iylm{!tomergeIYL, tocalcT}, 
              iyl{!tomergeIYL, finish});
   } else {
     taskexit(iyl{!tomergeIYL, finish});
   }
 }
 
-task addIXLM(TrackDemo tdmo{toaddIXL},
-             IXLM ixlm{toaddIXL}) {
-//System.printString("task addIXLM()\n");
+task processIXLR(IXLR ixl{toprocess}) {
+//System.printString("task processIXLR\n");
+  
+  ixl.calcSobel_dX();
+  
+  taskexit(ixl{!toprocess, tomergeIXLR});
+}
+
+task processIYLR(IYLR iyl{toprocess}) {
+//System.printString("task processIYLR\n");
+  
+  iyl.calcSobel_dY();
+  
+  taskexit(iyl{!toprocess, tomergeIYLR});
+}
+
+task mergeIXLR(IXLMR ixlm{tomergeIXLR}, 
+               IXLR ixl{tomergeIXLR}) {
+//System.printString("task mergeIXLR\n");
+
+  boolean isfinished = ixlm.addCalcSobelResult(ixl);
 
-  if(tdmo.addIXLM(ixlm)) {
-//  finished
-    taskexit(tdmo{!toaddIXL, tocalcT},
-             ixlm{!toaddIXL, finish});
+  if(isfinished) {
+    ixlm.calcSobel_dX();
+    taskexit(ixlm{!tomergeIXLR, tocalcT}, 
+             ixl{!tomergeIXLR, finish});
   } else {
-    taskexit(ixlm{!toaddIXL, finish});
+    taskexit(ixl{!tomergeIXLR, finish});
   }
 }
 
-task addIYLM(TrackDemo tdmo{toaddIYL},
-             IYLM iylm{toaddIYL}) {
-//System.printString("task addIYLM()\n");
+task mergeIYLR(IYLMR iylm{tomergeIYLR}, 
+               IYLR iyl{tomergeIYLR}) {
+//System.printString("task mergeIYLR\n");
 
-  if(tdmo.addIYLM(iylm)) {
-//  finished
-    taskexit(tdmo{!toaddIYL, tocalcT},
-             iylm{!toaddIYL, finish});
+  boolean isfinished = iylm.addCalcSobelResult(iyl);
+
+  if(isfinished) {
+    iylm.calcSobel_dY();
+    taskexit(iylm{!tomergeIYLR, tocalcT}, 
+             iyl{!tomergeIYLR, finish});
   } else {
-    taskexit(iylm{!toaddIYL, finish});
+    taskexit(iyl{!tomergeIYLR, finish});
   }
 }
 
-task calcTrack(TrackDemo tdmo{!toaddIXL && !toaddIYL && tocalcT}) {
+task calcTrack(TrackDemo tdmo{tocalcT},
+               IXLM ixlm{tocalcT},
+               IYLM iylm{tocalcT},
+               IXLMR ixlmr{tocalcT},
+               IYLMR iylmr{tocalcT}) {
 //System.printString("task calcTrack()\n");
 
-  tdmo.calcTrack();
+  tdmo.calcTrack(ixlm, iylm, ixlmr, iylmr);
 
   if(tdmo.isFinish()) {
     //tdmo.printFeatures();
     // finished
-    taskexit(tdmo{!tocalcT, finish});
+    taskexit(tdmo{!tocalcT, finish},
+             ixlm{!tocalcT, finish},
+             iylm{!tocalcT, finish},
+             ixlmr{!tocalcT, finish},
+             iylmr{!tocalcT, finish});
   } else {
-    taskexit(tdmo{!tocalcT, tostartL});
+    taskexit(tdmo{!tocalcT, tostartL},
+             ixlm{!tocalcT, finish},
+             iylm{!tocalcT, finish},
+             ixlmr{!tocalcT, finish},
+             iylmr{!tocalcT, finish});
   }
 }
\ No newline at end of file