Merge branch 'choose_int_downsample' into 'v3'
Choose a correlation resize factor rounded to an int See merge request openflexure/openflexure-microscope-server!541
This commit is contained in:
commit
aeb337f9d1
3 changed files with 47 additions and 3 deletions
|
|
@ -23,7 +23,10 @@ from openflexure_microscope_server.utilities import is_path_safe
|
|||
IS_WINDOWS = os.name == "nt"
|
||||
|
||||
STITCHING_CMD = "openflexure-stitch"
|
||||
STITCHING_RESOLUTION = (820, 616)
|
||||
|
||||
# The target width and height to correlate images. Used to choose
|
||||
# a suitable correlation_resize factor in scan_workflows
|
||||
TARGET_STITCHING_DIMENSION = 700
|
||||
STITCH_TILE_SIZE = 8192
|
||||
|
||||
DEFAULT_OVERLAP = 0.1
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from openflexure_microscope_server.scan_planners import (
|
|||
SmartSpiral,
|
||||
)
|
||||
from openflexure_microscope_server.stitching import (
|
||||
STITCHING_RESOLUTION,
|
||||
TARGET_STITCHING_DIMENSION,
|
||||
StitchingSettings,
|
||||
)
|
||||
from openflexure_microscope_server.things.autofocus import (
|
||||
|
|
@ -261,9 +261,19 @@ class RectGridWorkflow(
|
|||
|
||||
def _get_stitching_settings_model(self) -> StitchingSettings:
|
||||
"""Return a stitching settings model based on current settings."""
|
||||
# Use the save resolution and target stitch resolution to choose a unit fraction,
|
||||
# which makes correlating faster
|
||||
width, height = self.save_resolution
|
||||
# Target area in pixels
|
||||
target_area = TARGET_STITCHING_DIMENSION**2
|
||||
# Find N so that (width/N) * (height/N) ~ target_area
|
||||
# N^2 ~ (width * height) / target_area
|
||||
downsample_factor = max(1, round((width * height / target_area) ** 0.5))
|
||||
correlation_resize = 1 / downsample_factor
|
||||
|
||||
return StitchingSettings(
|
||||
overlap=self.overlap,
|
||||
correlation_resize=STITCHING_RESOLUTION[0] / self.save_resolution[0],
|
||||
correlation_resize=correlation_resize,
|
||||
)
|
||||
|
||||
def _build_scan_settings(self, base_kwargs: dict) -> RectGridSettingModelType:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue