Adding percentile markers to HistogramLUTWidget in ImageView

39 views
Skip to first unread message

Bjorn

unread,
Jul 21, 2017, 2:12:25 PM7/21/17
to pyqtgraph
I recently added to the ImageView class to make a live-updating GUI for a camera system. I needed to add markers to the histogram to show the 10th-90th percentile values. I did think by manually plotting points on the HistogramLUTITem's  .plot attribute (PlotDataItem) .scatter attribute (ScatterPlotItem), and manually showing the scatter attribute. This was necessary since PlotDataItem only has a setData function for plotting, which clears the plot each time it is called (unlike the more standard PlotItem used in the examples).

Is this the only way to implement adding a plot to the HistogramLUTItem? If so, it seems worth replacing the PlotDataItem in the HistogramLUTITem with a PlotItem, since it would give more control over the histogram while adapting the ImageView class.

Tim Williams

unread,
Jul 22, 2017, 3:32:31 PM7/22/17
to pyqtgraph
You could create your own class that inherits HistogramLUTItem to add the percentiles to the plot. Is this basically what you did, but to the ImageView class?  I recently did this to my own application where I wanted the HistogramLUTItem to display 3 histograms for RGB images.  It's a bit of a hack, because I had to steal the ImageItem.getHistogram() function and redefined it in my RGBHistogramLUT class. I have 2 additional plots to the HistogramLUTItem.plot attribute for the green and blue histograms and add/remove them from the viewbox depending on if my data is single band, or RGBA.

(Like I said, it's a hack, but it works for me.)
Reply all
Reply to author
Forward
0 new messages