Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Cittena
cittena
Commits
92877daa
Commit
92877daa
authored
Dec 29, 2016
by
Niels-Oliver Walkowski
Browse files
fixed false usage of np.uint8 for contrasts
with higher values
parent
b3ecf438
Changes
2
Hide whitespace changes
Inline
Side-by-side
itten/contrasts.py
View file @
92877daa
...
...
@@ -26,6 +26,7 @@ class LightDark(object):
# addiert alle Werte auf einer bestimmten Achse
luminances
=
np
.
sum
(
self
.
_img
,
axis
=
2
)
luminances
=
luminances
.
astype
(
np
.
uint8
,
copy
=
True
)
return
luminances
...
...
itten/views.py
View file @
92877daa
...
...
@@ -52,9 +52,9 @@ class View(np.ndarray):
"""
obj
=
input_array
if
type
(
obj
)
==
np
.
ndarray
:
obj
=
np
.
asarray
(
input_array
,
dtype
=
np
.
uint
8
).
view
(
cls
).
copy
()
obj
=
np
.
asarray
(
input_array
,
dtype
=
np
.
uint
32
).
view
(
cls
).
copy
()
else
:
input_array
=
np
.
empty
((
0
,
3
),
dtype
=
np
.
uint
8
)
input_array
=
np
.
empty
((
0
,
3
),
dtype
=
np
.
uint
32
)
obj
=
np
.
asarray
(
input_array
).
view
(
cls
).
copy
()
obj
.
_frames
=
frames
obj
.
_contrast
=
2
...
...
@@ -141,7 +141,7 @@ class MultivariateSequence(View):
# selef._frames.start = start
# self._frames.end = end
contrast_points
=
np
.
empty
((
0
,
3
),
dtype
=
np
.
uint
8
)
contrast_points
=
np
.
empty
((
0
,
3
),
dtype
=
np
.
uint
32
)
# pwd list sollte in Frames sein und hier nur durchlaufen werden
for
frm_nr
in
range
(
self
.
_frames
.
start
,
self
.
_frames
.
end
,
self
.
_frame_step
):
...
...
@@ -152,16 +152,19 @@ class MultivariateSequence(View):
ctrst_cls
=
self
.
_get_ctrst_cls_name
(
self
.
_contrast
)
ctrst_img
=
ctrst_cls
(
img
).
ctrst
hist_value
,
_
=
np
.
histogram
(
ctrst_img
.
flatten
(),
bins
=
self
.
_bins
,
shape
=
ctrst_img
.
shape
ctrst_img
=
np
.
reshape
(
ctrst_img
,
(
shape
[
0
]
*
shape
[
1
]))
hist_value
,
_
=
np
.
histogram
(
ctrst_img
,
bins
=
self
.
_bins
,
range
=
(
0
,
256
))
for
bin_index
,
point
in
enumerate
(
hist_value
):
if
point
>
self
.
_threshold
:
entry
=
np
.
array
([[
frm_nr
,
bin_index
,
int
(
point
)
]],
dtype
=
np
.
uint
8
)
if
int
(
point
)
>
self
.
_threshold
:
entry
=
np
.
array
([[
frm_nr
,
bin_index
,
point
]],
dtype
=
np
.
uint
32
)
contrast_points
=
np
.
vstack
((
contrast_points
,
entry
))
# irgendwie prüfen, ob ich contrast_points insgesamt durch self ersetzen kann
contrast_points
=
np
.
asarray
(
contrast_points
,
np
.
uint
8
)
contrast_points
=
np
.
asarray
(
contrast_points
,
np
.
uint
32
)
shape
=
contrast_points
.
shape
self
.
resize
(
shape
,
refcheck
=
False
)
self
[:,
:]
=
contrast_points
...
...
@@ -213,7 +216,7 @@ class BivariateSequence(View):
# self._frames.start = start
# self._frames.end = end
contrast_points
=
np
.
empty
((
0
,
2
),
dtype
=
np
.
uint
8
)
contrast_points
=
np
.
empty
((
0
,
2
),
dtype
=
np
.
uint
32
)
# sofern kein oder nur ein Peak gefunden wird, man könnte dann auch
# noch einen Durchlauf mit geringeren thres und min_dist versuceh
...
...
@@ -304,7 +307,7 @@ class BivariateSequence(View):
contrast_points
=
np
.
vstack
((
contrast_points
,
[
lastmin
,
lastmax
]))
contrast_points
=
np
.
asarray
(
contrast_points
,
np
.
uint
8
)
contrast_points
=
np
.
asarray
(
contrast_points
,
np
.
uint
32
)
shape
=
contrast_points
.
shape
self
.
resize
(
shape
,
refcheck
=
False
)
self
[:,
:]
=
contrast_points
...
...
@@ -367,7 +370,7 @@ class UnivariateSequence(View):
# self._frames.start = start
# self._frames.end = end
contrast_points
=
np
.
empty
((
0
,
4
),
dtype
=
np
.
uint
8
)
contrast_points
=
np
.
empty
((
0
,
2
),
dtype
=
np
.
uint
32
)
# pwd list sollte in Frames sein und hier nur durchlaufen werden
for
frm_nr
in
range
(
self
.
_frames
.
start
,
self
.
_frames
.
end
,
...
...
@@ -382,18 +385,18 @@ class UnivariateSequence(View):
bins
=
self
.
_bins
,
range
=
(
0
,
256
))
hist_value
=
hist_value
.
flatten
()
hist_value
=
hist_value
.
astype
(
np
.
uint
8
,
copy
=
False
)
hist_value
=
hist_value
.
astype
(
np
.
uint
32
,
copy
=
False
)
# eigenes mean und devi durch numpy ersetzt
# TODO Ergebnisse der unterschiedlichen Verfahrenstimmt nicht überein
contrast
=
hist_value
.
mean
()
deviation
=
hist_value
.
std
()
_
contrast
,
_
deviation
=
UnivariateSequence
.
meanmad
(
hist_value
)
#
contrast = hist_value.mean()
#
deviation = hist_value.std()
contrast
,
deviation
=
UnivariateSequence
.
meanmad
(
hist_value
)
contrast_points
=
np
.
vstack
((
contrast_points
,
[
contrast
,
deviation
,
_contrast
,
_
deviation
]))
[
contrast
,
deviation
]))
contrast_points
=
np
.
asarray
(
contrast_points
,
np
.
uint
8
)
contrast_points
=
np
.
asarray
(
contrast_points
,
np
.
uint
32
)
shape
=
contrast_points
.
shape
self
.
resize
(
shape
,
refcheck
=
False
)
self
[:,
:]
=
contrast_points
...
...
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