(image, mask, alpha, sigma, alpha_affine=None, random_state=None)
return res_x, res_y
Elastic deformation of images as described in [Simard2003]_ (with modifications).
    .. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for
         Convolutional Neural Networks applied to Visual Document Analysis", in
         Proc. of the International Conference on Document Analysis and
         Recognition, 2003.

     Based on https://gist.github.com/erniejunior/601cdf56d2b424757de5
Elastic deformation of images as described in [Simard2003]_ (with modifications).
    .. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for
         Convolutional Neural Networks applied to Visual Document Analysis", in
         Proc. of the International Conference on Document Analysis and
         Recognition, 2003.
Elastic deformation of images as described in [ Simard2003 ] _ ( with modifications ) . .. [ Simard2003 ] Simard Steinkraus and Platt Best Practices for Convolutional Neural Networks applied to Visual Document Analysis in Proc . of the International Conference on Document Analysis and Recognition 2003 .
def elastic_transform(image, mask, alpha, sigma, alpha_affine=None, random_state=None):
    """Elastic deformation of images as described in [Simard2003]_ (with modifications).
    .. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for
         Convolutional Neural Networks applied to Visual Document Analysis", in
         Proc. of the International Conference on Document Analysis and
         Recognition, 2003.

     Based on https://gist.github.com/erniejunior/601cdf56d2b424757de5
    """
    if random_state is None:
        random_state = np.random.RandomState(None)

    shape = image.shape

    dx = gaussian_filter((random_state.rand(*shape) * 2 - 1), sigma) * alpha
    dy = gaussian_filter((random_state.rand(*shape) * 2 - 1), sigma) * alpha

    x, y = np.meshgrid(np.arange(shape[1]), np.arange(shape[0]))
    indices = np.reshape(y+dy, (-1, 1)), np.reshape(x+dx, (-1, 1))


    res_x = map_coordinates(image, indices, order=1, mode='reflect').reshape(shape)
    res_y = map_coordinates(mask, indices, order=1, mode='reflect').reshape(shape)
    return res_x, res_y
def elastic_transform ( image , mask , alpha , sigma , alpha_affine = None , random_state = None ) : if random_state is None : random_state = np . random . RandomState ( None ) shape = image . shape dx = gaussian_filter ( ( random_state . rand ( * shape ) * 2 - 1 ) , sigma ) * alpha dy = gaussian_filter ( ( random_state . rand ( * shape ) * 2 - 1 ) , sigma ) * alpha x , y = np . meshgrid ( np . arange ( shape [ 1 ] ) , np . arange ( shape [ 0 ] ) ) indices = np . reshape ( y + dy , ( - 1 , 1 ) ) , np . reshape ( x + dx , ( - 1 , 1 ) ) res_x = map_coordinates ( image , indices , order = 1 , mode = 'reflect' ) . reshape ( shape ) res_y = map_coordinates ( mask , indices , order = 1 , mode = 'reflect' ) . reshape ( shape ) return res_x , res_y