Ejemplo n.º 1
0
        public Matrix <U> Valid(Matrix <U> u)
        {
            var strat = new ConvolutionStrategy2D
            {
                FromInclusive = this.vc,

                ToExclusive = Vector.Build <int>().Dense(
                    u.RowCount - this.vc[0],
                    u.ColumnCount - this.vc[1]),

                TargetSize = Vector.Build <int>().Dense(
                    u.RowCount - 2 * this.vc[0],
                    u.ColumnCount - 2 * this.vc[1]),
            };

            return(this.Convolve(u, strat));
        }
Ejemplo n.º 2
0
        public Matrix <U> Same(Matrix <U> u)
        {
            var strat = new ConvolutionStrategy2D
            {
                FromInclusive = Vector.Build <int>().Dense(0, 0),

                ToExclusive = Vector.Build <int>().Dense(
                    u.RowCount,
                    u.ColumnCount),

                TargetSize = Vector.Build <int>().Dense(
                    u.RowCount,
                    u.ColumnCount),
            };

            return(this.Convolve(u, strat));
        }
Ejemplo n.º 3
0
        internal Matrix <U> Convolve(Matrix <U> u, ConvolutionStrategy2D strat)
        {
            var w = Matrix.Create(
                strat.TargetSize[0],
                strat.TargetSize[1],
                (r, c) => default(U));

            Parallel.For(strat.FromInclusive[0], strat.ToExclusive[0], r =>
            {
                for (var c = strat.FromInclusive[1]; c < strat.ToExclusive[1]; c++)
                {
                    var s = this.Accumulate(r, c, u);
                    w[r - strat.FromInclusive[0], c - strat.FromInclusive[1]] = s;
                }
            });

            return(w);
        }