private void CollectLines( short minLineIntensity )
{
int maxTheta = houghMap.GetLength( 0 );
int maxRadius = houghMap.GetLength( 1 );
short intensity;
bool foundGreater;
int halfHoughWidth = maxRadius >> 1;
// clean lines collection
lines.Clear( );
// for each Theta value
for ( int theta = 0; theta < maxTheta; theta++ )
{
// for each Radius value
for ( int radius = 0; radius < maxRadius; radius++ )
{
// get current value
intensity = houghMap[theta, radius];
if ( intensity < minLineIntensity )
continue;
foundGreater = false;
// check neighboors
for ( int tt = theta - localPeakRadius, ttMax = theta + localPeakRadius; tt < ttMax; tt++ )
{
// skip out of map values
if ( tt < 0 )
continue;
if ( tt >= maxTheta )
break;
// break if it is not local maximum
if ( foundGreater == true )
break;
for ( int tr = radius - localPeakRadius, trMax = radius + localPeakRadius; tr < trMax; tr++ )
{
// skip out of map values
if ( tr < 0 )
continue;
if ( tr >= maxRadius )
break;
// compare the neighboor with current value
if ( houghMap[tt, tr] > intensity )
{
foundGreater = true;
break;
}
}
}
// was it local maximum ?
if ( !foundGreater )
{
// we have local maximum
lines.Add( new HoughLine( 90.0 - maxSkewToDetect + (double) theta / stepsPerDegree, (short) ( radius - halfHoughWidth ), intensity, (double) intensity / maxMapIntensity ) );
}
}
}
lines.Sort( );
}