コード例 #1
0
 public override IMatrixImage Invoke(IMatrixImage input)
 {
     if (Math.Round(X0Y0, 0) == X0Y0 &&
         Math.Round(X1Y0, 0) == X1Y0 &&
         Math.Round(X2Y0, 0) == X2Y0 &&
         Math.Round(X0Y1, 0) == X0Y1 &&
         Math.Round(X1Y1, 0) == X1Y1 &&
         Math.Round(X2Y1, 0) == X2Y1 &&
         Math.Round(X0Y2, 0) == X0Y2 &&
         Math.Round(X1Y2, 0) == X1Y2 &&
         Math.Round(X2Y2, 0) == X2Y2)
     {
         input.SlidingWindow(new MatrixOperation <int>(new int[, ] {
             { (int)X0Y0, (int)X1Y0, (int)X2Y0 },
             { (int)X0Y1, (int)X1Y1, (int)X2Y1 },
             { (int)X0Y2, (int)X1Y2, (int)X2Y2 },
         }, (int?)MinLimit, (int?)MaxLimit));
     }
     else
     {
         input.SlidingWindow(new MatrixOperation <double>(new double[, ] {
             { X0Y0, X1Y0, X2Y0 },
             { X0Y1, X1Y1, X2Y1 },
             { X0Y2, X1Y2, X2Y2 },
         }, MinLimit, MaxLimit));
     }
     return(input);
 }
コード例 #2
0
        //public static TElement Test<TElement>(IndexResolver<TElement> indexResolver)
        //{
        //}

        //public static bool UseContourFunc(this IMatrixImage image, out MatrixImage<byte> retImage, Func<byte[], byte> coreFunc, int width, int height, bool alwaysCreateNew = false)
        //{
        //}

        public static void Laplas(this IMatrixImage image)
        {
            var mask = new int[, ] {
                { -1, -2, -1 },
                { -2, 12, -2 },
                { -1, -2, -1 }
            };

            image.SlidingWindow(new MatrixOperation <int>(mask, 0, 255));
        }
コード例 #3
0
        public override IMatrixImage Invoke(IMatrixImage input)
        {
            input.SlidingWindow(new SigmaOperation(CoreWidth, CoreHeight, Aqd));
            //MethodImpl.Preview.Contours.Implementations.Laplas(input);

            //var image = input.ToByteImage(true);
            //foreach (var layer in image.SplitWithoutAlpha())
            //    layer.SlidingWindow(3, 3, Func);
            return(input);
        }
コード例 #4
0
 public override IMatrixImage Invoke(IMatrixImage input)
 {
     if (UseOpenCV)
     {
         OpenCvSharp.Mat mat = input.GetCVMat();
         input.SetCVMat(mat.MedianBlur(Width));
         mat.Dispose();
         return(input);
     }
     else
     {
         input.SlidingWindow(new MedianeOperation(Width, Height));
         //int offset = (Width * Height) / 2;
         //if (image is MatrixImage<byte> imgByte)
         //{
         //    foreach (var layer in imgByte.SplitWithoutAlpha())
         //        layer.SlidingWindow(Width, Height, a => a.OrderBy(a => a).ElementAt(offset));
         //}
         //else if (image is MatrixImage<short> imgInt16)
         //{
         //    foreach (var layer in imgInt16.SplitWithoutAlpha())
         //        layer.SlidingWindow(Width, Height, a => a.OrderBy(a => a).ElementAt(offset));
         //}
         //else if (image is MatrixImage<int> imgInt32)
         //{
         //    foreach (var layer in imgInt32.SplitWithoutAlpha())
         //        layer.SlidingWindow(Width, Height, a => a.OrderBy(a => a).ElementAt(offset));
         //}
         //else if (image is MatrixImage<long> imgInt64)
         //{
         //    foreach (var layer in imgInt64.SplitWithoutAlpha())
         //        layer.SlidingWindow(Width, Height, a => a.OrderBy(a => a).ElementAt(offset));
         //}
         //else if (image is MatrixImage<float> imgSingle)
         //{
         //    foreach (var layer in imgSingle.SplitWithoutAlpha())
         //        layer.SlidingWindow(Width, Height, a => a.OrderBy(a => a).ElementAt(offset));
         //}
         //else if (image is MatrixImage<double> imgDouble)
         //{
         //    foreach (var layer in imgDouble.SplitWithoutAlpha())
         //        layer.SlidingWindow(Width, Height, a => a.OrderBy(a => a).ElementAt(offset));
         //}
         //else throw new NotSupportedException();
         return(input);
     }
 }
コード例 #5
0
 public override IMatrixImage Invoke(IMatrixImage input)
 {
     double[,] x = new double[, ] {
         { 1, 2, 1 },
         { 0, 0, 0 },
         { -1, -2, -1 }
     };
     double[,] y = new double[, ] {
         { 1, 0, -1 },
         { 2, 0, -2 },
         { 1, 0, -1 }
     };
     input.SlidingWindow(new GxGyOperation(3, 3, x, y));
     return(input);
     //MatrixImage<byte> image = input.ToByteImage(true);
     //foreach (var layer in image.SplitWithoutAlpha())
     //    layer.SlidingWindow(3, 3, Func);
     //return image;
 }
コード例 #6
0
ファイル: Roberts.cs プロジェクト: GerFern/ImageProject
 public override IMatrixImage Invoke(IMatrixImage input)
 {
     double[,] x = new double[, ]
     {
         { 0, 0, 0 },
         { 0, 1, 0 },
         { 0, 0, 1 }
     };
     double[,] y = new double[, ]
     {
         { 0, 0, 0 },
         { 0, 0, 1 },
         { 0, 1, 0 }
     };
     input.SlidingWindow(new GxGyOperation(3, 3, x, y));
     //input.SlidingWindow(new RobertsOperation(3, 3), true);
     return(input);
     //var image = input.ToByteImage(true);
     //foreach (var layer in image.SplitWithoutAlpha())
     //    layer.SlidingWindow(3, 3, Func);
     //return image;
 }
コード例 #7
0
ファイル: Average.cs プロジェクト: GerFern/ImageProject
 public override IMatrixImage Invoke(IMatrixImage input)
 {
     input.SlidingWindow(new AverageOperation(CoreWidth, CoreHeight));
     return(input);
 }
コード例 #8
0
 public override IMatrixImage Invoke(IMatrixImage input)
 {
     input.SlidingWindow(new KaunOperations(CoreWidth, CoreHeight, Aqd));
     return(input);
 }