Commit 455a225a authored by inhuszar's avatar inhuszar
Browse files

Bugfix2: TImage weighted centre

parent 3a39e997
......@@ -2249,7 +2249,7 @@ class TImage(TField):
"""
if weighted:
# TODO: This is too slow for large arrays...
# TODO: This might be too slow for large arrays
weights = self.reduce_tensors(copy=True)
weights.order = ts.TENSOR_MAJOR
weights = weights / np.max(weights)
......@@ -2258,7 +2258,8 @@ class TImage(TField):
pc = self.domain.get_physical_coordinates()
pc = TField.fromarray(pc.reshape(*self.vshape, -1), tensor_axes=-1)
pc.order = ts.TENSOR_MAJOR
return tuple((np.sum(weights * pc) / np.sum(weights)).data.ravel())
c = tuple(np.sum(weights * pc, axis=pc.vaxes) / np.sum(weights))
return c
else:
txs = self.domain.transformations
......
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