arte/utils/shape_fitter.py
def fit_annular_correlation(self,
                                method='Nelder-Mead',
                                display=False,
                                **keywords):
        '''Perform a annular circle fitting on the current mask using 
        minimization algorithm  with correlation merit functions.

        Tested with following minimizations methods: 'Nelder-Mead'. Relative 
        precision of 1% reached on synthetic images without noise.

        Parameters
        ----------
            method: string, default='Nelder-Mead'
                from scipy.optimize.minimize. Choose among 'Nelder-Mead'
            display: bool, default=False
                SLOWLY shows the progress of the fit.
            **keywords: dict, optional
                passed to scipy.optimize.minimize
        '''

        self._method = 'correlation ' + method
        img = np.asarray(self._mask.copy(), dtype=int)
        regions = measure.regionprops(img)
        bubble = regions[0]

        x0, y0 = bubble.centroid
        r = bubble.major_axis_length / 2.
        inr = r / 2
        if display:
            fign = plt.figure()

        self._shape_fitted = 'annulus'
        self._initial_guess = (x0, y0, r, inr)

        def _cost_annular_disk(params):
            x0, y0, r, inr = params
            coords = draw.disk((x0, y0), r, shape=img.shape)
            template = np.zeros_like(img)
            template[coords] = 1

            coords2 = draw.disk((x0, y0), inr, shape=img.shape)
            template2 = np.zeros_like(img)
            template2[coords2] = 1
            template -= template2

            if display:
                self._dispnobl(template + img, fign)

            merit_fcn = np.sum((template - img)**2)

            return np.sqrt(merit_fcn)

        linear_constraint = LinearConstraint(
            np.identity(4, float32), np.zeros(4),
            np.zeros(4) + np.max(img.shape))
        res = optimize.minimize(_cost_annular_disk, self._initial_guess,
                                method=method, constraints=linear_constraint,
                                **keywords)
        self._params = res.x
        self._success = res.success
        if res.success is False or (method != 'COBYLA' and res.nit == 0):
            raise Exception("Fit circle with hole didn't converge %s" % res)
Perform a annular circle fitting on the current mask using 
        minimization algorithm  with correlation merit functions.

        Tested with following minimizations methods: 'Nelder-Mead'. Relative 
        precision of 1% reached on synthetic images without noise.

        Parameters
        ----------
            method: string, default='Nelder-Mead'
                from scipy.optimize.minimize. Choose among 'Nelder-Mead'
            display: bool, default=False
                SLOWLY shows the progress of the fit.
            **keywords: dict, optional
                passed to scipy.optimize.minimize
        
Perform a annular circle fitting on the current mask using
minimization algorithm  with correlation merit functions.

Tested with following minimizations methods: 'Nelder-Mead'. Relative
precision of 1% reached on synthetic images without noise.

Parameters


Perform a annular circle fitting on the current mask using minimization algorithm with correlation merit functions . Tested with following minimizations methods : ' Nelder - Mead ' . Relative precision of 1% reached on synthetic images without noise . Parameters
def fit_annular_correlation(self,
                                method='Nelder-Mead',
                                display=False,
                                **keywords):
        self._method = 'correlation ' + method
        img = np.asarray(self._mask.copy(), dtype=int)
        regions = measure.regionprops(img)
        bubble = regions[0]
        x0, y0 = bubble.centroid
        r = bubble.major_axis_length / 2.
        inr = r / 2
        if display:
            fign = plt.figure()
        self._shape_fitted = 'annulus'
        self._initial_guess = (x0, y0, r, inr)
        def _cost_annular_disk(params):
            x0, y0, r, inr = params
            coords = draw.disk((x0, y0), r, shape=img.shape)
            template = np.zeros_like(img)
            template[coords] = 1
            coords2 = draw.disk((x0, y0), inr, shape=img.shape)
            template2 = np.zeros_like(img)
            template2[coords2] = 1
            template -= template2
            if display:
                self._dispnobl(template + img, fign)
            merit_fcn = np.sum((template - img)**2)
            return np.sqrt(merit_fcn)
        linear_constraint = LinearConstraint(
            np.identity(4, float32), np.zeros(4),
            np.zeros(4) + np.max(img.shape))
        res = optimize.minimize(_cost_annular_disk, self._initial_guess,
                                method=method, constraints=linear_constraint,
                                **keywords)
        self._params = res.x
        self._success = res.success
        if res.success is False or (method != 'COBYLA' and res.nit == 0):
            raise Exception("Fit circle with hole didn't converge %s" % res)
def fit_annular_correlation ( self , method = 'Nelder-Mead' , display = False , ** keywords ) : self . _method = 'correlation ' + method img = np . asarray ( self . _mask . copy ( ) , dtype = int ) regions = measure . regionprops ( img ) bubble = regions [ 0 ] x0 , y0 = bubble . centroid r = bubble . major_axis_length / 2. inr = r / 2 if display : fign = plt . figure ( ) self . _shape_fitted = 'annulus' self . _initial_guess = ( x0 , y0 , r , inr ) def _cost_annular_disk ( params ) : x0 , y0 , r , inr = params coords = draw . disk ( ( x0 , y0 ) , r , shape = img . shape ) template = np . zeros_like ( img ) template [ coords ] = 1 coords2 = draw . disk ( ( x0 , y0 ) , inr , shape = img . shape ) template2 = np . zeros_like ( img ) template2 [ coords2 ] = 1 template -= template2 if display : self . _dispnobl ( template + img , fign ) merit_fcn = np . sum ( ( template - img ) ** 2 ) return np . sqrt ( merit_fcn ) linear_constraint = LinearConstraint ( np . identity ( 4 , float32 ) , np . zeros ( 4 ) , np . zeros ( 4 ) + np . max ( img . shape ) ) res = optimize . minimize ( _cost_annular_disk , self . _initial_guess , method = method , constraints = linear_constraint , ** keywords ) self . _params = res . x self . _success = res . success if res . success is False or ( method != 'COBYLA' and res . nit == 0 ) : raise Exception ( "Fit circle with hole didn't converge %s" % res )
Perform a annular circle fitting on the current mask using
minimization algorithm  with correlation merit functions.
Perform a annular circle fitting on the current mask using minimization algorithm with correlation merit functions .
'''Perform a annular circle fitting on the current mask using 
        minimization algorithm  with correlation merit functions.

        Tested with following minimizations methods: 'Nelder-Mead'. Relative 
        precision of 1% reached on synthetic images without noise.

        Parameters
        ----------
            method: string, default='Nelder-Mead'
                from scipy.optimize.minimize. Choose among 'Nelder-Mead'
            display: bool, default=False
                SLOWLY shows the progress of the fit.
            **keywords: dict, optional
                passed to scipy.optimize.minimize
        '''
self
method
display