def shear(x, intensity=0.1, is_random=False, row_index=0, col_index=1, channel_index=2, fill_mode='nearest', cval=0.0):
 if is_random:
  shear = np.random.uniform((- intensity), intensity)
 else:
  shear = intensity
 shear_matrix = np.array([[1, (- np.sin(shear)), 0], [0, np.cos(shear), 0], [0, 0, 1]])
 (h, w) = (x.shape[row_index], x.shape[col_index])
 transform_matrix = transform_matrix_offset_center(shear_matrix, h, w)
 x = apply_transform(x, transform_matrix, channel_index, fill_mode, cval)
 return x

def shear ( x , intensity = 0.1 , is_random = False , row_index = 0 , col_index = 1 , channel_index = 2 , fill_mode = 'nearest' , cval = 0.0 ) : if is_random : shear = np . random . uniform ( ( - intensity ) , intensity ) else : shear = intensity shear_matrix = np . array ( [ [ 1 , ( - np . sin ( shear ) ) , 0 ] , [ 0 , np . cos ( shear ) , 0 ] , [ 0 , 0 , 1 ] ] ) ( h , w ) = ( x . shape [ row_index ] , x . shape [ col_index ] ) transform_matrix = transform_matrix_offset_center ( shear_matrix , h , w ) x = apply_transform ( x , transform_matrix , channel_index , fill_mode , cval ) return x
shear an image randomly or non-randomly .