Last active
December 10, 2017 19:53
-
-
Save dabrowski-adam/04f2abc1cace7323b6d46b17710a3086 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Obraz::HMTtransformation(int structural_element, int h) { | |
// Structural element | |
bool hit[3][3]; // Matches 1 | |
bool miss[3][3]; // Matches 0 | |
Choose_HMT_Structural_Element(structural_element, h, hit, miss); | |
// Output image | |
int** r1 = new int*[y]; | |
int** g1 = new int*[y]; | |
int** b1 = new int*[y]; | |
// Visit each pixel | |
bool white, match; | |
for (int i = 1; i < y - 1; i++) { | |
r1[i] = new int[x]; | |
g1[i] = new int[x]; | |
b1[i] = new int[x]; | |
for (int j = 1; j < x - 1; j++) { | |
// Check if neighbours match st. element | |
match = true; | |
for (int p = 0; p < 3; p++) { | |
for (int d = 0; d < 3; d++) { | |
white = isWhite(i - 1 + p, j - 1 + d); | |
if ( (hit[p][d] && !white) || (miss[p][d] && white) ) { | |
match = false; | |
} | |
} | |
} | |
// Color the pixel accordingly | |
if (match) { | |
r1[i][j] = 255; | |
g1[i][j] = 255; | |
b1[i][j] = 255; | |
} else { | |
r1[i][j] = 0; | |
g1[i][j] = 0; | |
b1[i][j] = 0; | |
} | |
} | |
} | |
// Save output | |
for (int i = 1; i < y - 1; i++) | |
{ | |
for (int j = 1; j < x - 1; j++) | |
{ | |
r[i][j] = r1[i][j]; | |
g[i][j] = g1[i][j]; | |
b[i][j] = b1[i][j]; | |
} | |
} this->save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment