Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

multitext annotation on images #827

Copy link
Copy link
Open
@kushalkolar

Description

@kushalkolar
Issue body actions

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.