Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change_overlap_prob_uniform_threshold #101

Merged
merged 5 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "m2stitch"
version = "0.1.1"
version = "0.2.0"
description = "M2Stitch"
authors = ["Yohsuke Fukai <[email protected]>"]
license = "MIT"
Expand Down
4 changes: 3 additions & 1 deletion src/m2stitch/_stage_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def compute_image_overlap(
return tuple(map(float, model["x"]))
elif model["fun"] < best_model["fun"]:
best_model = model
assert not best_model is None
assert (
not best_model is None
), "Overlap model estimation failed, try raising the value of overlap_prob_uniform_threshold" # noqa :
# best_model_params : Tuple[Float,Float,Float] = tuple(best_model["x"])
assert len(best_model["x"]) == 3
return tuple(map(float, best_model["x"]))
Expand Down
14 changes: 12 additions & 2 deletions src/m2stitch/stitching.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def stitch_images(
rows: Sequence[Any],
cols: Sequence[Any],
pou: Float = 3,
overlap_prob_uniform_threshold: Float = 80,
full_output: bool = False,
) -> Tuple[pd.DataFrame, dict]:
"""Compute image positions for stitching.
Expand All @@ -45,6 +46,11 @@ def stitch_images(
pou : Float, default 3
the "percent overlap uncertainty" parameter

overlap_prob_uniform_threshold : Float, default 80
the upper threshold for "uniform probability".
raise this value to ease assumption
that the displacement is following non-uniform distribution.

full_output : bool, default False
if True, returns the full computation result in the pd.DataFrame

Expand Down Expand Up @@ -105,9 +111,13 @@ def get_index(row, col):
for j, key in enumerate(["ncc", "x", "y"]):
grid.loc[i2, f"{direction}_{key}_first"] = max_peak[j]

prob_uniform_n, mu_n, sigma_n = compute_image_overlap(grid, "top", W, H)
prob_uniform_n, mu_n, sigma_n = compute_image_overlap(
grid, "top", W, H, prob_uniform_threshold=overlap_prob_uniform_threshold
)
overlap_n = 100 - mu_n
prob_uniform_w, mu_w, sigma_w = compute_image_overlap(grid, "left", W, H)
prob_uniform_w, mu_w, sigma_w = compute_image_overlap(
grid, "left", W, H, prob_uniform_threshold=overlap_prob_uniform_threshold
)
overlap_w = 100 - mu_w

overlap_n = np.clip(overlap_n, pou, 100 - pou)
Expand Down