Ver.2 Non Maximal Suppression

Ver.2 Non Maximal Suppression

if( gradTheta[i][j] == 0 ){ // Compare with [left] and with [right]
if( (gradient[i][j] > gradient[i][j-1]) && (gradient[i][j] >
gradient[i][j+1]) ){
gradNonMax[i][j] = gradient[i][j];
}
else{
gradNonMax[i][j] = 0;
}
} //  End-3-if
else if( gradTheta[i][j] == 45 ){ //   [up-right]. [low-left].
if( (gradient[i][j] > gradient[i-1][j+1]) && (gradient[i][j] >
gradient[i+1][j-1]) ){
gradNonMax[i][j] = gradient[i][j];
}
else{
gradNonMax[i][j] = 0;
}
} //  End-3-else-if
else if( gradTheta[i][j] == 90 ){  // Compare With [up] and with [low]
if( (gradient[i][j] > gradient[i-1][j]) && (gradient[i][j] >
gradient[i+1][j]) ){
gradNonMax[i][j] = gradient[i][j];
}
else{
gradNonMax[i][j] = 0;
}
} //  End-3-else-if
else if( gradTheta[i][j] == 135 ){   //   [up-left].  [low-right].
if( (gradient[i][j] > gradient[i-1][j-1]) && (gradient[i][j] >
gradient[i+1][j+1]) ){
gradNonMax[i][j] = gradient[i][j];
}
else{
gradNonMax[i][j] = 0;
}
} //  End-3-else-if