def _FSpecialGauss(size, sigma):
 radius = (size // 2)
 offset = 0.0
 (start, stop) = ((- radius), (radius + 1))
 if ((size % 2) == 0):
  offset = 0.5
  stop -= 1
 (x, y) = np.mgrid[(offset + start):stop, (offset + start):stop]
 assert (len(x) == size)
 g = np.exp((- (((x ** 2) + (y ** 2)) / (2.0 * (sigma ** 2)))))
 return (g / g.sum())

def _FSpecialGauss ( size , sigma ) : radius = ( size // 2 ) offset = 0.0 ( start , stop ) = ( ( - radius ) , ( radius + 1 ) ) if ( ( size % 2 ) == 0 ) : offset = 0.5 stop -= 1 ( x , y ) = np . mgrid [ ( offset + start ) : stop , ( offset + start ) : stop ] assert ( len ( x ) == size ) g = np . exp ( ( - ( ( ( x ** 2 ) + ( y ** 2 ) ) / ( 2.0 * ( sigma ** 2 ) ) ) ) ) return ( g / g . sum ( ) )
function to mimic the fspecial gaussian matlab function .