public static Data IterateCells(CA ca, Data cellData, List <int> labels, float threshold) { var imageData = cellData.GetData(); int y = 0; foreach (float[] row in imageData) { int x = 0; foreach (float pixel_value in row) { int[] fp = new int[2]; fp[0] = x; fp[1] = y; Position p = new Position(fp); CellState s = cellData.GetCellState(p); ca.ProcessCell(cellData, labels, p, s); x++; } y++; } return(cellData); }
public CellState[][] Train(List <float[]> data, float threshold) { Data d = new Data(data); float maxIntensity = d.GetMaxIntensity(); CA ca = new CA(maxIntensity, threshold); List <int> labels = d.SeedValues(20, 40); for (int i = 0; i < 400; i++) { int y = 0; foreach (float[] row in data) { int x = 0; foreach (float pixel_value in row) { int[] fp = new int[2]; fp[0] = x; fp[1] = y; Position p = new Position(fp); CellState s = d.GetCellState(p); ca.ProcessCell(d, labels, p, s); x++; } y++; } "Iteration: {0} Num state transitions: {1}".Cout(i, ca.NumStateTransitions); if (ca.NumStateTransitions == 0) { break; } ca.NumStateTransitions = 0; } return(d.CellStates); }