示例#1
0
        /// <summary>
        /// Superimpose a monochrome image, and return the resulting image.
        /// </summary>
        /// <param name="img">A monochrome image.</param>
        /// <param name="reference">A reference to img1 for downsampling and rotation.</param>
        /// <returns></returns>
        public static Image SaveSuperimposedImage(Image img, Image reference)
        {
            //If image isn't monochrome format, throw exception
            if (img.PixelFormat != PixelFormat.Format1bppIndexed)
            {
                throw new Exception(imageFormatNotMonochrome);
            }

            //Construct two ImageAsPointCollection instances.
            ImageAsPointCollection pointCollection1 = new ImageAsPointCollection(img);
            ImageAsPointCollection pointCollection2 = new ImageAsPointCollection(reference);

            //Downsample
            pointCollection1 = DownSampling(pointCollection1, Math.Min(pointCollection1.listOfPoints.Count, pointCollection2.listOfPoints.Count));
            pointCollection2 = DownSampling(pointCollection2, Math.Min(pointCollection1.listOfPoints.Count, pointCollection2.listOfPoints.Count));

            //Translate
            pointCollection1 = Translate(pointCollection1);
            pointCollection2 = Translate(pointCollection2);

            //Uniform scale
            pointCollection1 = UniformScale(pointCollection1);
            pointCollection2 = UniformScale(pointCollection2);

            //Rotate
            pointCollection1 = RotateToReference(pointCollection2, pointCollection1);

            Image superimposedImage1 = pointCollection1.ToMonoImage();

            return superimposedImage1;
        }
示例#2
0
        /// <summary>
        /// Returns the translated version of a given image.
        /// </summary>
        /// <param name="img">A monochrome image.</param>
        /// <returns></returns>
        public static Image SaveTranslatedImage(Image img)
        {
            //If image isn't monochrome format, throw exception
            if (img.PixelFormat != PixelFormat.Format1bppIndexed)
            {
                throw new Exception(imageFormatNotMonochrome);
            }

            //Construct ImageAsPointCollection instance.
            ImageAsPointCollection pointCollection1 = new ImageAsPointCollection(img);

            //Translate
            pointCollection1 = Translate(pointCollection1);

            Image superimposedImage1 = pointCollection1.ToMonoImage();

            return superimposedImage1;
        }