/// <summary>
        /// Adds two 8-bit gray images.
        /// <para>Source and destination image must have the size.</para>
        /// </summary>
        /// <param name="src">Source image.</param>
        /// <param name="dst">Destination image.</param>
        /// <param name="srcOffset">The point in source image.</param>
        public static void AddTo(this Image<Gray<byte>> src, Image<Gray<byte>> dst, Point srcOffset)
        {
            Debug.Assert(src.Width == dst.Width && src.Height == dst.Height);

            byte* srcRow = (byte*)src.GetData(srcOffset.Y);
            byte* dstRow = (byte*)dst.ImageData;

            if (src.Stride == src.Width && dst.Stride == dst.Width)
            {
                int numElemsToAdd = src.Width * src.Height - (srcOffset.Y * src.Width + srcOffset.X);
                AddByteToByteVector(srcRow + srcOffset.X, dstRow, numElemsToAdd);
            }
            else
            {
                //first row
                int nElemsToAddFirstRow = src.Width - srcOffset.X;
                AddByteToByteVector(srcRow + srcOffset.X, dstRow, nElemsToAddFirstRow);

                //other rows
                srcRow += src.Stride;
                dstRow += dst.Stride;

                for (int r = srcOffset.Y + 1; r < src.Height; r++)
                {
                    AddByteToByteVector(srcRow, dstRow, src.Width);
                    srcRow += src.Stride;
                    dstRow += dst.Stride;
                }
            }
        }
        /// <summary>
        ///  Maximum cross-correlation feature point matching algorithm.
        /// </summary>
        /// <param name="image1">First image.</param>
        /// <param name="image2">Second image.</param>
        /// <param name="points1">Points from the first image.</param>
        /// <param name="points2">Points from the second image.</param>
        /// <param name="windowSize">The size of the correlation window.</param>
        /// <param name="maxDistance">The maximum distance to consider points as correlated.</param>
        /// <returns>Matched point-pairs.</returns>
        public static Point[][] Match(Gray<byte>[,] image1, Gray<byte>[,] image2, Point[] points1, Point[] points2, int windowSize, int maxDistance)
        {
            Point[][] matches = null;

            using (var uImg1 = image1.Lock())
            using(var uImg2 = image2.Lock())
            {
                var correlationMatching = new CorrelationMatching(windowSize, maxDistance, uImg1.AsBitmap(), uImg2.AsBitmap());
                matches = correlationMatching.Match(points1.ToPoints(), points2.ToPoints()).ToPoints();
            }

            return matches;
        }