OpenCV
3.4.20-dev
Open Source Computer Vision
|
Class for iterating over all pixels on a raster line segment. More...
#include <opencv2/imgproc.hpp>
Public Member Functions | |
LineIterator (const Mat &img, Point pt1, Point pt2, int connectivity=8, bool leftToRight=false) | |
Initializes iterator object for the given line and image. More... | |
uchar * | operator* () |
Returns pointer to the current pixel. More... | |
LineIterator & | operator++ () |
Moves iterator to the next pixel on the line. More... | |
LineIterator | operator++ (int) |
Moves iterator to the next pixel on the line. More... | |
Point | pos () const |
Returns coordinates of the current pixel. More... | |
Public Attributes | |
int | count |
int | elemSize |
int | err |
int | minusDelta |
int | minusStep |
int | plusDelta |
int | plusStep |
uchar * | ptr |
const uchar * | ptr0 |
int | step |
Class for iterating over all pixels on a raster line segment.
The class LineIterator is used to get each pixel of a raster line connecting two specified points. It can be treated as a versatile implementation of the Bresenham algorithm where you can stop at each pixel and do some extra processing, for example, grab pixel values along the line or draw a line with an effect (for example, with XOR operation).
The number of pixels along the line is stored in LineIterator::count. The method LineIterator::pos returns the current position in the image:
cv::LineIterator::LineIterator | ( | const Mat & | img, |
Point | pt1, | ||
Point | pt2, | ||
int | connectivity = 8 , |
||
bool | leftToRight = false |
||
) |
Initializes iterator object for the given line and image.
The returned iterator can be used to traverse all pixels on a line that connects the given two points. The line will be clipped on the image boundaries.
img | Underlying image. |
pt1 | First endpoint of the line. |
pt2 | The other endpoint of the line. |
connectivity | Pixel connectivity of the iterator. Valid values are 4 (iterator can move up, down, left and right) and 8 (iterator can also move diagonally). |
leftToRight | If true, the line is traversed from the leftmost endpoint to the rightmost endpoint. Otherwise, the line is traversed from pt1 to pt2 . |
uchar* cv::LineIterator::operator* | ( | ) |
Returns pointer to the current pixel.
LineIterator& cv::LineIterator::operator++ | ( | ) |
Moves iterator to the next pixel on the line.
This is the prefix version (++it).
LineIterator cv::LineIterator::operator++ | ( | int | ) |
Moves iterator to the next pixel on the line.
This is the postfix version (it++).
Point cv::LineIterator::pos | ( | ) | const |
Returns coordinates of the current pixel.
int cv::LineIterator::count |
int cv::LineIterator::elemSize |
int cv::LineIterator::err |
int cv::LineIterator::minusDelta |
int cv::LineIterator::minusStep |
int cv::LineIterator::plusDelta |
int cv::LineIterator::plusStep |
uchar* cv::LineIterator::ptr |
const uchar* cv::LineIterator::ptr0 |
int cv::LineIterator::step |