def swirl(x, center=None, strength=1, radius=100, rotation=0, output_shape=None, order=1, mode='constant', cval=0, clip=True, preserve_range=False, is_random=False):
 assert (radius != 0), Exception('Invalid radius value')
 rotation = ((np.pi / 180) * rotation)
 if is_random:
  center_h = int(np.random.uniform(0, x.shape[0]))
  center_w = int(np.random.uniform(0, x.shape[1]))
  center = (center_h, center_w)
  strength = np.random.uniform(0, strength)
  radius = np.random.uniform(1e-10, radius)
  rotation = np.random.uniform((- rotation), rotation)
 max_v = np.max(x)
 if (max_v > 1):
  x = (x / max_v)
 swirled = skimage.transform.swirl(x, center=center, strength=strength, radius=radius, rotation=rotation, output_shape=output_shape, order=order, mode=mode, cval=cval, clip=clip, preserve_range=preserve_range)
 if (max_v > 1):
  swirled = (swirled * max_v)
 return swirled

def swirl ( x , center = None , strength = 1 , radius = 100 , rotation = 0 , output_shape = None , order = 1 , mode = 'constant' , cval = 0 , clip = True , preserve_range = False , is_random = False ) : assert ( radius != 0 ) , Exception ( 'Invalid radius value' ) rotation = ( ( np . pi / 180 ) * rotation ) if is_random : center_h = int ( np . random . uniform ( 0 , x . shape [ 0 ] ) ) center_w = int ( np . random . uniform ( 0 , x . shape [ 1 ] ) ) center = ( center_h , center_w ) strength = np . random . uniform ( 0 , strength ) radius = np . random . uniform ( 1e-10 , radius ) rotation = np . random . uniform ( ( - rotation ) , rotation ) max_v = np . max ( x ) if ( max_v > 1 ) : x = ( x / max_v ) swirled = skimage . transform . swirl ( x , center = center , strength = strength , radius = radius , rotation = rotation , output_shape = output_shape , order = order , mode = mode , cval = cval , clip = clip , preserve_range = preserve_range ) if ( max_v > 1 ) : swirled = ( swirled * max_v ) return swirled
perform a swirl transformation .