BioLib  3.6.2
A GUI-less version of Bio .NET library for editing & annotating various microscopy image formats.
Loading...
Searching...
No Matches
Bio.Graphics.QueueLinearFloodFiller Class Reference

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

Inheritance diagram for Bio.Graphics.QueueLinearFloodFiller:
Bio.Graphics.AbstractFloodFiller

Public Member Functions

 QueueLinearFloodFiller (AbstractFloodFiller configSource)
 
override void FloodFill (Point pt)
 Fills the specified point on the bitmap with the currently selected fill color.
 
- Public Member Functions inherited from Bio.Graphics.AbstractFloodFiller
 AbstractFloodFiller (AbstractFloodFiller configSource)
 
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.
 
- Protected Member Functions inherited from Bio.Graphics.AbstractFloodFiller
void PrepareForFloodFill (Point pt)
 

Additional Inherited Members

- Protected Attributes inherited from Bio.Graphics.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
 
- Package Attributes inherited from Bio.Graphics.AbstractFloodFiller
- Properties inherited from Bio.Graphics.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 13 of file QueueLinearFloodFiller.cs.

Constructor & Destructor Documentation

◆ QueueLinearFloodFiller()

Bio.Graphics.QueueLinearFloodFiller.QueueLinearFloodFiller ( AbstractFloodFiller configSource)

Definition at line 21 of file QueueLinearFloodFiller.cs.

21: base(configSource) { }

Member Function Documentation

◆ CheckPixel()

bool Bio.Graphics.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 212 of file QueueLinearFloodFiller.cs.

◆ CoordsToByteIndex()

int Bio.Graphics.QueueLinearFloodFiller.CoordsToByteIndex ( ref int x,
ref int y )
protected

Definition at line 262 of file QueueLinearFloodFiller.cs.

263 {
264 return (bitmapStride * y) + (x * bitmapPixelFormatSize);
265 }

◆ CoordsToPixelIndex()

int Bio.Graphics.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 273 of file QueueLinearFloodFiller.cs.

274 {
275 return (bitmapWidth * y) + x;
276 }

◆ FloodFill()

override void Bio.Graphics.QueueLinearFloodFiller.FloodFill ( 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 27 of file QueueLinearFloodFiller.cs.

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

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