Exemple #1
0
        /// <summary>
        /// gets point where the edge positions start to move away from the edge line
        /// </summary>
        /// <param name="distanceProcessor"></param>
        /// <returns></returns>
        private int?GetDiscTopEndY(IDistanceProcessor distanceProcessor)
        {
            var maxDistanceVarianceOnLine = GetMaxDistanceVarianceOnLine(distanceProcessor);

            var movingAwaySequentially = false;
            var yMovingAwayStartPt     = 0;

            var startIndex = _image.Height - _inputParams.MinPixelsForBaseDisc - 1;

            for (var y = startIndex; y >= 0; y--)
            {
                var distance = distanceProcessor.GetDistance(y);

                if (distance > maxDistanceVarianceOnLine)
                {
                    if (!movingAwaySequentially)
                    {
                        movingAwaySequentially = true;
                        yMovingAwayStartPt     = y;
                    }

                    if (distance >= _inputParams.MinPixelsForBaseDiscEndOfEdge)
                    {
                        return(yMovingAwayStartPt + 1 < _image.Height? yMovingAwayStartPt + 1 : (int?)null);
                    }
                }
                else
                {
                    movingAwaySequentially = false;
                }
            }

            return(null);
        }
Exemple #2
0
        private double GetMaxDistanceVarianceOnLine(IDistanceProcessor distanceProcessor)
        {
            var maxDistance = 0.0;

            for (int y = _image.Height - 1, ctr = 1; y >= 0 && ctr <= _inputParams.MinPixelsForBaseDisc; y--, ctr++)
            {
                var distance = Math.Abs(distanceProcessor.GetDistance(y));
                if (distance > maxDistance)
                {
                    maxDistance = distance;
                }
            }
            return(maxDistance);
        }