Skip to content

Commit

Permalink
add wave example
Browse files Browse the repository at this point in the history
  • Loading branch information
roflmaostc committed Feb 14, 2024
1 parent 9aa257c commit 1e47ac5
Showing 1 changed file with 48 additions and 11 deletions.
59 changes: 48 additions & 11 deletions examples/3_wave_optics_optimization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ using ImageShow, ImageIO, PlutoUI, IndexFunArrays, Optim, RadonKA, FileIO, Color
# ╔═╡ 50bb6567-4fea-4794-8a5d-2c519e065296
using CUDA

# ╔═╡ 86b8c061-2f0e-4e4d-9d5e-7694e152813a
using NDTools

# ╔═╡ bf0c719f-4fa7-4f58-b031-e535813acedf
md"""# Supplemental simulations
Note, in the publication we optimize a volume of 550x550x550 voxels which only runs on a large GPU (NVIDIA A100 with 80GB). Hence, here a smaller version which produces similar but not identical results because of a different discretization of the boat.
```bibtex
@misc{wechsler2024wave,
title={Wave optical model for tomographic volumetric additive manufacturing},
author={Felix Wechsler and Carlo Gigli and Jorge Madrid-Wolff and Christophe Moser},
year={2024},
eprint={2402.06283},
archivePrefix={arXiv},
primaryClass={physics.optics}
}
```
"""

# ╔═╡ ba186bc1-2d3d-4422-92b9-98e2657e2d47
md"# 0. Load packages
On the first run, Julia is going to install some packages automatically. So start this notebook and give it some minutes (5-10min) to install all packages.
Expand Down Expand Up @@ -80,17 +100,30 @@ loss = LossThreshold(thresholds=(0.65, 0.75))
# ╔═╡ 7f812aa1-7fae-40fd-8601-a5d8c19a5e49
md"# 2. Target"

# ╔═╡ f6f61a7e-7e2f-430b-801b-63c495ec79d6
begin
KK = 64
target_3D = box(Float32, (KK, KK, KK), (40, 40, 50)) .-
box(Float32, (KK, KK, KK), (30, 30, 50));
target = Float32.(Bool.(target_3D) .|| (rr2(size(target_3D)) .< 18^2))
target = target
end;
# ╔═╡ 1931aa0f-966e-4ca0-b6d6-2ff6995ff8cb
md"# 1. Load Benchy"

# ╔═╡ d708c3a1-6e59-4001-a93a-69442466a9d5
function load_benchy(sz, sz_file, path)
target = zeros(Float32, sz)
#@show size(load(joinpath(path, string("slice_", string(1, pad=3) ,".png"))))

for i in 0:sz_file[1]-1
target[:, :, 40 + i+1] .= select_region(Gray.(load(joinpath(path, string("boat_", string(i, pad=3) ,".png")))), new_size=(sz))
end

#target2 = zeros(Float32, sz)
#WaveOpticsPropagation.set_center!(target2, target
target2 = select_region(target, new_size=sz)
target2 = permutedims(target2, (3,1,2))[end:-1:begin, :, :]
return togoc(target2)
end

# ╔═╡ 70375fb2-a3f9-482d-b637-7b5867b1e2d0
target = permutedims(load_benchy((180, 180, 180), (100, 100, 100), "/home/felix/Downloads/benchy/files/output_100/"), (1,2,3));

# ╔═╡ 0594a1b3-cac0-4829-a801-78e2420022eb
md"z slide value $(@bind slice PlutoUI.Slider(axes(target_3D, 3), show_value=true, default=0.5))"
md"z slide value $(@bind slice PlutoUI.Slider(axes(target, 3), show_value=true, default=0.5))"

# ╔═╡ cc95eb12-e948-44ba-8165-edf6886efb37
simshow(Array(target[:, :, slice]))
Expand Down Expand Up @@ -135,7 +168,7 @@ res
md"Threshold value=$(@bind thresh4 PlutoUI.Slider(0:0.01:1, show_value=true, default=0.7))"

# ╔═╡ 605ba331-a480-492f-98aa-402155d33ebf
md"z slider value $(@bind slice2 PlutoUI.Slider(axes(target_3D, 3), show_value=true, default=0.5))"
md"z slider value $(@bind slice2 PlutoUI.Slider(axes(target, 3), show_value=true, default=0.5))"

# ╔═╡ 6e67afcc-597d-4c18-a351-e24c5b732f2d
[simshow(Array(printed[:, :, slice2]), set_one=false) simshow(ones((size(target, 1), 5))) simshow(thresh4 .< Array(printed[:, :, slice2])) simshow(ones((size(target, 1), 5))) simshow(target[:, :, slice2])]
Expand All @@ -150,6 +183,7 @@ md"angle $(@bind angle PlutoUI.Slider(axes(patterns, 2), show_value=true, defaul
simshow(Array(patterns[:,angle,:]), cmap=:turbo, set_one=true)

# ╔═╡ Cell order:
# ╟─bf0c719f-4fa7-4f58-b031-e535813acedf
# ╠═ba186bc1-2d3d-4422-92b9-98e2657e2d47
# ╠═874ffaea-c7ae-11ee-11c6-a7ddbc5bf852
# ╠═5d5d3113-e8d6-40a9-82d6-1d4f52e10d47
Expand All @@ -164,7 +198,10 @@ simshow(Array(patterns[:,angle,:]), cmap=:turbo, set_one=true)
# ╟─0cae8621-9b65-4506-b604-72719293d64d
# ╠═ed6b2393-0ebb-4a24-b872-7424723e1f98
# ╟─7f812aa1-7fae-40fd-8601-a5d8c19a5e49
# ╠═f6f61a7e-7e2f-430b-801b-63c495ec79d6
# ╟─1931aa0f-966e-4ca0-b6d6-2ff6995ff8cb
# ╠═86b8c061-2f0e-4e4d-9d5e-7694e152813a
# ╠═d708c3a1-6e59-4001-a93a-69442466a9d5
# ╠═70375fb2-a3f9-482d-b637-7b5867b1e2d0
# ╟─0594a1b3-cac0-4829-a801-78e2420022eb
# ╠═cc95eb12-e948-44ba-8165-edf6886efb37
# ╟─ceb4233f-efaa-4e78-922d-92acf6625ff3
Expand Down

0 comments on commit 1e47ac5

Please sign in to comment.