Class LineIterator
The class is used to iterate over all the pixels on the raster line segment connecting two specified points.
public class LineIterator : UnmanagedObject, IDisposable
- Inheritance
-
LineIterator
- Implements
- Inherited Members
Constructors
LineIterator(Mat, Point, Point, int, bool)
Create a LineIterator that can be used to get each pixel of a raster line. The line will be clipped on the image boundaries
public LineIterator(Mat img, Point p1, Point p2, int connectivity = 8, bool leftToRight = false)
Parameters
img
MatThe image
p1
PointThe first point
p2
PointThe second point
connectivity
int8-connected or 4-connected
leftToRight
boolIf true, then the iteration is always done from the left-most point to the right most, not to depend on the ordering of pt1 and pt2 parameters
Properties
Count
The total number of pixels in the line
public int Count { get; set; }
Property Value
Data
Get or set the pixel data in the current position
public Array Data { get; set; }
Property Value
DataPtr
Native pointer to the pixel data at the current position
public nint DataPtr { get; }
Property Value
Pos
returns the current position in the image
public Point Pos { get; }
Property Value
Methods
DisposeObject()
Release unmanaged resources
protected override void DisposeObject()
MoveNext()
Move to the next point
public void MoveNext()
SampleLine(Mat, Point, Point, int, bool)
Copy the pixel data in the line to a new Mat that is of the same type.
public static Mat SampleLine(Mat img, Point p1, Point p2, int connectivity = 8, bool leftToRight = false)
Parameters
img
MatThe image to sample from
p1
PointThe first point
p2
PointThe second point
connectivity
int8-connected or 4-connected
leftToRight
boolIf true, then the iteration is always done from the left-most point to the right most, not to depend on the ordering of pt1 and pt2 parameters
Returns
- Mat
A new single column Mat of the same data type. The number of rows equals to the number of points on the sample line.