public static double MeanIfPixel(this MatrixData input, Func <double, bool> condition) { List <double> colMean = new List <double>(); for (int c = 0; c < input.NumberOfColumns; c++) { double d = input.MeanIf(c, condition); if (condition(d)) { colMean.Add(d); } } return(colMean.Average()); }