Add stripe detection (WIP)

This commit is contained in:
linarphy 2023-05-11 14:30:10 +02:00
parent 2e1c83b527
commit 3c2c30b0fb
No known key found for this signature in database
GPG key ID: 3D4AAAC3AD16E79C

49
ETA.py
View file

@ -230,32 +230,53 @@ calibration_areas = utils.consecutive( np.where( indicators == 10 )[0] )
calibration_sizes = [ len( calibration_area ) for calibration_area in calibration_areas ]
y_calibrations = [ calibration_areas[ i ] for i in np.argsort( calibration_sizes ) ][ -2 : ]
calibrations = [
{
calibrations = {
'top': {
'x': {
'min': border['x']['min'],
'max': border['x']['max']
'max': border['x']['max'],
},
'y': {
'min': border['y']['min'] + y_calibrations[0][ 0],
'max': border['y']['min'] + y_calibrations[0][-1]
}
'max': border['y']['min'] + y_calibrations[0][-1],
},
{
},
'down': {
'x': {
'min': border['x']['min'],
'max': border['x']['max']
'max': border['x']['max'],
},
'y': {
'min': border['y']['min'] + y_calibrations[1][ 0],
'max': border['y']['min'] + y_calibrations[1][-1]
}
'max': border['y']['min'] + y_calibrations[1][-1],
},
},
}
"""
stripes curves detection
"""
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_ )
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 )
y_stripe = np.array( [
np.where(
list_[ : , x ] > 0.8
)[0][0] for x in x_stripe
] )
stripes = [ # list of polyval result for each stripe
np.polyfit( x_strip , y_stripe , 2 )
]
import matplotlib.pyplot as plt
plt.imshow( data[
calibrations[1]['y']['min'] : calibrations[1]['y']['max'],
calibrations[1]['x']['min'] : calibrations[1]['x']['max']
] )
plt.savefig( 'asset/calibration_1.png' )
plt.plot( x_stripe , y_stripe )
plt.plot( x_stripe , np.polyval( stripes[0] , x_stripe ) )
plt.savefig( 'asset/stripe.png' )