#NEWLINE# def perturb( img , augmentation_params , target_shape = ( 50 , 50 ) , rng = np . random ) : #NEWLINE# #INDENT# tform_centering = build_centering_transform ( img . shape , target_shape ) #NEWLINE# ( tform_center , tform_uncenter ) = build_center_uncenter_transforms ( img . shape ) #NEWLINE# tform_augment = random_perturbation_transform ( rng = rng , ** augmentation_params ) #NEWLINE# tform_augment = ( ( target_shape + tform_augment ) + tform_center ) #NEWLINE# return fast_warp ( img , ( tform_centering + tform_augment ) , output_shape = target_shape , mode = 'constant' ) . astype ( 'float32' )