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"); } }
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()); }
public dynamic[] ProcessImage4(dynamic[] input) { //Turn the input vector into a matrix //This matrix represents the image MatrixData pixelMatrix = input.GetReShapedMatrix(19); //reduce the size of the image to 18x18 by removing // a random pixel from each row and column pixelMatrix = pixelMatrix.ReduceDimensionByOne(0).ReduceDimensionByOne(1); //Reduce the 18x18 image to 6x6 using a custom downsampling algorithm pixelMatrix = pixelMatrix.Convert18To6Px(false); return(pixelMatrix.GetVectorizedMatrix()); }