commit acc87560f0b17b372121e2ebf5bbff28ca66147f Author: Lukas Winkler Date: Tue Jan 7 19:39:58 2020 +0100 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b75c10b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/ +*.npy +fig.png diff --git a/input.png b/input.png new file mode 100644 index 0000000..4e8c662 Binary files /dev/null and b/input.png differ diff --git a/input.xcf b/input.xcf new file mode 100644 index 0000000..93b2583 Binary files /dev/null and b/input.xcf differ diff --git a/input2.png b/input2.png new file mode 100644 index 0000000..9ea5535 Binary files /dev/null and b/input2.png differ diff --git a/input2.xcf b/input2.xcf new file mode 100644 index 0000000..94d0eb1 Binary files /dev/null and b/input2.xcf differ diff --git a/input_blur.png b/input_blur.png new file mode 100644 index 0000000..40bd6ea Binary files /dev/null and b/input_blur.png differ diff --git a/input_blur.xcf b/input_blur.xcf new file mode 100644 index 0000000..02b3dfc Binary files /dev/null and b/input_blur.xcf differ diff --git a/input_slight_blur.png b/input_slight_blur.png new file mode 100644 index 0000000..a3005db Binary files /dev/null and b/input_slight_blur.png differ diff --git a/input_slight_blur.xcf b/input_slight_blur.xcf new file mode 100644 index 0000000..e2aedae Binary files /dev/null and b/input_slight_blur.xcf differ diff --git a/reconstruct.py b/reconstruct.py new file mode 100644 index 0000000..69f1859 --- /dev/null +++ b/reconstruct.py @@ -0,0 +1,27 @@ +import math + +import numpy as np +from matplotlib import pyplot as plt + +width = 100 + +grid = np.zeros((width, width), dtype=np.uint64) + +all_data: dict = np.load("out.npy", allow_pickle=True).item() +print(all_data) +for y in range(width): + print(y) + for x in range(width): + for start, bins in all_data.items(): + pixpos = np.array([x, y]) + myradians = math.atan2(start[0] - x, start[1] - y) + angle = np.degrees(myradians) + if not np.isnan(angle): + bin = int(round(angle) % 360) + grid[x, y] += bins[bin] + # exit() +grid = grid.T +# grid[grid > 200] = 200 +plt.imshow(grid) +plt.colorbar() +plt.show() diff --git a/simulate.py b/simulate.py new file mode 100644 index 0000000..9d6977d --- /dev/null +++ b/simulate.py @@ -0,0 +1,52 @@ +import math + +import imageio +import matplotlib.pyplot as plt +import numpy as np +from scipy.ndimage import zoom, gaussian_filter + +img = imageio.imread('input_slight_blur.png') +print(img) +# img = zoom(img, 3) +width = 100 +numstarts = 6 +i = np.linspace(0, 360, numstarts, endpoint=False) +i += np.random.randint(-20, 20, numstarts) +r = width / 2.3 +ang = np.radians(i) +xstart = np.cos(ang) * r * np.random.randint(80, 110, numstarts) / 100 + width / 2 +ystart = np.sin(ang) * r * np.random.randint(80, 110, numstarts) / 100 + width / 2 +print(xstart, ystart) +plt.scatter(xstart, ystart, c="red") +plt.imshow(img) +plt.show() + +all_data = {} +show = True +for i in range(numstarts): + pos = (xstart[i], ystart[i]) + start = np.array(pos) + + bins = np.zeros(360) + for y, row in enumerate(img): + for x, value in enumerate(row): + pixpos = np.array([x, y]) + myradians = math.atan2(start[0] - x, start[1] - y) + angle = np.degrees(myradians) + # print(angle) + # exit() + if not np.isnan(angle): + bin = int(round(angle) % 360) + bins[bin] += value + else: + print(pixpos) + bins = gaussian_filter(bins, sigma=1) + all_data[pos] = bins + print(pos) + if show: + plt.plot(np.arange(0, 360), bins) + plt.xlabel("angle") + plt.savefig("fig.png") + plt.show() + show = False +np.save("out", all_data)