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
28ca53f6
Commit
28ca53f6
authored
Dec 20, 2016
by
Niels-Oliver Walkowski
Browse files
change contrast_points from list to np.arry
parent
58c41143
Changes
2
Hide whitespace changes
Inline
Side-by-side
itten/contrasts.py
View file @
28ca53f6
import
numpy
as
np
import
cv2
as
cv
# TODO create generic class
class
LightDark
(
object
):
"""docstring for LightDark"""
...
...
@@ -9,7 +11,7 @@ class LightDark(object):
meth
=
getattr
(
LightDark
,
method
)
self
.
ctrst
=
meth
(
self
)
def
luminance
(
self
):
"""Creates light/dark values using luminance quantifiers for RGB
...
...
@@ -40,4 +42,3 @@ class LightDark(object):
lightness
=
img
[:,
:,
1
].
copy
()
return
lightness
itten/views.py
View file @
28ca53f6
...
...
@@ -29,6 +29,7 @@ class View(np.ndarray):
Attributes:
TODO Docstring komplettieren und Verfahren überprüfen
"""
def
__new__
(
cls
,
frames
,
input_array
=
None
):
"""instantiates the view class
...
...
@@ -147,7 +148,7 @@ class VHistStack(View):
# slef._frames.start = start
# slef._frames.end = end
contrast_points
=
[]
contrast_points
=
np
.
empty
((
0
,
3
),
dtype
=
np
.
uint8
)
# 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
):
pwd
=
self
.
_frames
.
folder
+
self
.
_frames
.
prefix
+
str
(
frm_nr
)
+
'.png'
...
...
@@ -162,18 +163,23 @@ class VHistStack(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
,
range
=
(
0
,
256
))
# else:
# img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV_FULL)
# hist_value = cv2.calcHist([img_hsv], [self._contrast], None, [16], [0, 256])
hist_value
,
_
=
np
.
histogram
(
ctrst_img
.
flatten
(),
bins
=
self
.
_bins
,
range
=
(
0
,
256
))
for
bin_index
,
point
in
enumerate
(
hist_value
):
if
point
>
self
.
_threshold
:
contrast_points
.
append
((
frm_nr
,
bin_index
,
int
(
point
)))
entry
=
np
.
array
([[
frm_nr
,
bin_index
,
int
(
point
)]],
dtype
=
np
.
uint8
)
# print('Entry: {0}'.format(entry)) FUNZT
contrast_points
=
np
.
vstack
((
contrast_points
,
entry
))
# print('contrast points in loop: {0}'.format(contrast_points))
# np.append(contrast_points, [[frm_nr, bin_index, int(point)]], axis=0)
contrast_points
=
np
.
asarray
(
contrast_points
,
np
.
uint8
)
print
(
contrast_points
)
shape
=
contrast_points
.
shape
print
(
'contrast_points shape {0}'
.
format
(
shape
))
self
.
resize
(
shape
,
refcheck
=
False
)
print
(
'self_shape {0}'
.
format
(
self
.
shape
))
self
[:,
:]
=
contrast_points
return
deepcopy
(
self
)
# TODO does not create a new object
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