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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephan Hilb
SemiSmoothNewton.jl
Commits
1962d312
Commit
1962d312
authored
Dec 6, 2021
by
Stephan Hilb
Browse files
Options
Downloads
Patches
Plain Diff
refactor
parent
ef4e839a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/run_experiments.jl
+13
-14
13 additions, 14 deletions
scripts/run_experiments.jl
src/image.jl
+7
-7
7 additions, 7 deletions
src/image.jl
with
20 additions
and
21 deletions
scripts/run_experiments.jl
+
13
−
14
View file @
1962d312
...
@@ -12,7 +12,7 @@ using Plots
...
@@ -12,7 +12,7 @@ using Plots
using
SemiSmoothNewton
using
SemiSmoothNewton
using
SemiSmoothNewton
:
HMesh
,
ncells
,
refine
,
area
,
mesh_size
,
ndofs
using
SemiSmoothNewton
:
HMesh
,
ncells
,
refine
,
area
,
mesh_size
,
ndofs
using
SemiSmoothNewton
:
project_
img!
,
project_img2
!
,
project!
using
SemiSmoothNewton
:
project_
l2_lagrange!
,
project_qi_lagrange
!
,
project!
using
SemiSmoothNewton
:
vtk_mesh
,
vtk_append!
,
vtk_save
using
SemiSmoothNewton
:
vtk_mesh
,
vtk_append!
,
vtk_save
include
(
"util.jl"
)
include
(
"util.jl"
)
...
@@ -501,7 +501,7 @@ function denoise(img; name, params...)
...
@@ -501,7 +501,7 @@ function denoise(img; name, params...)
ctx
=
L1L2TVContext
(
name
,
mesh
,
m
;
T
,
tdata
=
nothing
,
S
,
params
...
)
ctx
=
L1L2TVContext
(
name
,
mesh
,
m
;
T
,
tdata
=
nothing
,
S
,
params
...
)
project_
img
!
(
ctx
.
g
,
img
)
project_
l2_lagrange
!
(
ctx
.
g
,
img
)
#interpolate!(ctx.g, x -> evaluate_bilinear(img, x))
#interpolate!(ctx.g, x -> evaluate_bilinear(img, x))
#m = (size(img) .- 1) ./ 2 .+ 1
#m = (size(img) .- 1) ./ 2 .+ 1
#interpolate!(ctx.g, x -> norm(x .- m) < norm(m .- 1) / 3)
#interpolate!(ctx.g, x -> norm(x .- m) < norm(m .- 1) / 3)
...
@@ -538,7 +538,7 @@ function denoise(img; name, params...)
...
@@ -538,7 +538,7 @@ function denoise(img; name, params...)
ctx
,
_
=
refine
(
ctx
,
marked_cells
)
ctx
,
_
=
refine
(
ctx
,
marked_cells
)
test_mesh
(
ctx
.
mesh
)
test_mesh
(
ctx
.
mesh
)
project_
img
!
(
ctx
.
g
,
img
)
project_
l2_lagrange
!
(
ctx
.
g
,
img
)
k
>=
100
&&
break
k
>=
100
&&
break
end
end
...
@@ -571,7 +571,7 @@ function denoise_pd(st, img; df=nothing, name, algorithm, params_...)
...
@@ -571,7 +571,7 @@ function denoise_pd(st, img; df=nothing, name, algorithm, params_...)
sigma
=
inv
(
tau
*
L
^
2
)
sigma
=
inv
(
tau
*
L
^
2
)
theta
=
1.
theta
=
1.
#project_
img
!(st.g, img)
#project_
l2_lagrange
!(st.g, img)
interpolate!
(
st
.
g
,
x
->
evaluate_bilinear
(
img
,
x
))
interpolate!
(
st
.
g
,
x
->
evaluate_bilinear
(
img
,
x
))
st
.
u
.
data
.=
st
.
g
.
data
st
.
u
.
data
.=
st
.
g
.
data
...
@@ -687,7 +687,7 @@ function denoise_approximation(ctx)
...
@@ -687,7 +687,7 @@ function denoise_approximation(ctx)
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
)
#project_
img
!(st.g, img)
#project_
l2_lagrange
!(st.g, img)
interpolate!
(
st
.
g
,
x
->
evaluate_bilinear
(
ctx
.
params
.
img
,
x
))
interpolate!
(
st
.
g
,
x
->
evaluate_bilinear
(
ctx
.
params
.
img
,
x
))
st
.
u
.
data
.=
st
.
g
.
data
st
.
u
.
data
.=
st
.
g
.
data
#st.u.data .= rand(size(st.u.data))
#st.u.data .= rand(size(st.u.data))
...
@@ -877,7 +877,7 @@ function optflow(ctx)
...
@@ -877,7 +877,7 @@ function optflow(ctx)
function
warp!
()
function
warp!
()
imgfw
=
warp_backwards
(
imgf1
,
sample
(
st
.
u
))
imgfw
=
warp_backwards
(
imgf1
,
sample
(
st
.
u
))
project_
img
!
(
fw
,
imgfw
)
project_
l2_lagrange
!
(
fw
,
imgfw
)
# replace new tdata
# replace new tdata
st
=
L1L2TVContext
(
"run"
,
mesh
,
st
.
d
,
st
.
m
,
T
,
nabla
(
fw
),
S
,
st
=
L1L2TVContext
(
"run"
,
mesh
,
st
.
d
,
st
.
m
,
T
,
nabla
(
fw
),
S
,
...
@@ -890,8 +890,8 @@ function optflow(ctx)
...
@@ -890,8 +890,8 @@ function optflow(ctx)
end
end
function
reproject!
()
function
reproject!
()
project_
img2
!
(
f0
,
imgf0
)
project_
qi_lagrange
!
(
f0
,
imgf0
)
project_
img2
!
(
f1
,
imgf1
)
project_
qi_lagrange
!
(
f1
,
imgf1
)
end
end
reproject!
()
reproject!
()
warp!
()
warp!
()
...
@@ -988,13 +988,12 @@ function experiment_image_mesh_interpolation(ctx)
...
@@ -988,13 +988,12 @@ function experiment_image_mesh_interpolation(ctx)
# all methods use bilinear interpolation for image evaluations
# all methods use bilinear interpolation for image evaluations
methods
=
[
methods
=
[
#"nodal_interpolation" => interpolate!,
"nodal"
=>
interpolate!
,
## techniques that use lagrange-lattice quadratures
"l2_lagrange"
=>
project_l2_lagrange!
,
"l2_projection"
=>
project_img!
,
#"clement" => projec_clement!,
#"clement" => projec_clement!,
"
l1_stable_quasi_interpolation
"
=>
project_
img2
!
,
"
qi_lagrange
"
=>
project_
qi_lagrange
!
,
#"
l1_stable_quasi_interpolation
_avg" => project_
img2
!,
#"
qi_lagrange
_avg" => project_
qi_lagrange
!,
#"l2_
regression
" => project_
img_regression
!,
#"l2_
pixel
" => project_
l2_pixel
!,
]
]
map
(
methods
)
do
(
name
,
f
)
map
(
methods
)
do
(
name
,
f
)
...
...
This diff is collapsed.
Click to expand it.
src/image.jl
+
7
−
7
View file @
1962d312
...
@@ -135,10 +135,10 @@ end
...
@@ -135,10 +135,10 @@ end
# TODO: refine interface: projection vs interpolation, unify different
# TODO: refine interface: projection vs interpolation, unify different
# algorithms
# algorithms
project_
img
(
space
::
FeSpace
,
img
)
=
project_
l2_lagrange
(
space
::
FeSpace
,
img
)
=
(
u
=
FeFunction
(
space
);
project_
img
!
(
u
,
img
))
(
u
=
FeFunction
(
space
);
project_
l2_lagrange
!
(
u
,
img
))
function
project_
img
!
(
u
::
FeFunction
,
img
::
AbstractArray
)
function
project_
l2_lagrange
!
(
u
::
FeFunction
,
img
::
AbstractArray
)
d
=
2
# domain dimension
d
=
2
# domain dimension
space
=
u
.
space
space
=
u
.
space
mesh
=
space
.
mesh
mesh
=
space
.
mesh
...
@@ -219,8 +219,8 @@ function project_img!(u::FeFunction, img::AbstractArray)
...
@@ -219,8 +219,8 @@ function project_img!(u::FeFunction, img::AbstractArray)
return
u
return
u
end
end
project_
img2
(
space
::
FeSpace
,
img
)
=
project_
qi_lagrange
(
space
::
FeSpace
,
img
)
=
(
u
=
FeFunction
(
space
);
project_
img2
!
(
u
,
img
))
(
u
=
FeFunction
(
space
);
project_
qi_lagrange
!
(
u
,
img
))
# L1-stable quasi-interpolation operator
# L1-stable quasi-interpolation operator
# (https://arxiv.org/pdf/1505.06931.pdf)
# (https://arxiv.org/pdf/1505.06931.pdf)
...
@@ -228,7 +228,7 @@ project_img2(space::FeSpace, img) =
...
@@ -228,7 +228,7 @@ project_img2(space::FeSpace, img) =
# FIXME: currently only approximate quadrature by sampling on lagrange lattice
# FIXME: currently only approximate quadrature by sampling on lagrange lattice
# based on element size. Exact evaluation is tricky to implement (lots of
# based on element size. Exact evaluation is tricky to implement (lots of
# intersection handling).
# intersection handling).
function
project_
img2
!
(
u
::
FeFunction
,
img
)
function
project_
qi_lagrange
!
(
u
::
FeFunction
,
img
)
u
.
space
.
element
==
P1
()
||
u
.
space
.
element
==
P1
()
||
throw
(
ArgumentError
(
"element unsupported"
))
throw
(
ArgumentError
(
"element unsupported"
))
d
=
2
# domain dimension
d
=
2
# domain dimension
...
@@ -296,7 +296,7 @@ function quadrature_cell_pixels(mesh, cell; m0)
...
@@ -296,7 +296,7 @@ function quadrature_cell_pixels(mesh, cell; m0)
end
end
function
interpolate_img
_l2pixel!
(
u
::
FeFunction
,
img
)
function
project
_l2
_
pixel!
(
u
::
FeFunction
,
img
)
d
=
2
# domain dimension
d
=
2
# domain dimension
space
=
u
.
space
space
=
u
.
space
mesh
=
space
.
mesh
mesh
=
space
.
mesh
...
...
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