Beispiel #1
0
        public void Run(string fileName)
        {
            MatrixData m = new MatrixData(fileName, false, true, ',');

            for (int i = 0; i < 2; i++)
            {
                OutputSteps(m[i].GetReShapedMatrix(19), i.ToString());
            }

            void OutputSteps(MatrixData input, string dir)
            {
                string _dir = "Data\\" + dir + "";

                MatrixData pixelMatrix = input;

                pixelMatrix.Clamp(0, 255).UpScale(16).ToImage(_dir + "0.bmp");

                pixelMatrix = pixelMatrix.ReduceDimensionByOne(0).ReduceDimensionByOne(1);
                pixelMatrix.UpScale(16).Clamp(0, 255).ToImage(_dir + "1.bmp");

                pixelMatrix = pixelMatrix.Convert18To6Px(false);
                pixelMatrix.Clamp(0, 255);
                pixelMatrix.UpScale(16).ToImage(_dir + "3.bmp");
            }
        }
Beispiel #2
0
        public dynamic[] ProcessImage2(dynamic[] input)
        {
            //Turn the input vector into a matrix
            //This matrix represents the image
            MatrixData pixelMatrix = input.GetReShapedMatrix(19);

            //Get the emboss edge
            pixelMatrix = pixelMatrix.GetEmbossEdge();

            //Apply with hist EQ function
            pixelMatrix = pixelMatrix.HistEQ();

            //Crop 1 pixel off the edge of the image
            //this results in a 17x17 image
            pixelMatrix = pixelMatrix.CropEdges(1);

            //reduce the size of the image to 16x16 by removing
            // a random pixel from each row and column
            pixelMatrix = pixelMatrix.ReduceDimensionByOne(0).ReduceDimensionByOne(1);

            //Blur the image
            pixelMatrix = pixelMatrix.ApplyConvolutionFilter(blurFilter);

            //Reduce the 16x16 image to 8x8 using a custom downsampling algorithm
            pixelMatrix = pixelMatrix.DownScale(2);

            //Clamp the output matrix values between 0 and 255
            pixelMatrix = pixelMatrix.Clamp(0, 255);

            //return the pixel matrix as a vector
            // the size of this vector will be 36 (6x6)
            return(pixelMatrix.GetVectorizedMatrix());
        }
Beispiel #3
0
        public dynamic[] ProcessImage1(dynamic[] input)
        {
            //Turn the input vector into a matrix
            //This matrix represents the image
            MatrixData pixelMatrix = input.GetReShapedMatrix(19);

            //Sharpen the image
            pixelMatrix = pixelMatrix.ApplyConvolutionFilter(sharpenFilter);

            //Apply the SobelEdge filter
            pixelMatrix = pixelMatrix.GetSobelEdge();

            //reduce the size of the image to 18x18 by removing
            // a random pixel from each row and column
            pixelMatrix = pixelMatrix.ReduceDimensionByOne(0).ReduceDimensionByOne(1);

            //Blur the image
            pixelMatrix = pixelMatrix.ApplyConvolutionFilter(blurFilter);

            //Reduce the 18x18 image to 6x6 using a custom downsampling algorithm
            pixelMatrix = pixelMatrix.Convert18To6Px();

            //Clamp the output matrix values between 0 and 255
            pixelMatrix = pixelMatrix.Clamp(0, 255);

            //return the pixel matrix as a vector
            // the size of this vector will be 36 (6x6)
            return(pixelMatrix.GetVectorizedMatrix());
        }