GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — High level widgets · Issue #31 · fastplotlib/fastplotlib

High level widgets #31

New issue
Copy link
New issue
Copy link
Closed
Closed
High level widgets#31
Copy link
Milestone
v0.1 alpha 6

Description

@kushalkolar
kushalkolar
opened on Oct 20, 2022
Issue body actions

Takes numpy array-like (such as pims objects), choose axes to have sliders on, displays plot. Could also have gridplot where multiple numpy arrays are given and sliders are synced across plots.

something like:

from fastplotlib.widgets import ImageWidget
import cv2
import pims

a = pims.open("img.tiff") # array-like of shape [n_frames, x, y]
vid = pims.open("vid.avi") # array-like of shape [n_frames, x, y, rgb_channels]

# produces a slider for each axis passed to `slider_axes`
# additional kwargs are passed to `graphics.Image`, such as `cmap`
iw = ImageWidget(data=a, slider_axes=0, axis_order="txy", **kwargs)
# could also specify slider axis from one of the axis_order indicators
# this could be the default kwarg for slider_axes
iw = ImageWidget(data=a, slider_axes="t", axis_order="txy", **kwargs)
iw.show() # returns `VBox` of `ImageWidget` and `ipywidgets.IntSlider`

# multiple sliders
iw = ImageWidget(data=a, slider_axes=["t", "z"], axis_order="tzxy", **kwargs)

# pass a frame apply function that is applied to the frame array when `update_frame()` is called
to_gray = lambda rgb_frame: cv2.cvtColor(rgb_frame, cv2.COLOR_BGR2GRAY)
iw_vid = ImageWidget(data=b, slider_axes=0, frame_apply=to_gray)

# Same widget but with gridplot, pass list of array-like
iw_grid = ImageWidget(
    data=[a, b], 
    slider_axes=0,  # use 0th axis for a single slider for both arrays
    frame_apply={b: to_gray}
)
iw_grid.show()

# if a.shape[0] != b.shape[0] it can print a warning and just not update `a` when it goes out of bounds for it, but continue updating `b`

# create multiple sliders for different dimensions
iw_grid_async = ImageWidget(
    data=[a, b],
    slider_axes=["t", "z"],
    axes_order={a: "tzxy", b: "xyzt"},
    slice_avg={"t": 10, "z": 1},  # window size for slice averaging along some axes
    frame_apply={b: to_gray}
)
iw_grid_async.show()
Reacted by Eric Thomson

Activity

  1. kushalkolar
    added this to the v0.1 alpha 6 milestone on Oct 29, 2022
  2. kushalkolar
    assigned
    clewis7
    and unassigned
    clewis7
    on Nov 1, 2022
  3. kushalkolar commented on Dec 4, 2022

    @kushalkolar
    kushalkolar
    on Dec 4, 2022
    MemberAuthor
    More actions

    For ImageWidgetGrid, all sliders will be synced. If a user wants a grid with separate sliders for each, they should just create a single ImageWidget for each array and use HBox and VBox to make their own grid.

  4. kushalkolar
    closed this as completedon Dec 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      • v0.1 alpha 6

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.