/// <summary> /// Dijkstra. Attempts to find the shortest path from start to end, only using pixels inside the "border pixel" collection that was discovered in FloodFill() <see cref="FloodFill"/> /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <returns></returns> private System.Collections.Generic.IList <Point> LeastCostPath(Point start, Point end) { var h = new IntervalHeap <Node>(new NodeCmpr()); var n = new Node { Back = null, Cost = 0, Point = start }; h.Add(n); _considered = new PixelTracker(_image.Width, _image.Height) { OutsideDefault = true }; while (!h.IsEmpty) { var node = h.DeleteMin(); if (node.Point.X == end.X && node.Point.Y == end.Y) { return(Backtrace(node)); } Follow(h, node, node.Point.X - 1, node.Point.Y - 1); Follow(h, node, node.Point.X - 1, node.Point.Y); Follow(h, node, node.Point.X - 1, node.Point.Y + 1); Follow(h, node, node.Point.X, node.Point.Y + 1); Follow(h, node, node.Point.X + 1, node.Point.Y + 1); Follow(h, node, node.Point.X + 1, node.Point.Y); Follow(h, node, node.Point.X + 1, node.Point.Y - 1); Follow(h, node, node.Point.X, node.Point.Y - 1); } return(new Point[] {}); }
public RenderManager(IRenderEngine engine, ILayoutBuilder layoutBuilder) { _renderEngine = engine; _pixelTracker = new PixelTracker(); _powerState = PowerState.On; _layoutBuilder = layoutBuilder; }
/// <summary> /// /// </summary> /// <param name="image">The image to operate on</param> /// <param name="startPoint">The pixel to start the search at</param> /// <param name="tolerance">How to calculate what counts as a boundary pixel. The higher the tolerance, the more different a pixel color must be to be considered "not in the same area"</param> public RegionFinder(Bitmap image, Point startPoint, uint tolerance) { try { _start = startPoint; _baseColor = image.GetPixel(startPoint.X, startPoint.Y); _image = image; _queue.Enqueue(startPoint); _considered = new PixelTracker(_image.Width, _image.Height) { OutsideDefault = true }; _considered.Add(startPoint.X, startPoint.Y); _fill.Add(startPoint); } catch (ArgumentOutOfRangeException ex) { Debug.WriteLine(ex.Message); } _toleranceSquared = Math.Pow(tolerance, 2); }