User scripts
This commit is contained in:
39
configuration/user_scripts/psen_min_processing.py
Normal file
39
configuration/user_scripts/psen_min_processing.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import json
|
||||
from collections import deque
|
||||
from logging import getLogger
|
||||
|
||||
_logger = getLogger(__name__)
|
||||
|
||||
background = deque(maxlen=4)
|
||||
|
||||
DEFAULT_ROI_SIGNAL = None
|
||||
DEFAULT_ROI_BACKGROUND = None
|
||||
|
||||
|
||||
def get_roi_x_profile(image, roi):
|
||||
offset_x, size_x, offset_y, size_y = roi
|
||||
roi_image = image[offset_y:offset_y + size_y, offset_x:offset_x + size_x]
|
||||
|
||||
return roi_image.sum(0)
|
||||
|
||||
|
||||
def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, image_background_array=None):
|
||||
|
||||
processed_data = dict()
|
||||
|
||||
image_property_name = parameters["camera_name"]
|
||||
roi_signal = parameters.get("roi_signal", DEFAULT_ROI_SIGNAL)
|
||||
roi_background = parameters.get("roi_background", DEFAULT_ROI_BACKGROUND)
|
||||
|
||||
processed_data[image_property_name + ".processing_parameters"] = json.dumps({"roi_signal": roi_signal,
|
||||
"roi_background": roi_background})
|
||||
|
||||
if roi_signal:
|
||||
signal_profile = get_roi_x_profile(image, roi_signal)
|
||||
processed_data[image_property_name + ".roi_signal_x_profile"] = signal_profile
|
||||
|
||||
if roi_background:
|
||||
processed_data[image_property_name + ".roi_background_x_profile"] = get_roi_x_profile(image, roi_background)
|
||||
|
||||
return processed_data
|
||||
|
||||
Reference in New Issue
Block a user