public boolean process ( EllipseRotated_F64 input , EllipseRotated_F64 refined ) { refined . set ( input ) ; previous . set ( input ) ; for ( int iteration = 0 ; iteration < maxIterations ; iteration ++ ) { refined . set ( previous ) ; computePointsAndWeights ( refined ) ; if ( fitter . process ( samplePts . toList ( ) , weights . data ) ) { // Get the results in local coordinates UtilEllipse_F64 . convert ( fitter . getEllipse ( ) , refined ) ; // convert back into image coordinates double scale = previous . a ; refined . center . x = refined . center . x * scale + previous . center . x ; refined . center . y = refined . center . y * scale + previous . center . y ; refined . a *= scale ; refined . b *= scale ; } else { return false ; } // stop once the change between two iterations is insignificant if ( change ( previous , refined ) <= convergenceTol ) { return true ; } else { previous . set ( refined ) ; } } return true ; }
Refines provided list by snapping it to edges found in the image