-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Description
We have this helper function to replace 0 counts in background images.
essimaging/src/ess/imaging/normalize.py
Lines 204 to 224 in d614d5f
| def apply_threshold_to_background_image( | |
| background: CleansedOpenBeamImage, background_threshold: BackgroundPixelThreshold | |
| ) -> BackgroundImage: | |
| """Apply the threshold to the background image. | |
| Parameters | |
| ---------- | |
| background: | |
| Background image. | |
| background_threshold: | |
| Threshold for the background pixel values. | |
| Any pixel values less than ``background_threshold`` | |
| are replaced with ``background_threshold``. | |
| """ | |
| background = CleansedOpenBeamImage(background.copy(deep=False)) | |
| background.data = sc.where( | |
| background.data < background_threshold, background_threshold, background.data | |
| ) | |
| return BackgroundImage(background) |
It was needed because imaging workflows need to normalize sample data pixel by pixel, time bin by time bin.
It surprised people quite a few times that the normalization works but the normalized image does not look normalized if too many histogram bins have 0 counts.
It should either raise an exception or at least throw warning if there are too many 0 counts.
I'm not sure how to decide when it's too-many though.
Metadata
Metadata
Assignees
Labels
No labels