mirror of
https://github.com/Findus23/lightpollution.git
synced 2024-09-18 12:13:45 +02:00
init
This commit is contained in:
commit
acc87560f0
11 changed files with 82 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
.idea/
|
||||
*.npy
|
||||
fig.png
|
BIN
input.png
Normal file
BIN
input.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 683 B |
BIN
input.xcf
Normal file
BIN
input.xcf
Normal file
Binary file not shown.
BIN
input2.png
Normal file
BIN
input2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
BIN
input2.xcf
Normal file
BIN
input2.xcf
Normal file
Binary file not shown.
BIN
input_blur.png
Normal file
BIN
input_blur.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
BIN
input_blur.xcf
Normal file
BIN
input_blur.xcf
Normal file
Binary file not shown.
BIN
input_slight_blur.png
Normal file
BIN
input_slight_blur.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
BIN
input_slight_blur.xcf
Normal file
BIN
input_slight_blur.xcf
Normal file
Binary file not shown.
27
reconstruct.py
Normal file
27
reconstruct.py
Normal file
|
@ -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()
|
52
simulate.py
Normal file
52
simulate.py
Normal file
|
@ -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)
|
Loading…
Reference in a new issue