Data Augmentation (Height Distortion: Sample Slope)
Python
It is expected that the data can be used for augmentation in neural network training.
main
0 files
Data Augmentation (Height …..py
Data Augmentation (Height …..py
927 bytes
import numpy as np
def _mlinedata(np_array):
"""
Used when mulitply of splited line data
"""
height, width = np_array.shape
x_line = np.linspace(0, width-1, width)
y_line = np.linspace(0, height, height)
return x_line, y_line
def _slope(value, slope_coeff=(0.5, 1)):
"""
slope_coeff = (position, slope)\n
position: 0 ~ 1 ratio\n
slope: dimensionless
"""
point_index = int(len(value)*slope_coeff[0])
value[point_index:] *= slope_coeff[1]
return value
def slope(Zdata_array, x_slope_coeff=(0,0.01), y_slope_coeff=(0,0.01)):
"""
slope_coeff = (position, slope)\n
position: 0 ~ 1 ratio\n
slope: dimensionless
"""
x_line, y_line = _mlinedata(Zdata_array)
dist_x = _slope(x_line,x_slope_coeff)
dist_y = _slope(y_line,y_slope_coeff)
mx, my = np.meshgrid(dist_x,dist_y)
return Zdata_array + mx + my
Comments (0)
No comments yet. Be the first to comment!