-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
644a764
commit b756643
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import pandas as pd | ||
import tifffile as tiff | ||
|
||
|
||
def make_mean_image_every_10deg(dataset_path): | ||
full_video = tiff.imread( | ||
f"{dataset_path}/derotated_image_stack_full_and_incremental.tif" | ||
) | ||
full_csv = pd.read_csv( | ||
f"{dataset_path}/derotated_image_stack_full_and_incremental.csv", | ||
delimiter=",", | ||
) | ||
|
||
mean_images = [] | ||
# images around 5, 10, 15, 20, etc. degrees | ||
tollerace_deg = 1 | ||
for angle in range(0, 360, 10): | ||
images = full_video[ | ||
np.where( | ||
np.abs(full_csv["rotation_angle"] - angle) < tollerace_deg | ||
) | ||
] | ||
mean_image = np.mean(images, axis=0) | ||
mean_images.append(mean_image) | ||
|
||
mean_images = np.array(mean_images) | ||
|
||
path_for_mean_images = Path(dataset_path) / "mean_images" | ||
Path(path_for_mean_images).mkdir(exist_ok=True) | ||
for i, mean_image in enumerate(mean_images): | ||
angle = i * 10 | ||
plt.imsave( | ||
f"{path_for_mean_images}/mean_image_{angle}.png", | ||
mean_image, | ||
cmap="gray", | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
dataset_path = sys.argv[1] | ||
make_mean_image_every_10deg(dataset_path) |