Skip to content

start video points example #676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions examples/image_widget/video_roi_points.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
Image Widget Pixel Timeseries
=============================

Use an ImageWidget to view a grayscale video and click on pixels to show their values
over time (timeseries)
"""

# test_example = true
# sphinx_gallery_pygfx_docs = 'animate 6s 20fps'

import numpy as np
import fastplotlib as fpl
import imageio.v3 as iio


# download and open video file
print("download and reading video file")
url = "https://caiman.flatironinstitute.org/~neuro/caiman_downloadables/demoMovieJ.tif"
url = "/home/kushal/caiman_data/example_movies/demoMovieJ.tif"
video = iio.imread(url)

iw = fpl.ImageWidget(
video,
cmap="viridis",
figure_kwargs={"size": (700, 600)}
)
iw.show()

fig = fpl.Figure(size=(700, 400))

# add an initial point
row_ix, col_ix = 29, 65
timeseries = fig[0, 0].add_line(video[:, row_ix, col_ix], thickness=1.0)
point = iw.figure[0, 0].add_scatter(np.column_stack([col_ix, row_ix]), sizes=10, alpha=0.7, colors="magenta")

time_selector = timeseries.add_linear_selector()


@time_selector.add_event_handler("selection")
def set_time_from_selector(ev):
iw.current_index = {"t": ev.get_selected_index()}


@iw.managed_graphics[0].add_event_handler("double_click")
def update_pixel(ev):
col, row = ev.pick_info["index"]

point.data[0, :2] = [col, row]
timeseries.data[:, 1] = video[:, row, col]
fig[0, 0].auto_scale(maintain_aspect=False)


fig.show(maintain_aspect=False)
fpl.run()
8 changes: 8 additions & 0 deletions fastplotlib/graphics/selectors/_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ def limits(self, values: tuple[float, float]):
) # if values are close to zero things get weird so round them
self.selection._limits = self._limits

@property
def end_points(self) -> tuple[float, float]:
pass

@end_points.setter
def end_points(self, points: tuple[float, float]):
pass

# TODO: make `selection` arg in graphics data space not world space
def __init__(
self,
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy