BioImager  5.0.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
Loading...
Searching...
No Matches
AbstractFloodFiller.cs
Go to the documentation of this file.
1using System.Diagnostics;
2using AForge;
3using Bitmap = AForge.Bitmap;
4using Color = AForge.Color;
5using PointF = AForge.PointF;
6using RectangleF = AForge.RectangleF;
7using RectangleD = AForge.RectangleD;
8using Rectangle = AForge.Rectangle;
9using Point = AForge.Point;
10namespace BioImager
11{
16 public abstract class AbstractFloodFiller
17 {
18
19 protected Bitmap bitmap;
20 protected ColorS tolerance = new ColorS(25, 25, 25);
21 protected ColorS fillColor = ColorS.FromColor(Color.Black);
22 protected bool fillDiagonally = false;
23 protected bool slow = false;
24
25 //cached bitmap properties
26 protected int bitmapWidth = 0;
27 protected int bitmapHeight = 0;
28 protected int bitmapStride = 0;
29 protected int bitmapPixelFormatSize = 0;
30 protected byte[] bitmapBits = null;
32
33 //internal int timeBenchmark = 0;
34 internal Stopwatch watch = new Stopwatch();
35
36 //internal, initialized per fill
37 //protected BitArray pixelsChecked;
38 protected bool[] pixelsChecked;
39 protected ColorS byteFillColor;
40 protected ColorS startColor;
41 //protected int stride;
42
44 {
45
46 }
47
49 {
50 if (configSource != null)
51 {
52 this.Bitmap = configSource.Bitmap;
53 this.FillColor = configSource.FillColor;
54 this.FillDiagonally = configSource.FillDiagonally; ;
55 this.Tolerance = configSource.Tolerance;
56 }
57 }
58
59 public ColorS FillColor
60 {
61 get { return fillColor; }
62 set { fillColor = value; }
63 }
64
65 public bool FillDiagonally
66 {
67 get { return fillDiagonally; }
68 set { fillDiagonally = value; }
69 }
70
71 public ColorS Tolerance
72 {
73 get { return tolerance; }
74 set { tolerance = value; }
75 }
76
78 {
79 get { return bitmap; }
80 set
81 {
82 bitmap = value;
83 }
84 }
85
86 public abstract void FloodFill(Point pt);
87 protected void PrepareForFloodFill(Point pt)
88 {
89 startColor = bitmap.GetPixel((int)pt.X, (int)pt.Y);
90 byteFillColor = new ColorS(fillColor.B, fillColor.G, fillColor.R);
91 bitmapStride = bitmap.Stride;
92 bitmapPixelFormatSize = bitmap.PixelFormatSize;
93 pixelFormat = bitmap.PixelFormat;
94 bitmapBits = bitmap.Bytes;
95 bitmapWidth = bitmap.SizeX;
96 bitmapHeight = bitmap.SizeY;
97 pixelsChecked = new bool[bitmapBits.Length / bitmapPixelFormatSize];
98 }
99 }
100}
AForge.Bitmap Bitmap
AForge.RectangleD RectangleD
AForge.RectangleF RectangleF
AForge.Color Color
AForge.Point Point
AForge.Rectangle Rectangle
AForge.PointF PointF
AForge.PixelFormat PixelFormat
The base class that the flood fill algorithms inherit from. Implements the basic flood filler functio...
AbstractFloodFiller(AbstractFloodFiller configSource)