BioImager  3.9.1
A .NET microscopy imaging library. Supports various microscopes by using imported libraries & GUI automation. Supported libraries include PriorĀ® & ZeissĀ® & all devices supported by Micromanager 2.0 and python-microscope.
Loading...
Searching...
No Matches
BioImager.QueueLinearFloodFiller Class Reference

Implements the QueueLinear flood fill algorithm using array-based pixel manipulation. More...

Inheritance diagram for BioImager.QueueLinearFloodFiller:
BioImager.AbstractFloodFiller

Public Member Functions

 QueueLinearFloodFiller (AbstractFloodFiller configSource)
 
override void FloodFill (AForge.Point pt)
 Fills the specified point on the bitmap with the currently selected fill color. More...
 
- Public Member Functions inherited from BioImager.AbstractFloodFiller
 AbstractFloodFiller (AbstractFloodFiller configSource)
 
abstract void FloodFill (Point pt)
 

Protected Member Functions

bool CheckPixel (ref int px)
 
int CoordsToByteIndex (ref int x, ref int y)
 
int CoordsToPixelIndex (int x, int y)
 Returns the linear index for a pixel, given its x and y coordinates. More...
 
- Protected Member Functions inherited from BioImager.AbstractFloodFiller
void PrepareForFloodFill (Point pt)
 

Additional Inherited Members

- Protected Attributes inherited from BioImager.AbstractFloodFiller
Bitmap bitmap
 
ColorS tolerance = new ColorS(25, 25, 25)
 
ColorS fillColor = ColorS.FromColor(Color.Black)
 
bool fillDiagonally = false
 
bool slow = false
 
int bitmapWidth = 0
 
int bitmapHeight = 0
 
int bitmapStride = 0
 
int bitmapPixelFormatSize = 0
 
byte[] bitmapBits = null
 
PixelFormat pixelFormat
 
bool[] pixelsChecked
 
ColorS byteFillColor
 
ColorS startColor
 
- Properties inherited from BioImager.AbstractFloodFiller
ColorS FillColor [get, set]
 
bool FillDiagonally [get, set]
 
ColorS Tolerance [get, set]
 
Bitmap Bitmap [get, set]
 

Detailed Description

Implements the QueueLinear flood fill algorithm using array-based pixel manipulation.

Definition at line 8 of file QueueLinearFloodFiller.cs.

Constructor & Destructor Documentation

◆ QueueLinearFloodFiller()

BioImager.QueueLinearFloodFiller.QueueLinearFloodFiller ( AbstractFloodFiller  configSource)

Definition at line 16 of file QueueLinearFloodFiller.cs.

16: base(configSource) { }

Member Function Documentation

◆ CheckPixel()

bool BioImager.QueueLinearFloodFiller.CheckPixel ( ref int  px)
protected

summary>Calculates and returns the byte index for the pixel (x,y). param name="x">The x coordinate of the pixel whose byte index should be returned.

param name="y">The y coordinate of the pixel whose byte index should be returned.

Definition at line 207 of file QueueLinearFloodFiller.cs.

Referenced by BioImager.QueueLinearFloodFiller.FloodFill().

◆ CoordsToByteIndex()

int BioImager.QueueLinearFloodFiller.CoordsToByteIndex ( ref int  x,
ref int  y 
)
protected

Definition at line 257 of file QueueLinearFloodFiller.cs.

258 {
259 return (bitmapStride * y) + (x * bitmapPixelFormatSize);
260 }

◆ CoordsToPixelIndex()

int BioImager.QueueLinearFloodFiller.CoordsToPixelIndex ( int  x,
int  y 
)
protected

Returns the linear index for a pixel, given its x and y coordinates.

Parameters
xThe x coordinate of the pixel.
yThe y coordinate of the pixel.
Returns

Definition at line 268 of file QueueLinearFloodFiller.cs.

269 {
270 return (bitmapWidth * y) + x;
271 }

◆ FloodFill()

override void BioImager.QueueLinearFloodFiller.FloodFill ( AForge.Point  pt)

Fills the specified point on the bitmap with the currently selected fill color.

Parameters
ptThe starting point for the fill.

Definition at line 22 of file QueueLinearFloodFiller.cs.

23 {
24 watch.Reset();
25 watch.Start();
26
27 //***Prepare for fill.
28 PrepareForFloodFill(pt);
29
30 ranges = new FloodFillRangeQueue(((bitmapWidth + bitmapHeight) / 2) * 5);//new Queue<FloodFillRange>();
31
32 //***Get starting color.
33 int x = (int)pt.X; int y = (int)pt.Y;
34 int idx = CoordsToByteIndex(ref x, ref y);
35 startColor = bitmap.GetPixel((int)pt.X,(int)pt.Y);
36
37 bool[] pixelsChecked = this.pixelsChecked;
38
39 //***Do first call to floodfill.
40 LinearFill(ref x, ref y);
41
42 //***Call floodfill routine while floodfill ranges still exist on the queue
43 while (ranges.Count > 0)
44 {
45 //**Get Next Range Off the Queue
46 FloodFillRange range = ranges.Dequeue();
47
48 //**Check Above and Below Each Pixel in the Floodfill Range
49 int downPxIdx = (bitmapWidth * (range.Y + 1)) + range.StartX;//CoordsToPixelIndex(lFillLoc,y+1);
50 int upPxIdx = (bitmapWidth * (range.Y - 1)) + range.StartX;//CoordsToPixelIndex(lFillLoc, y - 1);
51 int upY = range.Y - 1;//so we can pass the y coord by ref
52 int downY = range.Y + 1;
53 int tempIdx;
54 for (int i = range.StartX; i <= range.EndX; i++)
55 {
56 //*Start Fill Upwards
57 //if we're not above the top of the bitmap and the pixel above this one is within the color tolerance
58 tempIdx = CoordsToByteIndex(ref i, ref upY);
59 if (range.Y > 0 && (!pixelsChecked[upPxIdx]) && CheckPixel(ref tempIdx))
60 LinearFill(ref i, ref upY);
61
62 //*Start Fill Downwards
63 //if we're not below the bottom of the bitmap and the pixel below this one is within the color tolerance
64 tempIdx = CoordsToByteIndex(ref i, ref downY);
65 if (range.Y < (bitmapHeight - 1) && (!pixelsChecked[downPxIdx]) && CheckPixel(ref tempIdx))
66 LinearFill(ref i, ref downY);
67 downPxIdx++;
68 upPxIdx++;
69 }
70
71 }
72
73 watch.Stop();
74 }
FloodFillRange Dequeue()
Removes and returns the FloodFillRange at the beginning of the queue.
int Count
Returns the number of items currently in the queue.

References BioImager.QueueLinearFloodFiller.CheckPixel(), BioImager.FloodFillRangeQueue.Count, and BioImager.FloodFillRangeQueue.Dequeue().


The documentation for this class was generated from the following file: