Skip to content

Navigation Menu

Sign in
Appearance settings

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

fix ImageWidget.reset_vmin_vmax() #690

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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 16, 2025
Merged
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions 4 examples/screenshots/image_widget_single_video.png
4 changes: 2 additions & 2 deletions 4 examples/screenshots/image_widget_videos.png
44 changes: 37 additions & 7 deletions 44 fastplotlib/widgets/image_widget/_widget.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from copy import deepcopy
from typing import Callable
from warnings import warn

import numpy as np

from rendercanvas import BaseRenderCanvas

from ... import Figure
from ...layouts import ImguiFigure as Figure
from ...graphics import ImageGraphic
from ...utils import calculate_figure_shape
from ...utils import calculate_figure_shape, quick_min_max
from ...tools import HistogramLUTTool
from ._sliders import ImageWidgetSliders

Expand Down Expand Up @@ -507,6 +508,12 @@ def __init__(

graphic_kwargs.update({"cmap": cmap})

vmin_specified, vmax_specified = None, None
if "vmin" in graphic_kwargs.keys():
vmin_specified = graphic_kwargs.pop("vmin")
if "vmax" in graphic_kwargs.keys():
vmax_specified = graphic_kwargs.pop("vmax")

self._figure: Figure = Figure(**figure_kwargs_default)

self._histogram_widget = histogram_widget
Expand All @@ -518,7 +525,34 @@ def __init__(

frame = self._process_indices(d, slice_indices=self._current_index)
frame = self._process_frame_apply(frame, data_ix)
ig = ImageGraphic(frame, name="image_widget_managed", **graphic_kwargs)

if (vmin_specified is None) or (vmax_specified is None):
# if either vmin or vmax are not specified, calculate an estimate by subsampling
vmin_estimate, vmax_estimate = quick_min_max(d)

# decide vmin, vmax passed to ImageGraphic constructor based on whether it's user specified or now
if vmin_specified is None:
# user hasn't specified vmin, use estimated value
vmin = vmin_estimate
else:
# user has provided a specific value, use that
vmin = vmin_specified

if vmax_specified is None:
vmax = vmax_estimate
else:
vmax = vmax_specified
else:
# both vmin and vmax are specified
vmin, vmax = vmin_specified, vmax_specified

ig = ImageGraphic(
frame,
name="image_widget_managed",
vmin=vmin,
vmax=vmax,
**graphic_kwargs,
)
subplot.add_graphic(ig)
subplot.name = name
subplot.set_title(name)
Expand Down Expand Up @@ -811,10 +845,6 @@ def reset_vmin_vmax(self):
hlut = subplot.docks["right"]["histogram_lut"]
hlut.set_data(data, reset_vmin_vmax=True)

else:
for ig in self.managed_graphics:
ig.reset_vmin_vmax()

def reset_vmin_vmax_frame(self):
"""
Resets the vmin vmax and HistogramLUT widgets w.r.t. the current data shown in the
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.