Merge branch 'background-UV' into 'v3'

Use the UV channels only to determine if an area is background or sample

Closes #300

See merge request openflexure/openflexure-microscope-server!211
This commit is contained in:
Joe Knapper 2025-04-08 10:30:17 +00:00
commit 2cffe21727

View file

@ -259,9 +259,12 @@ class BackgroundDetectThing(Thing):
raise RuntimeError(
"Background is not set: you need to calibrate background detection."
)
# This image is in LUV space. But the brightness (L) often changes as the
# height of the sample changes. Hence in the line below we are only using
# the UV (colour) channels.
return np.all(
np.abs(image - np.array(d.means)[np.newaxis, np.newaxis, :])
< np.array(d.standard_deviations)[np.newaxis, np.newaxis, :]
np.abs(image[:, :, 1:] - np.array(d.means[1:])[np.newaxis, np.newaxis, :])
< np.array(d.standard_deviations[1:])[np.newaxis, np.newaxis, :]
* self.tolerance,
axis=2,
)