Open
Description
pretty slow for a 512 x 512 image, will figure out later:
def add_data_annotation(self):
"""Add text to display values of grayscale data"""
if self._data_annotation is not None:
raise ValueError("data annotation already added")
if self.data.value.ndim > 2:
raise ValueError("image data annotation only supported for grayscale data")
self._data_annotation = pygfx.MultiText(
screen_space=True,
font_size=12,
material=pygfx.TextMaterial(color="w", outline_thickness=0.1)
)
self._text_blocks = np.empty(shape=self.data.value.shape, dtype=object)
for (row_ix, col_ix) in product(range(self.data.value.shape[0]), range(self.data.value.shape[1])):
self._text_blocks[row_ix, col_ix] = self._data_annotation.create_text_block()
self._text_blocks[row_ix, col_ix].set_text(str(self.data[row_ix, col_ix]))
self._text_blocks[row_ix, col_ix].set_position(col_ix, row_ix)
self._data_annotation.local.z = self.offset[-1] + 1
self.world_object.add(self._data_annotation)
# self.add_event_handler(self._update_data_annotation, "data")
return self._data_annotation
def update_data_annotation(self, ev):
for (row_ix, col_ix) in product(range(self.data.value.shape[0]), range(self.data.value.shape[1])):
self._text_blocks[row_ix, col_ix].set_text(str(self.data[row_ix, col_ix]))
Metadata
Metadata
Assignees
Labels
No labels