b6a99f89baa6de8bd3c97af186f1beb3ce85a2fa
[IRC.git] / Robust / src / Benchmarks / Scheduling / Tracking / IXLM.java
1 public class IXLM {
2     flag tomergeIXL;
3     flag toaddIXL;
4     flag finish;
5     
6     /* current processing image related */
7     float[] m_image;
8     int m_rows;
9     int m_cols;
10     
11     /* current processing image related */
12     float[] m_result;
13     int m_rows_r;
14     int m_cols_r;
15     
16     int m_counter;
17     
18     /* processing type */
19     int m_id_t; // 0--Ipyr1; 1--Ipyr2;
20     
21     /* constructor */
22     public IXLM(int tid,
23                 int counter,
24                 float[] data,
25                 int rows,
26                 int cols) {
27       this.m_id_t = tid;
28       this.m_counter = counter;
29       this.m_rows = this.m_rows_r = rows;
30       this.m_cols = this.m_cols_r = cols;
31       this.m_image = data;
32       this.m_result = new float[rows * cols];
33     }
34     
35     public int getIdT() {
36       return this.m_id_t;
37     }
38     
39     public int getRows() {
40       return this.m_rows;
41     }
42     
43     public int getCols() {
44       return this.m_cols;
45     }
46     
47     public float[] getImage() {
48       return this.m_image;
49     }
50     
51     public int getRowsR() {
52       return this.m_rows_r;
53     }
54     
55     public int getColsR() {
56       return this.m_cols_r;
57     }
58     
59     public float[] getResult() {
60       return this.m_result;
61     }
62     
63     public boolean addCalcSobelResult(IXL ixl) {
64       int startRow = ixl.getRowsRS();
65       int endRow = ixl.getRowsRE();
66       int i, j, k, cols;
67       float[] image, r;
68       
69       image = this.m_result;
70       this.m_counter--;
71       cols = this.m_cols_r;
72       
73       // clone data piece      
74       r = ixl.getResult();
75       k = 0;
76       for(i = startRow; i < endRow; i++) {
77         for(j = 0; j < cols; j++) {
78           image[i * cols + j] = r[k * cols + j];
79         }
80         k++;
81       }
82       
83       return (0 == this.m_counter);
84     }
85     
86     public void calcSobel_dX() {
87       int rows_k1, cols_k1, rows_k2, cols_k2;
88       int[] kernel_1, kernel_2;
89       float temp;
90       int kernelSize, startCol, endCol, halfKernel, startRow, endRow;
91       int k, i, j, kernelSum_1, kernelSum_2;
92       float[] result, image;
93       int rows = this.m_rows_r;
94       int cols = this.m_cols_r;
95
96       image = this.m_result;
97       
98       rows_k1 = 1;
99       cols_k1 = 3;
100       kernel_1 = new int[rows_k1 * cols_k1];
101       rows_k2 = 1;
102       cols_k2 = 3;
103       kernel_2 = new int[rows_k2 * cols_k2];   
104
105       kernel_1[0] = 1;
106       kernel_1[1] = 2;
107       kernel_1[2] = 1;
108
109       kernelSize = 3;
110       kernelSum_1 = 4;
111       
112       kernel_2[0] = 1;
113       kernel_2[1] = 0;
114       kernel_2[2] = -1;
115
116       kernelSum_2 = 2;
117
118       startCol = 1;           //((kernelSize)/2);
119       endCol = cols - 1;      //(int)(cols - (kernelSize/2));
120       halfKernel = 1;         //(kernelSize-1)/2;
121
122       startRow = 1;       //(kernelSize)/2;
123       endRow = (rows-1);  //(rows - (kernelSize)/2);
124
125       for(i=startRow; i<endRow; i++) {
126           for(j=startCol; j<endCol; j++) {
127               temp = 0;
128               for(k=-halfKernel; k<=halfKernel; k++) {
129                   temp += (float)(image[(i+k) * cols + j] 
130                                          * (float)(kernel_1[k+halfKernel]));
131               }
132               image[i * cols + j] = (float)(temp/kernelSum_1);
133               image[i * cols + j] = (float)(image[i * cols + j] + 128);
134           }
135       }
136     }
137     
138     public void printImage() {
139       //    result validation
140       for(int i=0; i<this.m_rows; i++) {
141           for(int j=0; j<this.m_cols; j++) {
142               System.printI((int)(this.m_image[i * this.m_cols + j]*10));
143           }
144       }
145     }
146     
147     public void printResult() {
148       //    result validation
149       for(int i=0; i<this.m_rows_r; i++) {
150           for(int j=0; j<this.m_cols_r; j++) {
151               System.printI((int)(this.m_result[i * this.m_cols_r + j]*10));
152           }
153       }
154     }
155 }