// Get specified amount of lines with highest intensity private HoughLine[] GetMostIntensiveLines(int count) { // lines count int n = Math.Min(count, lines.Count); // result array HoughLine[] dst = new HoughLine[n]; lines.CopyTo(0, dst, 0, n); return(dst); }
/// <summary> /// Get specified amount of lines with highest <see cref="HoughLine.Intensity">intensity</see>. /// </summary> /// /// <param name="count">Amount of lines to get.</param> /// /// <returns>Returns array of most intesive lines. If there are no lines detected, /// the returned array has zero length.</returns> /// public HoughLine[] GetMostIntensiveLines(int count) { // lines count var n = Math.Min(count, this.lines.Count); // result array var dst = new HoughLine[n]; this.lines.CopyTo(0, dst, 0, n); return(dst); }
// Get specified amount of lines with highest intensity private HoughLine[] GetMostIntensiveLines( int count ) { // lines count int n = Math.Min( count, lines.Count ); // result array HoughLine[] dst = new HoughLine[n]; lines.CopyTo( 0, dst, 0, n ); return dst; }
// Get lines using theirs intensity value [0, 1] public HoughLine[] GetLinesByIntensity(double intensity) { short minIntensity = (short)(maxMapValue * intensity); int maxTheta = houghMap.GetLength(0); int maxR = houghMap.GetLength(1); short v; bool foundMax; int halfHoughWidth = maxR >> 1; ArrayList linesList = new ArrayList( ); // for each Theta value for (int theta = 0; theta < maxTheta; theta++) { // for each R value for (int r = 0; r < maxR; r++) { // get current value v = houghMap[theta, r]; foundMax = false; if (v < minIntensity) { continue; } // check neighboors for (int tt = theta - localPeakRadius, ttMax = theta + localPeakRadius; tt < ttMax; tt++) { if (tt < 0) { continue; } if ((foundMax == true) || (tt >= maxTheta)) { break; } for (int tr = r - localPeakRadius, trMax = r + localPeakRadius; tr < trMax; tr++) { if ((tr < 0) || ((tr == r) && (tt == theta))) { continue; } if (tr >= maxR) { break; } // compare the neighboor with current value if (houghMap[tt, tr] > v) { foundMax = true; break; } } } // if (!foundMax) { // we have local maximum linesList.Add(new HoughLine((short)theta, (short)(r - halfHoughWidth), v)); } } } // int linesCount = linesList.Count; HoughLine[] lines = new HoughLine[linesCount]; for (int i = 0; i < linesCount; i++) { lines[i] = (HoughLine)linesList[i]; } return(lines); }