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:
linarphy 2023-05-05 17:05:28 +02:00
parent c26b4782ed
commit fcb3172399
No known key found for this signature in database
GPG key ID: 69BD8A7D97AD643E

69
ETA.py Normal file
View 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' )