fn find_target_point<F, R>(
    rng: &mut R,
    fractal: &F,
    camera: &Camera,
    dimensions: (u32, u32),
) -> Option<(u32, u32)>
where
    F: Fractal + Sync,
    R: Rng,
{
    let (width, height) = dimensions;

    let grayscaled = produce_image(fractal, camera, dimensions, None, |i| Rgb { data: [i; 3] });
    let blurred = imageops::blur(&grayscaled, 10.0);
    let black_point = {
        let start = (rng.gen_range(0, width), rng.gen_range(0, height));
        find_point(start, &blurred, |p| p.data[0] <= 128)
    };

    black_point.and_then(|black_point| {
        let edged = edges(&grayscaled);
        find_point(black_point, &edged, |p| p.data[0] >= 128)
    })
}
/// Find a good target point that will not be a black area:
///   - create a grayscale image
///   - blur the grayscale image
///   - find the nearest black point
///   - create an edge image of the first grayscaled image
///   - find the nearest white point on the edged image starting from the previous black point
Find a good target point that will not be a black area:
create a grayscale image
blur the grayscale image
find the nearest black point
create an edge image of the first grayscaled image
find the nearest white point on the edged image starting from the previous black point
Find a good target point that will not be a black area : create a grayscale image blur the grayscale image find the nearest black point create an edge image of the first grayscaled image find the nearest white point on the edged image starting from the previous black point
fn find_target_point<F, R>(
    rng: &mut R,
    fractal: &F,
    camera: &Camera,
    dimensions: (u32, u32),
) -> Option<(u32, u32)>
where
    F: Fractal + Sync,
    R: Rng,
{
    let (width, height) = dimensions;
    let grayscaled = produce_image(fractal, camera, dimensions, None, |i| Rgb { data: [i; 3] });
    let blurred = imageops::blur(&grayscaled, 10.0);
    let black_point = {
        let start = (rng.gen_range(0, width), rng.gen_range(0, height));
        find_point(start, &blurred, |p| p.data[0] <= 128)
    };
    black_point.and_then(|black_point| {
        let edged = edges(&grayscaled);
        find_point(black_point, &edged, |p| p.data[0] >= 128)
    })
}
fn find_target_point < F , R > ( rng : & mut R , fractal : & F , camera : & Camera , dimensions : ( u32 , u32 ) , ) -> Option < ( u32 , u32 ) > where F : Fractal + Sync , R : Rng , { let ( width , height ) = dimensions ; let grayscaled = produce_image ( fractal , camera , dimensions , None , | i | Rgb { data : [ i ; 3 ] } ) ; let blurred = imageops :: blur ( & grayscaled , 10.0 ) ; let black_point = { let start = ( rng . gen_range ( 0 , width ) , rng . gen_range ( 0 , height ) ) ; find_point ( start , & blurred , | p | p . data [ 0 ] <= 128 ) } ; black_point . and_then ( | black_point | { let edged = edges ( & grayscaled ) ; find_point ( black_point , & edged , | p | p . data [ 0 ] >= 128 ) } ) }
Find a good target point that will not be a black area:
 create a grayscale image
 blur the grayscale image
 find the nearest black point
 create an edge image of the first grayscaled image
 find the nearest white point on the edged image starting from the previous black point
Find a good target point that will not be a black area : create a grayscale image blur the grayscale image find the nearest black point create an edge image of the first grayscaled image find the nearest white point on the edged image starting from the previous black point
rng
&mut R
fractal
&F
camera
&Camera
dimensions
(u32, u32)
rng
&mut R
fractal
&F
camera
&Camera
dimensions
(u32, u32)