Пример #1
0
 private void AddTopLeftCorner(TopLeftCorner newCorner)
 {
     foreach (var corner in _topLeftCorners)
     {
         if (newCorner.N1(corner) < 2 * 10)
         {
             return;
         }
     }
     _topLeftCorners.Add(newCorner);
 }
Пример #2
0
        private void SetPixels(TopLeftCorner corner, RGB rgb, Position squarePosition)
        {
            int row    = (int)(corner.Position.Row + squarePosition.Row * _squareHeight);
            int column = (int)(corner.Position.Column + squarePosition.Column * _squareWidth);

            for (int i = 0; i < _squareHeight; i++)
            {
                if (row + i >= 0 && row + i <= _pixels.GetLength(0) && column + i >= 0 && column + i <= _pixels.GetLength(1))
                {
                    _pixels[row + i, column + i] = rgb;
                    _pixels[row + i, column + _squareWidth - i] = rgb;
                }
            }
        }
Пример #3
0
        private RGB GetPixel(TopLeftCorner corner, Tuple <double, double> coeffs, int shiftSquareRows = 0, int shiftSquareColumns = 0)
        {
            int row    = (int)(corner.Position.Row + (shiftSquareRows + coeffs.Item1) * _squareHeight);
            int column = (int)(corner.Position.Column + (shiftSquareColumns + coeffs.Item2) * _squareWidth);

            if (row >= 0 && row <= _pixels.GetLength(0) && column >= 0 && column <= _pixels.GetLength(1))
            {
                return(_pixels[row, column]);
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        private int DistanceSample(TopLeftCorner corner, Position squarePos)
        {
            int distance = 0;

            for (int i = 0; i < _coeffs.Count; i++)
            {
                var rgb = GetPixel(corner, _coeffs[i], squarePos.Row, squarePos.Column);
                //                Logger.Info($"To compare: {rgb} {corner.PixelSamples[i]}");
                if (rgb != null)
                {
                    distance += corner.PixelSamples[i].N1(rgb);
                }
                else
                {
                    distance += int.MaxValue / (_coeffs.Count + 1);
                }
            }
            Logger.Info($"Distance {squarePos.Row} {squarePos.Column} = {distance}");
            return(distance);
        }
Пример #5
0
 public int N1(TopLeftCorner rhs) => Position.N1(rhs.Position);