Exemplo n.º 1
0
        public double[,] Compute(double[,] input)
        {
            int y, x, h, w, iy, ix;
            var outputHeight = Outputs.GetLength(0);
            var outputWidth  = Outputs.GetLength(1);

            Outputs     = new double[outputHeight, outputWidth];
            OutputCords = new bool[outputHeight, outputWidth];

            //сканируем изображение ядром
            for (y = 0; y < outputHeight; y++)
            {
                for (x = 0; x < outputWidth; x++)
                {
                    for (h = 0; h < _kernelSize; h++)
                    {
                        for (w = 0; w < _kernelSize; w++)
                        {
                            iy = y * _kernelSize;
                            ix = x * _kernelSize;

                            if (Outputs[y, x] < input[iy + h, ix + w])
                            {
                                Outputs[y, x]     = input[iy + h, ix + w];
                                OutputCords[y, x] = true;
                            }
                        }
                    }
                }
            }

            return(Outputs);
        }
Exemplo n.º 2
0
        public Matrix Compute(Matrix input)
        {
            int y, x, h, w, iy, ix;
            var outputHeight = Outputs.GetLength(0);
            var outputWidth  = Outputs.GetLength(1);

            var outputs     = new Matrix(new float[outputHeight, outputWidth]);
            var outputCords = new bool[inputHeight, inputWidth];

            //сканируем изображение ядром
            for (y = 0; y < outputHeight; y++)
            {
                for (x = 0; x < outputWidth; x++)
                {
                    iy = y * KernelSize;
                    ix = x * KernelSize;
                    (int y, int x)maxCord = (0, 0);

                    for (h = 0; h < KernelSize; h++)
                    {
                        for (w = 0; w < KernelSize; w++)
                        {
                            if (outputs[y, x] < input[iy + h, ix + w])
                            {
                                outputs[y, x] = input[iy + h, ix + w];
                                maxCord       = (iy + h, ix + w);
                            }
                        }
                    }

                    outputCords[maxCord.y, maxCord.x] = true;
                }
            }

            Outputs     = outputs;
            OutputCords = outputCords;

            return(outputs);
        }