Skip to content

Commit

Permalink
Merge pull request #101 from yfukai/change_overlap_prob_uniform_thres…
Browse files Browse the repository at this point in the history
…hold

Merge as coverage change is not a serious problem for now.
  • Loading branch information
yfukai authored Sep 22, 2021
2 parents 2d44f8c + 10bb1d9 commit c7b3fdd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
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

0 comments on commit c7b3fdd

Please sign in to comment.