Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SemiSmoothNewton.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephan Hilb
SemiSmoothNewton.jl
Commits
56c40abb
Commit
56c40abb
authored
3 years ago
by
Stephan Hilb
Browse files
Options
Downloads
Patches
Plain Diff
use warping
there is still something wrong apparently since one observes smoothing after warping?
parent
57756e64
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/run.jl
+40
-14
40 additions, 14 deletions
scripts/run.jl
src/image.jl
+1
-1
1 addition, 1 deletion
src/image.jl
with
41 additions
and
15 deletions
scripts/run.jl
+
40
−
14
View file @
56c40abb
...
@@ -7,6 +7,7 @@ import DataFrames: DataFrame
...
@@ -7,6 +7,7 @@ import DataFrames: DataFrame
import
FileIO
import
FileIO
using
OpticalFlowUtils
using
OpticalFlowUtils
using
WriteVTK
:
paraview_collection
using
WriteVTK
:
paraview_collection
using
Plots
using
SemiSmoothNewton
using
SemiSmoothNewton
using
SemiSmoothNewton
:
HMesh
,
ncells
,
refine
using
SemiSmoothNewton
:
HMesh
,
ncells
,
refine
...
@@ -691,12 +692,13 @@ function optflow(ctx)
...
@@ -691,12 +692,13 @@ function optflow(ctx)
# coord flip
# coord flip
imgf0
=
from_img
(
ctx
.
params
.
imgf0
)
imgf0
=
from_img
(
ctx
.
params
.
imgf0
)
imgf1
=
from_img
(
ctx
.
params
.
imgf1
)
imgf1
=
from_img
(
ctx
.
params
.
imgf1
)
maxflow
=
4.6157
# Dimetrodon
size
(
imgf0
)
==
size
(
imgf1
)
||
size
(
imgf0
)
==
size
(
imgf1
)
||
throw
(
ArgumentError
(
"non-matching dimensions"
))
throw
(
ArgumentError
(
"non-matching dimensions"
))
m
=
2
m
=
2
#mesh = init_grid(imgf0; type=:vertex)
#mesh = init_grid(imgf0; type=:vertex)
mesh
=
init_grid
(
imgf0
,
1
,
1
)
mesh
=
init_grid
(
imgf0
,
(
size
(
imgf0
)
.÷
16
)
...
)
#mesh = init_grid(imgf0)
#mesh = init_grid(imgf0)
# optflow specific stuff
# optflow specific stuff
...
@@ -706,25 +708,33 @@ function optflow(ctx)
...
@@ -706,25 +708,33 @@ function optflow(ctx)
fw
=
FeFunction
(
Vg
,
name
=
"fw"
)
fw
=
FeFunction
(
Vg
,
name
=
"fw"
)
T
(
tdata
,
u
)
=
tdata
*
u
# tdata = nablafw
T
(
tdata
,
u
)
=
tdata
*
u
# tdata = nablafw
#
S(u, nablau) = nablau
S
(
u
,
nablau
)
=
nablau
S
(
u
,
nablau
)
=
u
#
S(u, nablau) = u
st
=
L1L2TVContext
(
"run"
,
mesh
,
m
;
T
,
tdata
=
nabla
(
fw
),
S
,
st
=
L1L2TVContext
(
"run"
,
mesh
,
m
;
T
,
tdata
=
nabla
(
fw
),
S
,
ctx
.
params
.
alpha1
,
ctx
.
params
.
alpha2
,
ctx
.
params
.
lambda
,
ctx
.
params
.
beta
,
ctx
.
params
.
alpha1
,
ctx
.
params
.
alpha2
,
ctx
.
params
.
lambda
,
ctx
.
params
.
beta
,
ctx
.
params
.
gamma1
,
ctx
.
params
.
gamma2
)
ctx
.
params
.
gamma1
,
ctx
.
params
.
gamma2
)
function
reproject
!
()
function
warp
!
()
project_img!
(
f0
,
imgf0
)
imgfw
=
warp_backwards
(
imgf1
,
sample
(
st
.
u
)
)
project_img!
(
f
1
,
imgf
1
)
project_img!
(
f
w
,
imgf
w
)
# TODO: should be warping from imgfw
# replace new tdata
fw
.
data
.=
f1
.
data
st
=
L1L2TVContext
(
"run"
,
mesh
,
st
.
d
,
st
.
m
,
T
,
nabla
(
fw
),
S
,
st
.
alpha1
,
st
.
alpha2
,
st
.
beta
,
st
.
lambda
,
st
.
gamma1
,
st
.
gamma2
,
st
.
est
,
st
.
g
,
st
.
u
,
st
.
p1
,
st
.
p2
,
st
.
du
,
st
.
dp1
,
st
.
dp2
)
g_optflow
(
x
;
u
,
f0
,
fw
,
nablafw
)
=
g_optflow
(
x
;
u
,
f0
,
fw
,
nablafw
)
=
nablafw
*
u
-
(
fw
-
f0
)
nablafw
*
u
-
(
fw
-
f0
)
interpolate!
(
st
.
g
,
g_optflow
;
st
.
u
,
f0
,
fw
,
nablafw
=
nabla
(
fw
))
interpolate!
(
st
.
g
,
g_optflow
;
st
.
u
,
f0
,
fw
,
nablafw
=
st
.
tdata
)
end
function
reproject!
()
project_img2!
(
f0
,
imgf0
)
project_img2!
(
f1
,
imgf1
)
end
end
reproject!
()
reproject!
()
warp!
()
save_step
(
i
)
=
save_step
(
i
)
=
output
(
st
,
joinpath
(
ctx
.
outdir
,
"output_
$
(lpad(i, 5, '0')).vtu"
),
output
(
st
,
joinpath
(
ctx
.
outdir
,
"output_
$
(lpad(i, 5, '0')).vtu"
),
...
@@ -734,14 +744,26 @@ function optflow(ctx)
...
@@ -734,14 +744,26 @@ function optflow(ctx)
pvd
=
paraview_collection
(
joinpath
(
ctx
.
outdir
,
"output.pvd"
))
do
pvd
pvd
=
paraview_collection
(
joinpath
(
ctx
.
outdir
,
"output.pvd"
))
do
pvd
pvd
[
i
]
=
save_step
(
i
)
pvd
[
i
]
=
save_step
(
i
)
while
true
while
true
for
k
in
1
:
10
for
j
in
1
:
4
norm_g_old
=
norm_l2
(
st
.
g
)
for
k
in
1
:
5
i
+=
1
step!
(
st
)
estimate!
(
st
)
pvd
[
i
]
=
save_step
(
i
)
println
()
end
warp!
()
norm_g
=
norm_l2
(
st
.
g
)
i
+=
1
i
+=
1
step!
(
st
)
estimate!
(
st
)
pvd
[
i
]
=
save_step
(
i
)
pvd
[
i
]
=
save_step
(
i
)
println
(
)
display
(
plot
(
colorflow
(
to_img
(
sample
(
st
.
u
));
maxflow
))
)
end
end
i
>=
50
&&
break
#continue
marked_cells
=
mark
(
st
;
theta
=
0.5
)
marked_cells
=
mark
(
st
;
theta
=
0.5
)
#marked_cells = Set(axes(mesh.cells, 2))
println
(
"refining ..."
)
println
(
"refining ..."
)
...
@@ -752,12 +774,16 @@ function optflow(ctx)
...
@@ -752,12 +774,16 @@ function optflow(ctx)
st
.
alpha1
,
st
.
alpha2
,
st
.
beta
,
st
.
lambda
,
st
.
gamma1
,
st
.
gamma2
,
st
.
alpha1
,
st
.
alpha2
,
st
.
beta
,
st
.
lambda
,
st
.
gamma1
,
st
.
gamma2
,
fs
.
est
,
fs
.
g
,
fs
.
u
,
fs
.
p1
,
fs
.
p2
,
fs
.
du
,
fs
.
dp1
,
fs
.
dp2
)
fs
.
est
,
fs
.
g
,
fs
.
u
,
fs
.
p1
,
fs
.
p2
,
fs
.
du
,
fs
.
dp1
,
fs
.
dp2
)
f0
,
f1
,
fw
=
(
fs
.
f0
,
fs
.
f1
,
fs
.
fw
)
f0
,
f1
,
fw
=
(
fs
.
f0
,
fs
.
f1
,
fs
.
fw
)
i
+=
1
pvd
[
i
]
=
save_step
(
i
)
println
(
"reprojecting ..."
)
println
(
"reprojecting ..."
)
reproject!
()
reproject!
()
i
+=
1
pvd
[
i
]
=
save_step
(
i
)
end
end
end
end
display
(
plot
(
colorflow
(
to_img
(
sample
(
st
.
u
)))))
display
(
plot
(
colorflow
(
to_img
(
sample
(
st
.
u
))
;
maxflow
)))
#CSV.write(joinpath(ctx.outdir, "energies.csv"), df)
#CSV.write(joinpath(ctx.outdir, "energies.csv"), df)
#saveimg(joinpath(ctx.outdir, "output_glob.png"), fetch_u(states.glob))
#saveimg(joinpath(ctx.outdir, "output_glob.png"), fetch_u(states.glob))
...
...
This diff is collapsed.
Click to expand it.
src/image.jl
+
1
−
1
View file @
56c40abb
export
interpolate_bilinear
,
halve
export
interpolate_bilinear
,
halve
,
warp_backwards
eval_neumann
(
img
,
x
)
=
img
[
clamp
.
(
Tuple
(
x
),
axes
(
img
))
...
]
eval_neumann
(
img
,
x
)
=
img
[
clamp
.
(
Tuple
(
x
),
axes
(
img
))
...
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment