-
Notifications
You must be signed in to change notification settings - Fork 137
Closed
Labels
good first issueGood for newcomers - well-scoped, easy issue.Good for newcomers - well-scoped, easy issue.type: featureNew feature, enhancement or requestNew feature, enhancement or request
Description
Environment (optional)
No response
Describe the feature
The current deepinv.utils.plot function only supports two normalization modes before plotting:
- per-image min–max rescaling
- clipping between [0, 1]
However, in many real world applications (for instance tomography), images must be plotted using a shared absolute scale. The plot utility should support a shared color scale.
The current implementation only allows for individual rescales, which makes it unusable for most real-world evaluation or publication purposes. Here's a simple example showing how different the plots can look:
import deepinv as dinv
import matplotlib.pyplot as plt
x = dinv.utils.load_example("butterfly.png", img_size=(128, 128), grayscale=True)
physics1 = dinv.physics.PoissonNoise(gain=1 / 5)
physics2 = dinv.physics.PoissonNoise(gain=1 / 100)
y1 = physics1(x)
y2 = physics2(x)
print(y1.min(), y1.max())
print(y2.min(), y2.max())
dinv.utils.plot(
[x, y1, y2],
titles=["Ground-truth image", "Noisy measurement 1", "Noisy measurement 2"],
figsize=(10, 4),
)
fig, axes = plt.subplots(1, 3, figsize=(10, 4))
vmin = min(x.min().item(), y1.min().item(), y2.min().item())
vmax = max(x.max().item(), y1.max().item(), y2.max().item())
im0 = axes[0].imshow(x.squeeze(), cmap="gray", vmin=vmin, vmax=vmax)
axes[0].set_title("Ground-truth image")
axes[0].axis("off")
im1 = axes[1].imshow(y1.squeeze(), cmap="gray", vmin=vmin, vmax=vmax)
axes[1].set_title("Noisy measurement 1")
axes[1].axis("off")
im2 = axes[2].imshow(y2.squeeze(), cmap="gray", vmin=vmin, vmax=vmax)
axes[2].set_title("Noisy measurement 2")
axes[2].axis("off")
plt.tight_layout()
plt.show()Output:
Motivation
Many of the deepinv users work on quantitative applications where units matter, and they can't use our plotting function for their plots.
Alternatives considered
No response
Additional context
No response
nucli-vicky and Andrewwangojscanvic
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomers - well-scoped, easy issue.Good for newcomers - well-scoped, easy issue.type: featureNew feature, enhancement or requestNew feature, enhancement or request