<s> from __future__ import division <EOL> import numpy as np <EOL> __all__ = [ '<STR_LIT>' ] <EOL> def moments ( img , p0 , p1 , cm = None , convert_to_float = True , normalize = False , normalise = False ) : <EOL> '''<STR_LIT>''' <EOL> if normalise : <EOL> normalize = True <EOL> if not np . issubdtype ( img . dtype , float ) and convert_to_float : <EOL> img = img . astype ( np . float64 ) <EOL> r , c = img . shape <EOL> p = np . arange ( c , dtype = float ) <EOL> if cm is not None : <EOL> p -= cm [ <NUM_LIT:1> ] <EOL> p **= p1 <EOL> if normalize : <EOL> p /= p . sum ( ) <EOL> inter = np . dot ( img , p ) <EOL> p = np . arange ( r , dtype = float ) <EOL> if cm is not None : <EOL> p -= cm [ <NUM_LIT:0> ] <EOL> p **= p0 <EOL> if normalize : <EOL> p /= p . sum ( ) <EOL> return np . dot ( inter , p ) </s>
