arte/utils/shape_fitter.py
def fit_circle_ransac(self,
                          apply_canny=True,
                          sigma=3,
                          display=False,
                          **keywords):
        '''Perform a circle fitting on the current mask using RANSAC algorithm

        Parameters
        ----------
            apply_canny: bool, default=True
                apply Canny edge detection before performing the fit.
            sigma: float, default=10
                if apply_canny is True, you can decide the Canny kernel size.
            display: bool, default=False
                it shows the result of the fit.
        '''
        self._shape_fitted = 'circle'
        self._method = 'ransac'
        img = np.asarray(self._mask.copy(), dtype=float)
        img[img > 0] = 128

        edge = img.copy()
        if apply_canny:
            edge = feature.canny(img, sigma)

        coords = np.column_stack(np.nonzero(edge))

        model, inliers = measure.ransac(
            coords, measure.CircleModel,
            keywords.pop('min_samples', 10), residual_threshold=0.01,
            max_trials=1000)
        cx, cy, r = model.params

        if display is True:
            print(r"Cx-Cy {:.2f}-{:.2f}, R {:.2f}".format(cx, cy, r))
            rr, cc = draw.disk((model.params[0], model.params[1]),
                               model.params[2],
                               shape=img.shape)
            img[rr, cc] += 512
            # plt.figure()
            self._dispnobl(img)

        self._params = model.params
        self._success = model.estimate(coords)
Perform a circle fitting on the current mask using RANSAC algorithm

        Parameters
        ----------
            apply_canny: bool, default=True
                apply Canny edge detection before performing the fit.
            sigma: float, default=10
                if apply_canny is True, you can decide the Canny kernel size.
            display: bool, default=False
                it shows the result of the fit.
        
Perform a circle fitting on the current mask using RANSAC algorithm
Parameters

bool, default=True
apply Canny edge detection before performing the fit.
sigma: float, default=10
if apply_canny is True, you can decide the Canny kernel size.
display: bool, default=False
it shows the result of the fit.
Perform a circle fitting on the current mask using RANSAC algorithm Parameters bool default = True apply Canny edge detection before performing the fit . sigma : float default = 10 if apply_canny is True you can decide the Canny kernel size . display : bool default = False it shows the result of the fit .
def fit_circle_ransac(self,
                          apply_canny=True,
                          sigma=3,
                          display=False,
                          **keywords):
        self._shape_fitted = 'circle'
        self._method = 'ransac'
        img = np.asarray(self._mask.copy(), dtype=float)
        img[img > 0] = 128
        edge = img.copy()
        if apply_canny:
            edge = feature.canny(img, sigma)
        coords = np.column_stack(np.nonzero(edge))
        model, inliers = measure.ransac(
            coords, measure.CircleModel,
            keywords.pop('min_samples', 10), residual_threshold=0.01,
            max_trials=1000)
        cx, cy, r = model.params
        if display is True:
            print(r"Cx-Cy {:.2f}-{:.2f}, R {:.2f}".format(cx, cy, r))
            rr, cc = draw.disk((model.params[0], model.params[1]),
                               model.params[2],
                               shape=img.shape)
            img[rr, cc] += 512
            self._dispnobl(img)
        self._params = model.params
        self._success = model.estimate(coords)
def fit_circle_ransac ( self , apply_canny = True , sigma = 3 , display = False , ** keywords ) : self . _shape_fitted = 'circle' self . _method = 'ransac' img = np . asarray ( self . _mask . copy ( ) , dtype = float ) img [ img > 0 ] = 128 edge = img . copy ( ) if apply_canny : edge = feature . canny ( img , sigma ) coords = np . column_stack ( np . nonzero ( edge ) ) model , inliers = measure . ransac ( coords , measure . CircleModel , keywords . pop ( 'min_samples' , 10 ) , residual_threshold = 0.01 , max_trials = 1000 ) cx , cy , r = model . params if display is True : print ( r"Cx-Cy {:.2f}-{:.2f}, R {:.2f}" . format ( cx , cy , r ) ) rr , cc = draw . disk ( ( model . params [ 0 ] , model . params [ 1 ] ) , model . params [ 2 ] , shape = img . shape ) img [ rr , cc ] += 512 self . _dispnobl ( img ) self . _params = model . params self . _success = model . estimate ( coords )
Perform a circle fitting on the current mask using RANSAC algorithm
Parameters
Perform a circle fitting on the current mask using RANSAC algorithm Parameters
'''Perform a circle fitting on the current mask using RANSAC algorithm

        Parameters
        ----------
            apply_canny: bool, default=True
                apply Canny edge detection before performing the fit.
            sigma: float, default=10
                if apply_canny is True, you can decide the Canny kernel size.
            display: bool, default=False
                it shows the result of the fit.
        ''' # plt.figure()
self
apply_canny
sigma
display