-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoisyMask.cpp
109 lines (93 loc) · 2.16 KB
/
noisyMask.cpp
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# include "noisyMask.h"
using namespace std;
NoisyMask::NoisyMask(void)
{
for (int x = 0 ; x < cxDim ; x++)
for (int y = 0 ; y < cyDim ; y++)
{
m_pixels[x][y] = 0;
m_pixelsBool[x][y] = true;
m_pixelsEnergy[x][y] = 0;
}
m_threshold = 10000000;
}
void NoisyMask::AddHit(int x, int y, double energy)
{
m_pixels[x][y]++;
m_pixelsEnergy[x][y] += energy;
}
void NoisyMask::Clear(void)
{
for (int x = 0 ; x < cxDim ; x++)
for (int y = 0 ; y < cyDim ; y++)
{
m_pixels[x][y] = 0;
m_pixelsEnergy[x][y] = 0;
}
}
void NoisyMask::MaskBorder(void)
{
for (int x = 0 ; x < cxDim ; x++)
for (int y = 0 ; y < cyDim ; y++)
{
if ((x == 0)||(y == 0)||(x == 255)||(y == 255)||(x == 256)||(x == 511))
m_pixelsBool[x][y] = false;
}
}
int NoisyMask::Update(void)
{
m_nGood = 0;
for (int x = 0 ; x < cxDim ; x++)
for (int y = 0 ; y < cyDim ; y++)
{
if (m_pixels[x][y] >= m_threshold)
m_pixelsBool[x][y] = false;
else
m_nGood++;
}
return m_nGood;
}
void NoisyMask::SaveNoisyMask(void)
{
ofstream noisyMaskFile;
noisyMaskFile.open(m_noisyMaskFileName);
for (int y = 0 ; y < cyDim ; y++)
{
for (int x = 0 ; x < cxDim ; x++)
{
noisyMaskFile << m_pixelsBool[x][y] << " ";
}
noisyMaskFile << endl;
}
noisyMaskFile.close();
}
void NoisyMask::LoadNoisyMask(void)
{
ifstream noisyMaskFile;
noisyMaskFile.open(m_noisyMaskFileName);
for (int y = 0 ; y < cyDim ; y++)
{
for (int x = 0 ; x < cxDim ; x++)
{
noisyMaskFile >> m_pixelsBool[x][y];
}
}
noisyMaskFile.close();
}
void NoisyMask::CoutNoisyMask(void)
{
for (int y = 0 ; y < cyDim ; y++)
for (int x = 0 ; x < cxDim ; x++)
{
cout << m_pixelsBool[x][y];
}
cout << endl;
}
void NoisyMask::CoutNoisyMaskRow(int myRow)
{
for (int x = 0 ; x < cxDim ; x++)
{
cout << m_pixelsBool[x][myRow];
}
cout << endl;
}