/// <summary>
        /// Compares the specified first image.
        /// </summary>
        /// <param name="firstImage">The first image.</param>
        /// <param name="secondImage">The second image.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">Bitmaps must be the same size.</exception>
        public Image Compare(Image firstImage, Image secondImage)
        {
            Guard.AssertNotNull(firstImage, nameof(firstImage));
            Guard.AssertNotNull(secondImage, nameof(secondImage));

            if (firstImage.Width != secondImage.Width || firstImage.Height != secondImage.Height)
            {
                throw new ArgumentException("Bitmaps must be the same size.");
            }

            var differenceMap    = BitmapAnalyzer.Analyze(firstImage, secondImage);
            var differenceLabels = Labeler.Label(differenceMap);
            var boundingBoxes    = BoundingBoxIdentifier.CreateBoundingBoxes(differenceLabels);
            var differenceBitmap = CreateImageWithBoundingBoxes(secondImage, boundingBoxes);

            return(differenceBitmap);
        }
Example #2
0
        public Bitmap Compare(Bitmap firstImage, Bitmap secondImage)
        {
            if (firstImage == null)
            {
                throw new ArgumentNullException("firstImage");
            }
            if (secondImage == null)
            {
                throw new ArgumentNullException("secondImage");
            }
            if (firstImage.Width != secondImage.Width || firstImage.Height != secondImage.Height)
            {
                throw new ArgumentException("Bitmaps must be the same size.");
            }

            var differenceMap    = BitmapAnalyzer.Analyze(firstImage, secondImage);
            var differenceLabels = Labeler.Label(differenceMap);
            var boundingBoxes    = BoundingBoxIdentifier.CreateBoundingBoxes(differenceLabels);
            var differenceBitmap = CreateImageWithBoundingBoxes(secondImage, boundingBoxes);

            return(differenceBitmap);
        }