From 3c2c30b0fb4f14797429482cd140e4a507d1e975 Mon Sep 17 00:00:00 2001 From: linarphy Date: Thu, 11 May 2023 14:30:10 +0200 Subject: [PATCH] Add stripe detection (WIP) --- ETA.py | 49 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/ETA.py b/ETA.py index 9b92db6..20eb316 100644 --- a/ETA.py +++ b/ETA.py @@ -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' )