From 271c45b87344a1e6773578c494b7c1720b34e8d2 Mon Sep 17 00:00:00 2001 From: Joe Knapper Date: Thu, 9 Apr 2026 16:16:59 +0100 Subject: [PATCH] Scale blur in simulator based on objective --- .../things/camera/simulation.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/openflexure_microscope_server/things/camera/simulation.py b/src/openflexure_microscope_server/things/camera/simulation.py index d75c36e5..dcbc7cdc 100644 --- a/src/openflexure_microscope_server/things/camera/simulation.py +++ b/src/openflexure_microscope_server/things/camera/simulation.py @@ -383,9 +383,11 @@ class SimulatedCamera(BaseCamera): # Use npx to make each 1d index list 3D focused_np_img = canvas[np.ix_(x_indices, y_indices, z_indices)] - np_img = fast_resize_and_blur( - focused_np_img, sigma=np.abs(im_pos[2]) / 5, shape=self.shape - ) + + # Scale blurring based on objective + sigma = np.abs(im_pos[2]) * (self.objective / 20) ** 2 / 5 + + np_img = fast_resize_and_blur(focused_np_img, sigma=sigma, shape=self.shape) # Generate random noise by repeating 500 noise points, as the speed rather # than randomness is important for simulation. noise = RNG.normal(scale=self.noise_level, size=500).astype("int16")