Add first ETA automated processing
Start of the transition from jupyter to plain python. Still WIP ! For now, only give the cropped image.
This commit is contained in:
parent
c26b4782ed
commit
fcb3172399
1 changed files with 69 additions and 0 deletions
69
ETA.py
Normal file
69
ETA.py
Normal file
|
@ -0,0 +1,69 @@
|
|||
import numpy as np
|
||||
import utils
|
||||
import sys
|
||||
|
||||
data = utils.load( sys.argv[1] )
|
||||
|
||||
"""
|
||||
find fill points
|
||||
"""
|
||||
points = []
|
||||
|
||||
points += utils.find_point( data[ : , 0 ] , 0 ) # x_min
|
||||
points += utils.find_point(
|
||||
data[ : , data.shape[1] - 1 ],
|
||||
data.shape[1] - 1 ,
|
||||
) # x_max
|
||||
|
||||
index_min = 0
|
||||
while data.shape[0] - 1 > index_min:
|
||||
index_min += 1
|
||||
if len( utils.find_point( data[ index_min , : ] , index_min , 'y' ) ) == 3:
|
||||
break
|
||||
|
||||
points.append(
|
||||
utils.find_point( data[ index_min , : ] , index_min , 'y' )[1]
|
||||
) # y_min
|
||||
|
||||
index_max = data.shape[0] - 1
|
||||
while index_min < index_max:
|
||||
index_max -= 1
|
||||
if len( utils.find_point( data[ index_max , : ] , index_max , 'y' ) ) == 3:
|
||||
break
|
||||
|
||||
|
||||
points.append(
|
||||
utils.find_point( data[ index_max , : ] , index_max , 'y' )[1]
|
||||
) # y_max
|
||||
|
||||
small_data = utils.compress( data , 5 )
|
||||
|
||||
points = utils.big_to_small( points , 5 )
|
||||
|
||||
points[ 1 ][ 1 ] -= 1
|
||||
points[ 3 ][ 0 ] -= 1
|
||||
|
||||
extremum = []
|
||||
for point in points:
|
||||
taken_points = utils.small_to_big( utils.fill( small_data , point , 1000 ) , 5 )
|
||||
extremum.append( [
|
||||
np.min( taken_points[ : , 1 ] ),
|
||||
np.max( taken_points[ : , 1 ] ),
|
||||
np.min( taken_points[ : , 0 ] ),
|
||||
np.max( taken_points[ : , 0 ] ),
|
||||
] )
|
||||
|
||||
border = {
|
||||
'x': {
|
||||
'min': extremum[0][1] + 1,
|
||||
'max': extremum[1][0] ,
|
||||
},
|
||||
'y': {
|
||||
'min': extremum[2][3] + 1,
|
||||
'max': extremum[3][2] ,
|
||||
},
|
||||
}
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
plt.imshow( data[ border[ 'y' ][ 'min' ] : border[ 'y' ][ 'max' ] , border[ 'x' ][ 'min' ] : border[ 'x' ][ 'max' ] ] )
|
||||
plt.savefig( 'test.png' )
|
Loading…
Reference in a new issue