- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImagery.java
More file actions
Latest commit
77 lines (63 loc) · 1.78 KB
/
Copy pathImagery.java
File metadata and controls
77 lines (63 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
importjava.io.BufferedReader;
importjava.io.FileNotFoundException;
importjava.io.FileReader;
importjava.io.IOException;
publicclassImagery {
RGB[][] m_element;
intm_rowsize;
intm_colsize;
intm_testcase;
Stringm_imgtype;
voidLoadFromFile(Stringpathtofile) throwsIOException {
BufferedReaderin = newBufferedReader(newFileReader(pathtofile));
// get first line : image type
Stringline;
line = in.readLine();
m_testcase = Integer.parseInt(line);
// second line : empty
in.readLine();
// third line : type
m_imgtype=in.readLine();
// fourth line : column / width
m_colsize = Integer.parseInt(in.readLine());
// fifth line : row / height
m_rowsize = Integer.parseInt(in.readLine());
Stringdelimiter = " ";
//populate 2darray object in java
m_element = newRGB[m_colsize][m_rowsize];
for(inti=0;i<m_rowsize;i++) {
for(intj=0;j<m_colsize;j++) {
m_element[i][j] = newRGB();
}
}
for(intcur_row = 0; cur_row < m_rowsize; cur_row++) {
line = in.readLine();
String[] temp = line.split(delimiter);
intcol_count = temp.length, cur_col = 0;
for(intt=0;t<col_count;t++){
if(t%3 == 0) {
// initiate
m_element[cur_row][cur_col].red = Integer.parseInt(temp[t]);
}elseif(t%3 == 1) {
m_element[cur_row][cur_col].green = Integer.parseInt(temp[t]);
}
else { // n_count%3 == 2
m_element[cur_row][cur_col].blue = Integer.parseInt(temp[t]);
++cur_col;
}
}
}
}
voidDisplayImage() {
for (inti = 0; i < m_rowsize; ++i)
{
for (intj = 0; j < m_colsize; ++j)
{
System.out.println("Row #"+j);
System.out.println("Red : "+m_element[i][j].red);
System.out.println("Green : "+m_element[i][j].green);
System.out.println( "Blue : "+m_element[i][j].blue);
}
}
}
}