Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bio-IT Workshops
ai4ia
Commits
4f919a40
Commit
4f919a40
authored
Aug 12, 2020
by
Constantin Pape
Browse files
Add spatial noise
parent
0026647e
Changes
1
Hide whitespace changes
Inline
Side-by-side
stardist/stardist_impl/train_stardist_2d.py
View file @
4f919a40
...
...
@@ -128,9 +128,25 @@ def random_uniform_noise(x):
return
x
*
np
.
random
.
uniform
(
0.6
,
2
)
+
np
.
random
.
uniform
(
-
0.2
,
0.2
)
def
gaussian_spatial_noise
(
x
,
scale
=
(
0.1
,
1.0
),
execution_probability
=
0.25
):
if
np
.
random
.
uniform
()
<
execution_probability
:
std
=
np
.
random
.
uniform
(
scale
[
0
],
scale
[
1
])
x
+=
np
.
random
.
normal
(
scale
=
std
,
size
=
x
.
shape
)
return
x
def
poisson_spatial_noise
(
x
,
lambda_
=
(
0.1
,
1.0
),
execution_probability
=
0.25
):
if
np
.
random
.
uniform
()
<
execution_probability
:
lam
=
np
.
random
.
uniform
(
lambda_
[
0
],
lambda_
[
1
])
x
+=
np
.
random
.
poisson
(
lam
,
size
=
x
.
shape
)
return
x
def
augmenter
(
x
,
y
):
x
,
y
=
random_flips_and_rotations
(
x
,
y
)
x
=
random_uniform_noise
(
x
)
x
=
gaussian_spatial_noise
(
x
)
x
=
poisson_spatial_noise
(
x
)
return
x
,
y
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment