[][src]Struct opencv::imgproc::LineIterator

pub struct LineIterator { /* fields omitted */ }

Line iterator

The class is used to iterate over all the pixels on the raster line segment connecting two specified points.

The class LineIterator is used to get each pixel of a raster line. It can be treated as 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:

This example is not tested
// grabs pixels along the line (pt1, pt2)
// from 8-bit 3-channel image to the buffer
LineIterator it(img, pt1, pt2, 8);
LineIterator it2 = it;
vector<Vec3b> buf(it.count);

for(int i = 0; i < it.count; i++, ++it)
buf[i] = *(const Vec3b*)*it;

// alternative way of iterating through the line
for(int i = 0; i < it2.count; i++, ++it2)
{
Vec3b val = img.at<Vec3b>(it2.pos());
CV_Assert(buf[i] == val);
}

Methods

impl LineIterator[src]

pub fn as_raw_LineIterator(&self) -> *mut c_void[src]

pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self[src]

impl LineIterator[src]

pub fn new(
    img: &Mat,
    pt1: Point,
    pt2: Point,
    connectivity: i32,
    left_to_right: bool
) -> Result<LineIterator>
[src]

initializes the iterator

creates iterators for the line connecting pt1 and pt2 the line will be clipped on the image boundaries the line is 8-connected or 4-connected If leftToRight=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

C++ default parameters

  • connectivity: 8
  • left_to_right: false

pub fn pos(&self) -> Result<Point>[src]

returns coordinates of the current pixel

Trait Implementations

impl Send for LineIterator[src]

impl Drop for LineIterator[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]