Beispiel #1
0
 internal void Register(Pylon pylon)
 {
     pylon.IsGrouped = true;
     PylonCount++;
     GroupRange = pylon.Range;
     SumPylonX += pylon.ImgX;
     SumPylonY += pylon.ImgY;
 }
Beispiel #2
0
 internal bool IsDiscardedBy(Pylon adjacent)
 {
     if (adjacent.IsBorder)
         return false;
     if (adjacent.Range < this.Range)
         return true;
     if (adjacent.Range == this.Range && !adjacent.IsHead)
         return true;
     return false;
 }
Beispiel #3
0
 private unsafe void ResetPylon(Pylon pylon, byte* scan0, int stride)
 {
     byte range = *(scan0 + pylon.ImgY * stride + pylon.ImgX);
     if (pylon.IsInsideImage(_MedianFilter.Radius, _ImgWidth, _ImgHeight)) {
         range = _MedianFilter.Calculate(pylon.ImgX, pylon.ImgY, scan0, stride);
     }
     pylon.ResetAt(range);
 }
Beispiel #4
0
        private void DiscardTailPylon(int gridRow, int gridCol, Pylon previous)
        {
            Pylon current = _Grid[gridRow, gridCol];
            if (!current.IsHead)
                return;

            Pylon adjacentE = _Grid[gridRow, gridCol + 1];
            Pylon adjacentW = _Grid[gridRow, gridCol - 1];
            Pylon adjacentN = _Grid[gridRow - 1, gridCol];
            Pylon adjacentS = _Grid[gridRow + 1, gridCol];

            bool visitedE = (previous == adjacentE) || current.IsDiscardedBy(adjacentE);
            bool visitedW = (previous == adjacentW) || current.IsDiscardedBy(adjacentW);
            bool visitedN = (previous == adjacentN) || current.IsDiscardedBy(adjacentN);
            bool visitedS = (previous == adjacentS) || current.IsDiscardedBy(adjacentS);

            if (visitedE || visitedN || visitedW || visitedS) {
                current.IsHead = false;
                if (!visitedE)  // go E
                    DiscardTailPylon(gridRow, gridCol + 1, current);
                if (!visitedN)  // go N
                    DiscardTailPylon(gridRow - 1, gridCol, current);
                if (!visitedW)  // go W
                    DiscardTailPylon(gridRow, gridCol - 1, current);
                if (!visitedS)  // go S
                    DiscardTailPylon(gridRow + 1, gridCol, current);
            }
        }
Beispiel #5
0
 private void PlacePylon(int gridRow, int gridCol)
 {
     int halfStep = _PyStep / 2;
     int imgX = (gridCol * _PyStep) + halfStep;
     int imgY = (gridRow * _PyStep) + halfStep;
     bool isBorder = (gridRow == 0 || gridRow == _GridRows - 1 ||
                        gridCol == 0 || gridCol == _GridCols - 1);
     Pylon pylon = new Pylon(imgX, imgY, isBorder);
     _Grid[gridRow, gridCol] = pylon;
 }