From 3474f580382c68795ea3b8db70ee51a96cd403f6 Mon Sep 17 00:00:00 2001 From: Yohsuke Fukai Date: Sun, 13 Feb 2022 18:15:24 +0900 Subject: [PATCH 1/2] updated example --- examples/stitching_example.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/examples/stitching_example.py b/examples/stitching_example.py index dddf020..613f1a4 100755 --- a/examples/stitching_example.py +++ b/examples/stitching_example.py @@ -12,40 +12,42 @@ props_file_path = path.join(script_path, "../tests/data/testimages_props.csv") images = np.load(image_file_path) props = pd.read_csv(props_file_path, index_col=0) -rows = props["col"].to_list() -cols = props["row"].to_list() + +rows = props["row"].to_list() +cols = props["col"].to_list() print(images.shape) # must be 3-dim, with each dimension meaning (tile_index,x,y) print(rows) -# the row indices for each tile index. for example, [1,1,2,2,2,...] +# the row (second-last dim.) indices for each tile index. for example, [1,1,2,2,2,...] print(cols) -# the column indices for each tile index. for example, [2,3,1,2,3,...] +# the column (last dim.) indices for each tile index. for example, [2,3,1,2,3,...] -result_df, _ = m2stitch.stitch_images(images, rows, cols) +# Note : the row_col_transpose=True is kept only for the sake of version compatibility. +# In the mejor version, the row_col_transpose=False will be the default. +result_df, _ = m2stitch.stitch_images(images, rows, cols, row_col_transpose=False) -print(result_df["x_pos"]) -# the absolute x positions of the tiles print(result_df["y_pos"]) -# the absolute y positions of the tiles - +# the absolute y (second last dim.) positions of the tiles +print(result_df["x_pos"]) +# the absolute x (last dim.) positions of the tiles # stitching example -result_df["x_pos2"] = result_df["x_pos"] - result_df["x_pos"].min() result_df["y_pos2"] = result_df["y_pos"] - result_df["y_pos"].min() +result_df["x_pos2"] = result_df["x_pos"] - result_df["x_pos"].min() -size_x = images.shape[1] -size_y = images.shape[2] +size_y = images.shape[1] +size_x = images.shape[2] stitched_image_size = ( - result_df["x_pos2"].max() + size_x, result_df["y_pos2"].max() + size_y, + result_df["x_pos2"].max() + size_x, ) stitched_image = np.zeros_like(images, shape=stitched_image_size) for i, row in result_df.iterrows(): stitched_image[ - row["x_pos2"] : row["x_pos2"] + size_x, row["y_pos2"] : row["y_pos2"] + size_y, + row["x_pos2"] : row["x_pos2"] + size_x, ] = images[i] result_image_file_path = path.join(script_path, "stitched_image.npy") From 42a008448a12275afcf1b3592a4da2321d07b7d0 Mon Sep 17 00:00:00 2001 From: Yohsuke Fukai Date: Sun, 13 Feb 2022 18:19:09 +0900 Subject: [PATCH 2/2] ignored artifact --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d5b53cd..779028f 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ __pycache__/ tests/data/testimages_lowncc.npy tests/data/testimages_lowncc2.npy tests/data/testimages_lowncc2.csv +examples/stitched_image.npy