fn timing_scan(image: &Image, p0: Point, p1: Point) -> i32 {
    if p0.x < 0 || p0.y < 0 || p0.x >= image.w || p0.y >= image.h {
        return -1;
    }
    if p1.x < 0 || p1.y < 0 || p1.x >= image.w || p1.y >= image.h {
        return -1;
    }

    let mut run_length: i32 = 0;
    let mut count: i32 = 0;
    for (x, y) in Bresenham::new((p0.x, p0.y), (p1.x, p1.y)) {
        let pixel = i32::from(image[(y * image.w + x) as usize]);

        if pixel != 0 {
            if run_length >= 2 {
                count += 1;
            }
            run_length = 0;
        } else {
            run_length += 1;
        }
    }

    count
}
/// Do a Bresenham scan from one point to another and count the number
/// of black/white transitions.
Do a Bresenham scan from one point to another and count the number
of black/white transitions.
Do a Bresenham scan from one point to another and count the number of black / white transitions .
fn timing_scan(image: &Image, p0: Point, p1: Point) -> i32 {
    if p0.x < 0 || p0.y < 0 || p0.x >= image.w || p0.y >= image.h {
        return -1;
    }
    if p1.x < 0 || p1.y < 0 || p1.x >= image.w || p1.y >= image.h {
        return -1;
    }
    let mut run_length: i32 = 0;
    let mut count: i32 = 0;
    for (x, y) in Bresenham::new((p0.x, p0.y), (p1.x, p1.y)) {
        let pixel = i32::from(image[(y * image.w + x) as usize]);
        if pixel != 0 {
            if run_length >= 2 {
                count += 1;
            }
            run_length = 0;
        } else {
            run_length += 1;
        }
    }
    count
}
fn timing_scan ( image : & Image , p0 : Point , p1 : Point ) -> i32 { if p0 . x < 0 || p0 . y < 0 || p0 . x >= image . w || p0 . y >= image . h { return - 1 ; } if p1 . x < 0 || p1 . y < 0 || p1 . x >= image . w || p1 . y >= image . h { return - 1 ; } let mut run_length : i32 = 0 ; let mut count : i32 = 0 ; for ( x , y ) in Bresenham :: new ( ( p0 . x , p0 . y ) , ( p1 . x , p1 . y ) ) { let pixel = i32 :: from ( image [ ( y * image . w + x ) as usize ] ) ; if pixel != 0 { if run_length >= 2 { count += 1 ; } run_length = 0 ; } else { run_length += 1 ; } } count }
Do a Bresenham scan from one point to another and count the number
of black/white transitions.
Do a Bresenham scan from one point to another and count the number of black / white transitions .
image
&Image
p0
Point
p1
Point
image
&Image
p0
Point
p1
Point