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
c8e8d779
Commit
c8e8d779
authored
Dec 15, 2016
by
Niels-Oliver Walkowski
Browse files
refacture calls of class parameters
parent
adef287f
Changes
5
Hide whitespace changes
Inline
Side-by-side
itten/__pycache__/contrasts.cpython-35.pyc
View file @
c8e8d779
No preview for this file type
itten/__pycache__/movie.cpython-35.pyc
View file @
c8e8d779
No preview for this file type
itten/contrasts.py
View file @
c8e8d779
...
...
@@ -28,8 +28,7 @@ class View(np.ndarray):
Attributes:
TODO Docstring komplettieren und Verfahren überprüfen
"""
def
__new__
(
cls
,
frames
,
input_array
=
None
,
ctrst
=
'lightDark'
,
frm_stp
=
10
,
savefig
=
False
):
def
__new__
(
cls
,
frames
,
input_array
=
None
):
"""instantiates the view class
instantiation complies with the recommendation for subclassing
...
...
@@ -55,9 +54,9 @@ class View(np.ndarray):
input_array
=
np
.
zeros
((
0
),
dtype
=
np
.
uint8
)
obj
=
np
.
asarray
(
input_array
).
view
(
cls
).
copy
()
obj
.
_frames
=
frames
obj
.
_contrast
=
ctrst
obj
.
_frame_step
=
frm_stp
obj
.
_
savefig
=
savefig
obj
.
_contrast
=
2
obj
.
_frame_step
=
10
obj
.
_
bins
=
256
return
obj
def
__array_finalize__
(
self
,
obj
):
...
...
@@ -66,8 +65,6 @@ class View(np.ndarray):
self
.
_contrast
=
getattr
(
obj
,
'_contrast'
,
None
)
self
.
_frame_step
=
getattr
(
obj
,
'_frame_step'
,
None
)
self
.
_bins
=
getattr
(
obj
,
'_bins'
,
None
)
self
.
_threshold
=
getattr
(
obj
,
'_threshold'
,
None
)
self
.
_savefig
=
getattr
(
obj
,
'_savefig'
,
None
)
def
__array_wrap__
(
self
,
out_arr
,
context
=
None
):
return
np
.
ndarray
.
__array_wrap__
(
self
,
out_arr
,
context
)
...
...
@@ -76,8 +73,7 @@ class View(np.ndarray):
# subclassing subclass of numpy http://stackoverflow.com/questions/7342637/how-to-subclass-a-subclass-of-numpy-ndarray
# TODO es gibt noch das Problem, dass numpy nach mehreren Berechnungen von drive eine max recursion Warnung ausgiebt, warum? Brauche ich __del__
class
VHistStack
(
View
):
def
__new__
(
cls
,
frames
,
input_array
=
None
,
ctrst
=
'lightDark'
,
frm_stp
=
10
,
bins
=
16
,
thrsh
=
60000
,
savefig
=
False
):
def
__new__
(
cls
,
frames
,
input_array
=
None
):
"""Represents a movie contrast in terms of stacked histograms
For each defined frame a histogram is calculated and each bin that
...
...
@@ -99,21 +95,29 @@ class VHistStack(View):
represents the relative weight of the bin in the frame
"""
obj
=
View
.
__new__
(
cls
,
frames
,
input_array
=
input_array
,
ctrst
=
ctrst
,
frm_stp
=
frm_stp
,
savefig
=
savefig
)
obj
.
_bins
=
bins
obj
.
_threshold
=
thrsh
obj
=
View
.
__new__
(
cls
,
frames
,
input_array
=
input_array
)
obj
.
_threshold
=
60000
return
obj
def
__array_finalize__
(
self
,
obj
):
if
obj
is
None
:
return
View
.
__array_finalize__
(
self
,
obj
)
self
.
_bins
=
getattr
(
obj
,
'_bins'
,
None
)
self
.
_threshold
=
getattr
(
obj
,
'_threshold'
,
None
)
# TODO jetzt ausschließlich mit self numpy rechnen statt mit contrast_points liste
def
derive
(
self
):
def
populate
(
self
,
ctrst
=
2
,
frm_stp
=
10
,
bins
=
16
,
thrsh
=
60000
,
start
=
1
,
end
=
0
):
"""doc (aus __new__ zusammentragen)
"""
# set class properties
self
.
_contrast
=
ctrst
self
.
_frame_step
=
frm_stp
self
.
_bins
=
bins
self
.
_threshold
=
thrsh
# TODO dafür müssen erst getters und setters in movie.frames definiert werden
# slef._frames.start = start
# slef._frames.end = end
contrast_points
=
[]
# 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
):
...
...
itten/movie.py
View file @
c8e8d779
...
...
@@ -22,7 +22,7 @@ class Movie(object):
class
Frames
(
object
):
# TODO
wie ist das bei Python mit getters und setters, gibt es eine elegantere Lösung
# TODO
getters und setters für start und end setzen
"""Parses movie frames properties"""
def
__init__
(
self
,
folder
,
prefix
,
start
=
1
,
end
=
0
):
self
.
folder
=
folder
...
...
testing/bootstrap.py
View file @
c8e8d779
...
...
@@ -2,4 +2,4 @@ from itten.movie import Movie
from
itten.contrasts
import
VHistStack
movie
=
Movie
(
prefix
=
'rec_'
,
folder
=
'../DHd-2017/Data/Frames/Rec/'
)
cont
=
VHistStack
(
movie
.
_frames
,
ctrst
=
2
)
cont
=
VHistStack
(
movie
.
_frames
)
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