public static double ModePixel(this MatrixData input) { double[] colMode = new double[input.NumberOfColumns]; for (int c = 0; c < input.NumberOfColumns; c++) { colMode[c] = input.Mode(c); } return(colMode.Average()); }
public static MatrixData SubtractIfLessThanMode(this MatrixData input, MatrixData input1) { MatrixData output = new MatrixData(input.NumberOfRows, input.NumberOfColumns); double[] colMode = new double[input.NumberOfColumns]; for (int c = 0; c < input.NumberOfColumns; c++) { colMode[c] = input1.Mode(c); } double modeVal = colMode.GroupBy(v => v) .OrderByDescending(g => g.Count()) .First() .Key; for (int r = 0; r < input.NumberOfRows; r++) { for (int c = 0; c < input.NumberOfColumns; c++) { output[r, c] = (input1[r, c] < modeVal)? input[r, c] - input1[r, c]: input[r, c]; } } return(output); }