Commit c8e8d779 authored by Niels-Oliver Walkowski's avatar Niels-Oliver Walkowski
Browse files

refacture calls of class parameters

parent adef287f
......@@ -28,8 +28,7 @@ class View(np.ndarray):
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
# 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):
......@@ -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
......@@ -2,4 +2,4 @@ from 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)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment