Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
GEPARD
GEPARD
Commits
8fc15b1e
Commit
8fc15b1e
authored
May 24, 2019
by
Josef Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix plus additional checkbox for inverting threshold.
parent
6d428c36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
segmentation.py
segmentation.py
+11
-5
No files found.
segmentation.py
View file @
8fc15b1e
...
...
@@ -52,6 +52,7 @@ class Segmentation(object):
'lowThresh'
:
0.2
,
'activateUpThresh'
:
False
,
'upThresh'
:
0.5
,
'invertThresh'
:
False
,
'maxholebrightness'
:
0.5
,
# 'erodeconvexdefects': 0,
'minparticlearea'
:
20
,
...
...
@@ -73,9 +74,10 @@ class Segmentation(object):
parlist
=
[
Parameter
(
"contrastCurve"
,
np
.
ndarray
,
self
.
detectParams
[
'contrastCurve'
],
helptext
=
"Curve contrast"
),
Parameter
(
"activateContrastCurve"
,
np
.
bool
,
self
.
detectParams
[
'activateContrastCurve'
],
helptext
=
"activate Contrast curve"
,
show
=
True
,
linkedParameter
=
'contrastCurve'
),
Parameter
(
"blurRadius"
,
int
,
self
.
detectParams
[
'blurRadius'
],
3
,
99
,
1
,
2
,
helptext
=
"Blur radius"
,
show
=
True
),
Parameter
(
"activateLowThresh"
,
np
.
bool
,
self
.
detectParams
[
'activateThresh2'
],
helptext
=
"activate lower threshold"
,
show
=
False
,
linkedParameter
=
'lowThresh'
),
Parameter
(
"invertThresh"
,
np
.
bool
,
self
.
detectParams
[
'invertThresh'
],
helptext
=
"Invert the current threshold"
,
show
=
False
),
Parameter
(
"activateLowThresh"
,
np
.
bool
,
self
.
detectParams
[
'activateLowThresh'
],
helptext
=
"activate lower threshold"
,
show
=
False
,
linkedParameter
=
'lowThresh'
),
Parameter
(
"lowThresh"
,
float
,
self
.
detectParams
[
'lowThresh'
],
.
01
,
.
9
,
2
,
.
02
,
helptext
=
"Lower threshold"
,
show
=
True
),
Parameter
(
"activateUpThresh"
,
np
.
bool
,
self
.
detectParams
[
'activateThresh
2
'
],
helptext
=
"activate upper threshold"
,
show
=
False
,
linkedParameter
=
'upThresh'
),
Parameter
(
"activateUpThresh"
,
np
.
bool
,
self
.
detectParams
[
'activate
Up
Thresh'
],
helptext
=
"activate upper threshold"
,
show
=
False
,
linkedParameter
=
'upThresh'
),
Parameter
(
"upThresh"
,
float
,
self
.
detectParams
[
'upThresh'
],
.
01
,
1.0
,
2
,
.
02
,
helptext
=
"Upper threshold"
,
show
=
True
),
Parameter
(
"maxholebrightness"
,
float
,
self
.
detectParams
[
'maxholebrightness'
],
0
,
1
,
2
,
0.02
,
helptext
=
"Close holes brighter than.."
,
show
=
True
),
# Parameter("erodeconvexdefects", int, self.detectParams['erodeconvexdefects'], 0, 20, helptext="Erode convex defects", show=True), #TODO: Consider removing it entirely. It is usually not used...
...
...
@@ -320,6 +322,8 @@ class Segmentation(object):
# thresholding
if
self
.
activateLowThresh
and
not
self
.
activateUpThresh
:
thresh
=
cv2
.
threshold
(
blur
,
int
(
255
*
self
.
lowThresh
),
255
,
cv2
.
THRESH_BINARY
)[
1
]
if
self
.
invertThresh
:
thresh
=
255
-
thresh
if
return_step
==
"lowThresh"
:
return
thresh
,
0
print
(
"lower threshold"
)
if
self
.
cancelcomputation
:
...
...
@@ -329,7 +333,8 @@ class Segmentation(object):
lowerLimit
,
upperLimit
=
np
.
round
(
self
.
lowThresh
*
255
),
np
.
round
(
self
.
upThresh
*
255
)
thresh
=
np
.
zeros_like
(
blur
)
thresh
[
np
.
where
(
np
.
logical_and
(
blur
>=
lowerLimit
,
blur
<=
upperLimit
))]
=
255
if
self
.
invertThresh
:
thresh
=
255
-
thresh
if
return_step
==
"lowThresh"
or
return_step
==
"upThresh"
:
return
thresh
,
0
print
(
"between threshold"
)
if
self
.
cancelcomputation
:
...
...
@@ -338,6 +343,8 @@ class Segmentation(object):
elif
not
self
.
activateLowThresh
and
self
.
activateUpThresh
:
thresh
=
np
.
zeros_like
(
blur
)
thresh
[
np
.
where
(
blur
<=
np
.
round
(
self
.
upThresh
*
255
))]
=
255
if
self
.
invertThresh
:
thresh
=
255
-
thresh
if
return_step
==
"upThresh"
:
return
thresh
,
0
print
(
"upper threshold"
)
if
self
.
cancelcomputation
:
...
...
@@ -346,8 +353,7 @@ class Segmentation(object):
if
self
.
parent
is
not
None
:
self
.
parent
.
raiseWarning
(
'No thresholding method selected!
\n
Aborted detection..'
)
print
(
'NO THRESHOLDING SELECTED!'
)
return
None
,
None
,
None
return
blur
,
0
#close holes darkter than self.max_brightness
self
.
closeBrightHoles
(
thresh
,
blur
,
self
.
maxholebrightness
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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