void FillWhiteField() { _flood = new ScanLineFloodAlgorithm(); _flood.ImageHeight = Image.RowCount; _flood.ImageWidth = Image.ColumnCount; _flood.FillCondition = WhiteFieldFillCondition; _flood.FillAction = WhiteFieldFillAction; // Reset all white points foreach(var point in _whiteBorder) { _pixelCodes[point.Y, point.X] = CellCodeToFloat(CellCode.Unvisited); } _currentWhiteField = 0; // For each white field start flood foreach(var point in _whiteBorder) { _flood.FloodFill(point.Y, point.X); _currentWhiteField += 1; } }
void FillShape(int y, int x) { _flood = new IterativeBasicFloodAlgorithm(); _flood.ImageHeight = Image.RowCount; _flood.ImageWidth = Image.ColumnCount; _flood.FillCondition = ShapeFillCondition; _flood.FillAction = ShapeFillAction; // Create new CalibrationShape and set index in pixelcodes _currentShape = new CalibrationShape(); _currentShape.Index = (uint)_currentWhiteField; _pixelCodes[y, x] = CellCodeToFloat(CellCode.Unvisited); _flood.FloodFill(y, x); _currentShape.FindCenter(); // Check if its primary shape -> should have very high red value if(PrimaryShapeChecker.CheckShape(_currentShape)) { CalibShapes[0] = _currentShape; } else { CalibShapes.Add(_currentShape); } }
void FillBackground() { _flood = new ScanLineFloodAlgorithm(); _flood.ImageHeight = Image.RowCount; _flood.ImageWidth = Image.ColumnCount; _flood.FillCondition = BackgroundFillCondition; _flood.FillAction = BackgroundFillAction; // Left/Right Side for(int dy = 0; dy < Image.RowCount; ++dy) { if(CompareCellCodes(_pixelCodes[dy, 0], CellCode.Unvisited)) { _flood.FloodFill(dy, 0); } if(CompareCellCodes(_pixelCodes[dy, Image.ColumnCount - 1], CellCode.Unvisited)) { _flood.FloodFill(dy, Image.ColumnCount - 1); } } // Top/Bottom Side for(int dx = 0; dx < Image.ColumnCount; ++dx) { if(CompareCellCodes(_pixelCodes[0, dx], CellCode.Unvisited)) { _flood.FloodFill(0, dx); } if(CompareCellCodes(_pixelCodes[Image.RowCount - 1, dx], CellCode.Unvisited)) { _flood.FloodFill(Image.RowCount - 1, dx); } } }