Skip to content

HistogramWidget: Part of the input data are not part of the result #4464

@vallsv

Description

@vallsv

Hi,

Will trying to dig inside data, we have noticed that the silx histogram was not able to display the MAX values.

Sounds like the pixels bigger than few millions are just skipped.

I feel like the problem could be because of the used RangeSlider.

It is always enabled, and probably Qt is not able to handle ranges bigger than some power of 2.

That's a huge problem, because actually we can't trust the default histogram. So what we have to do it manually on the side.

On a side note, it sounds like the reset zoom is not always doing properly the job. Sometimes the result is off view.

sample

Here is a sample to reproduce the prioblem.

Image

Here is a sample to reproduce the problem

diff --git a/examples/plotInteractiveImageROI.py b/examples/plotInteractiveImageROI.py
index a37396692..2a33df159 100644
--- a/examples/plotInteractiveImageROI.py
+++ b/examples/plotInteractiveImageROI.py
@@ -34,7 +34,7 @@ import sys
 import numpy
 
 from silx.gui import qt
-from silx.gui.plot import Plot2D
+from silx.gui.plot import ImageView
 from silx.gui.plot.tools.roi import RegionOfInterestManager
 from silx.gui.plot.tools.roi import RegionOfInterestTableWidget
 from silx.gui.plot.tools.roi import RoiModeSelectorAction
@@ -50,16 +50,22 @@ def dummy_image():
     signal = numpy.exp(-(xv**2 / 0.15**2 + yv**2 / 0.25**2))
     # add noise
     signal += 0.3 * numpy.random.random(size=signal.shape)
+    signal = signal.astype(numpy.uint32)
+    signal[0:100, 0:100] = 1_000_000
+    signal[100:200, 100:200] = 2_000_000
+    signal[200:300, 200:300] = 3_000_000   # <-- where do you go?
+    print(signal.dtype)
     return signal
 
 
 app = qt.QApplication([])  # Start QApplication
 
 # Create the plot widget and add an image
-plot = Plot2D()
+plot = ImageView()
 plot.getDefaultColormap().setName("viridis")
 plot.setKeepDataAspectRatio(True)
 plot.addImage(dummy_image())
+plot.getIntensityHistogramAction().setVisible(True)

Metadata

Metadata

Assignees

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