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

fixed false usage of np.uint8 for contrasts

with higher values
parent b3ecf438
......@@ -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
......
......@@ -52,9 +52,9 @@ class View(np.ndarray):
"""
obj = input_array
if type(obj) == np.ndarray:
obj = np.asarray(input_array, dtype=np.uint8).view(cls).copy()
obj = np.asarray(input_array, dtype=np.uint32).view(cls).copy()
else:
input_array = np.empty((0, 3), dtype=np.uint8)
input_array = np.empty((0, 3), dtype=np.uint32)
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.uint8)
contrast_points = np.empty((0, 3), dtype=np.uint32)
# 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.uint8)
if int(point) > self._threshold:
entry = np.array([[frm_nr, bin_index, point]], dtype=np.uint32)
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.uint8)
contrast_points = np.asarray(contrast_points, np.uint32)
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.uint8)
contrast_points = np.empty((0, 2), dtype=np.uint32)
# 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.uint8)
contrast_points = np.asarray(contrast_points, np.uint32)
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.uint8)
contrast_points = np.empty((0, 2), dtype=np.uint32)
# 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.uint8, copy=False)
hist_value = hist_value.astype(np.uint32, 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.uint8)
contrast_points = np.asarray(contrast_points, np.uint32)
shape = contrast_points.shape
self.resize(shape, refcheck=False)
self[:, :] = contrast_points
......
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