Ejemplo n.º 1
0
        /// <summary>
        /// Rectification filter for projective transformation.
        /// <para>Accord.NET internal call. Please see: <see cref="Accord.Imaging.Filters.Rectification"/> for details.</para>
        /// </summary>
        /// <param name="img">Image.</param>
        /// <param name="homography">The homography matrix used to map a image passed to the filter to the overlay image.</param>
        /// <param name="fillColor">The filling color used to fill blank spaces.</param>
        /// <returns>Rectified image.</returns>
        public static Bgra<byte>[,] Rectification(this Bgra<byte>[,] img, double[,] homography, Bgra<byte> fillColor)
        {
            Rectification r = new Rectification(homography);
            r.FillColor = fillColor.ToColor();

            return img.ApplyBaseTransformationFilter(r);
        }
        /// <summary>
        /// Converts an image to an bitmap.
        /// </summary>
        /// <param name="img">Input image.</param>
        /// <returns>Bitmap</returns>
        public static Bitmap ToBitmap(this Bgra <short>[,] img)
        {
            Bitmap bmp = null;

            using (var uImg = img.Lock())
            {
                bmp = toBitmap(uImg, PixelFormat.Format64bppArgb);
            }
            return(bmp);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The blending filter is able to blend two images using a homography matrix.
        /// A linear alpha gradient is used to smooth out differences between the two
        /// images, effectively blending them in two images. The gradient is computed
        /// considering the distance between the centers of the two images.
        /// </summary>
        /// <param name="im">Image.</param>
        /// <param name="overlayIm">The overlay image (also called the anchor).</param>
        /// <param name="homography">Homography matrix used to map a image passed to
        /// the filter to the overlay image specified at filter creation.</param>
        /// <param name="fillColor">The filling color used to fill blank spaces. The filling color will only be visible after the image is converted
        /// to 24bpp. The alpha channel will be used internally by the filter.</param>
        /// <param name="gradient">A value indicating whether to blend using a linear
        ///  gradient or just superimpose the two images with equal weights.</param>
        /// <param name="alphaOnly">A value indicating whether only the alpha channel
        /// should be blended. This can be used together with a transparency
        /// mask to selectively blend only portions of the image.</param>
        /// <returns>Blended image.</returns>
        public static Bgra<byte>[,] Blend(this Gray<byte>[,] im, Gray<byte>[,] overlayIm, MatrixH homography, Bgra<byte> fillColor, bool gradient = true, bool alphaOnly = false)
        {
            Bgra<byte>[,] resultImage = null;

            using (var uOverlayIm = overlayIm.Lock())
            {
                Blend blend = new Blend(homography, uOverlayIm.AsBitmap());
                blend.AlphaOnly = alphaOnly;
                blend.Gradient = gradient;
                blend.FillColor = fillColor.ToColor();

                resultImage = im.ApplyBaseTransformationFilter<Gray<byte>, Bgra<byte>>(blend);
            }

            return resultImage;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// The blending filter is able to blend two images using a homography matrix.
        /// A linear alpha gradient is used to smooth out differences between the two
        /// images, effectively blending them in two images. The gradient is computed
        /// considering the distance between the centers of the two images.
        /// </summary>
        /// <param name="im">Image.</param>
        /// <param name="overlayIm">The overlay image (also called the anchor).</param>
        /// <param name="homography">Homography matrix used to map a image passed to
        /// the filter to the overlay image specified at filter creation.</param>
        /// <param name="fillColor">The filling color used to fill blank spaces. The filling color will only be visible after the image is converted
        /// to 24bpp. The alpha channel will be used internally by the filter.</param>
        /// <param name="gradient">A value indicating whether to blend using a linear
        ///  gradient or just superimpose the two images with equal weights.</param>
        /// <param name="alphaOnly">A value indicating whether only the alpha channel
        /// should be blended. This can be used together with a transparency
        /// mask to selectively blend only portions of the image.</param>
        /// <returns>Blended image.</returns>
        public static Bgra <byte>[,] Blend(this Gray <byte>[,] im, Gray <byte>[,] overlayIm, MatrixH homography, Bgra <byte> fillColor, bool gradient = true, bool alphaOnly = false)
        {
            Bgra <byte>[,] resultImage = null;

            using (var uOverlayIm = overlayIm.Lock())
            {
                Blend blend = new Blend(homography, uOverlayIm.AsBitmap());
                blend.AlphaOnly = alphaOnly;
                blend.Gradient  = gradient;
                blend.FillColor = fillColor.ToColor();

                resultImage = im.ApplyBaseTransformationFilter <Gray <byte>, Bgra <byte> >(blend);
            }

            return(resultImage);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// The blending filter is able to blend two images using a homography matrix.
 /// A linear alpha gradient is used to smooth out differences between the two
 /// images, effectively blending them in two images. The gradient is computed
 /// considering the distance between the centers of the two images.
 /// <para>Homography matrix is set to identity.</para>
 /// <para>Fill color is set to black with alpha set to 0 (all zeros).</para>
 /// </summary>
 /// <param name="im">Image.</param>
 /// <param name="overlayIm">The overlay image (also called the anchor).</param>
 /// <param name="gradient">A value indicating whether to blend using a linear
 ///  gradient or just superimpose the two images with equal weights.</param>
 /// <param name="alphaOnly">A value indicating whether only the alpha channel
 /// should be blended. This can be used together with a transparency
 /// mask to selectively blend only portions of the image.</param>
 /// <returns>Blended image.</returns>
 public static Bgra<byte>[,] Blend(this Bgra<byte>[,] im, Bgra<byte>[,] overlayIm, bool gradient = true, bool alphaOnly = false)
 {
     return Blend(im, overlayIm, new MatrixH(Matrix.Identity(3)), new Bgra<byte>(), gradient, alphaOnly);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// The blending filter is able to blend two images using a homography matrix.
 /// A linear alpha gradient is used to smooth out differences between the two
 /// images, effectively blending them in two images. The gradient is computed
 /// considering the distance between the centers of the two images.
 /// <para>Homography matrix is set to identity.</para>
 /// <para>Fill color is set to black with alpha set to 0 (all zeros).</para>
 /// </summary>
 /// <param name="im">Image.</param>
 /// <param name="overlayIm">The overlay image (also called the anchor).</param>
 /// <param name="gradient">A value indicating whether to blend using a linear
 ///  gradient or just superimpose the two images with equal weights.</param>
 /// <param name="alphaOnly">A value indicating whether only the alpha channel
 /// should be blended. This can be used together with a transparency
 /// mask to selectively blend only portions of the image.</param>
 /// <returns>Blended image.</returns>
 public static Bgra <byte>[,] Blend(this Bgra <byte>[,] im, Bgra <byte>[,] overlayIm, bool gradient = true, bool alphaOnly = false)
 {
     return(Blend(im, overlayIm, new MatrixH(Matrix.Identity(3)), new Bgra <byte>(), gradient, alphaOnly));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Saves the specified image.
 /// </summary>
 /// <param name="image">Image to save.</param>
 /// <param name="fileName">Image filename.</param>
 public static void Save(this Bgra <double>[,] image, string fileName)
 {
     image.Save <Bgra <double> >(fileName);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Saves the specified image.
 /// </summary>
 /// <param name="image">Image to save.</param>
 /// <param name="fileName">Image filename.</param>
 public static void Save(this Bgra <ushort>[,] image, string fileName)
 {
     image.Save <Bgra <ushort> >(fileName);
 }
 /// <summary>
 /// Gets System.Drawing.Color from Bgra8 color.
 /// </summary>
 /// <param name="color">Color.</param>
 /// <returns>System.Drawing.Color</returns>
 public static System.Drawing.Color ToColor(this Bgra <byte> color)
 {
     return(Color.FromArgb(color.A, color.R, color.G, color.B));
 }
Ejemplo n.º 10
0
 public static CvScalar ToCvScalar(this Bgra <byte> color)
 {
     return(new CvScalar {
         V0 = color.B, V1 = color.G, V2 = color.R, V3 = color.A
     });
 }