Add first deformation
This commit is contained in:
parent
3c2c30b0fb
commit
2840f86646
1 changed files with 14 additions and 8 deletions
22
ETA.py
22
ETA.py
|
@ -261,22 +261,28 @@ list_ = data[
|
|||
calibrations[ 'top' ][ 'y' ][ 'max' ] : calibrations[ 'down' ][ 'y' ][ 'min' ],
|
||||
border[ 'x' ][ 'min' ] : border[ 'x' ][ 'max' ]
|
||||
].copy()
|
||||
list_ -= np.min( list_ )
|
||||
list_ /= np.max( list_ )
|
||||
list_ -= np.min( list_ , axis = 0 )
|
||||
list_ /= np.max( list_ , axis = 0 )
|
||||
|
||||
size = border[ 'x' ][ 'max' ] - border[ 'x' ][ 'min' ]
|
||||
x_stripe = np.arange( border[ 'x' ][ 'min' ] + 1 * size / 4 , border[ 'x' ][ 'min' ] + 3 * size / 4 , 1 ).astype( int )
|
||||
x_stripe = np.arange( border[ 'x' ][ 'min' ] + 1 * size // 4 , border[ 'x' ][ 'min' ] + 3 * size // 4 , 1 ).astype( int )
|
||||
y_stripe = np.array( [
|
||||
np.where(
|
||||
list_[ : , x ] > 0.8
|
||||
)[0][0] for x in x_stripe
|
||||
)[0][0] for x in x_stripe
|
||||
] )
|
||||
|
||||
stripes = [ # list of polyval result for each stripe
|
||||
np.polyfit( x_strip , y_stripe , 2 )
|
||||
np.polyfit( x_stripe , y_stripe , 2 )
|
||||
]
|
||||
|
||||
# First deformation
|
||||
y_diff = np.polyval( stripes[0] , np.arange( 0 , size , 1 ) ).astype( int )
|
||||
results = np.zeros( ( list_.shape[1] , list_.shape[0] - np.max( y_diff ) ) )
|
||||
for i in range( list_.shape[1] ):
|
||||
results[i] = list_[ y_diff[ i ] : list_.shape[0] + y_diff[ i ] - np.max( y_diff ) , i ]
|
||||
results = results.transpose()
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
plt.plot( x_stripe , y_stripe )
|
||||
plt.plot( x_stripe , np.polyval( stripes[0] , x_stripe ) )
|
||||
plt.savefig( 'asset/stripe.png' )
|
||||
plt.imshow( results )
|
||||
plt.savefig( 'asset/deformation.png' )
|
||||
|
|
Loading…
Reference in a new issue