pub fn perturb_localize(
        &self,
        image: &GrayImage,
        roi: &Point3<f32>,
        mut rng: impl RngCore,
        nperturbs: usize,
    ) -> Point2<f32> {
        let mut xs: Vec<f32> = Vec::with_capacity(nperturbs);
        let mut ys: Vec<f32> = Vec::with_capacity(nperturbs);
        let mut point = *roi;

        // println!("\ninit: {}", roi);
        for _ in 0..nperturbs {
            point.z = rng.sample(self.distrs.0) * roi.z;
            point.x = roi.z.mul_add(rng.sample(self.distrs.1), roi.x);
            point.y = roi.z.mul_add(rng.sample(self.distrs.1), roi.y);

            // println!("rand: {}", _roi);
            let result = self.localize(image, &point);

            xs.push(result.x);
            ys.push(result.y);
        }

        Point2::new(odd_median_mut(&mut xs), odd_median_mut(&mut ys))
    }
/// Estimate object location on the image with perturbation to increase accuracy.
///
/// ### Arguments
///
/// * `image` - Target image.
/// * `roi` - Initial location to start:
///   - `roi.x` initial position on image x-axis,
///   - `roi.y` initial position on image y-axis,
///   - `roi.z` initial window size (in pixels) to search.
/// * `rng` - Source for randomness.
/// * `nperturbs` - How many perturbations to make.
Estimate object location on the image with perturbation to increase accuracy.
Estimate object location on the image with perturbation to increase accuracy .
pub fn perturb_localize(
        &self,
        image: &GrayImage,
        roi: &Point3<f32>,
        mut rng: impl RngCore,
        nperturbs: usize,
    ) -> Point2<f32> {
        let mut xs: Vec<f32> = Vec::with_capacity(nperturbs);
        let mut ys: Vec<f32> = Vec::with_capacity(nperturbs);
        let mut point = *roi;
        // println!("\ninit: {}", roi);
        for _ in 0..nperturbs {
            point.z = rng.sample(self.distrs.0) * roi.z;
            point.x = roi.z.mul_add(rng.sample(self.distrs.1), roi.x);
            point.y = roi.z.mul_add(rng.sample(self.distrs.1), roi.y);
            // println!("rand: {}", _roi);
            let result = self.localize(image, &point);
            xs.push(result.x);
            ys.push(result.y);
        }
        Point2::new(odd_median_mut(&mut xs), odd_median_mut(&mut ys))
    }
pub fn perturb_localize ( & self , image : & GrayImage , roi : & Point3 < f32 > , mut rng : impl RngCore , nperturbs : usize , ) -> Point2 < f32 > { let mut xs : Vec < f32 > = Vec :: with_capacity ( nperturbs ) ; let mut ys : Vec < f32 > = Vec :: with_capacity ( nperturbs ) ; let mut point = * roi ; // println!("\ninit: {}", roi); for _ in 0 .. nperturbs { point . z = rng . sample ( self . distrs . 0 ) * roi . z ; point . x = roi . z . mul_add ( rng . sample ( self . distrs . 1 ) , roi . x ) ; point . y = roi . z . mul_add ( rng . sample ( self . distrs . 1 ) , roi . y ) ; // println!("rand: {}", _roi); let result = self . localize ( image , & point ) ; xs . push ( result . x ) ; ys . push ( result . y ) ; } Point2 :: new ( odd_median_mut ( & mut xs ) , odd_median_mut ( & mut ys ) ) }
Estimate object location on the image with perturbation to increase accuracy.
Estimate object location on the image with perturbation to increase accuracy .
&self
image
&GrayImage
roi
&Point3<f32>
rng
impl RngCore
nperturbs
usize
&self
image
&GrayImage
roi
&Point3<f32>
rng
impl RngCore
nperturbs
usize