HistogramLUTWidget levels with ImageView

763 views
Skip to first unread message

Michael Ramm

unread,
May 29, 2013, 2:40:26 AM5/29/13
to pyqt...@googlegroups.com
Hi,

I have a question about ImageView: In the 'pyqtgraph example: ImageView' code, I try doing

imv.setLevels(500, 501)

then the image goes black, as expected, However, the position of the two infinite lines in HistogramLUTItem doesn't get updated. Is this the intended behavior? Everything is set properly by running

imv.getHistogramWidget().setLevels(500, 501)

however it seems this way doesn't offer an option to do autoLevels()

Thanks, Michael


Luke Campagnola

unread,
May 29, 2013, 2:43:20 PM5/29/13
to pyqt...@googlegroups.com
There was some similar discussion here:

..and if I recall correctly there was a bug that is now fixed in my in-progress branch, slated for next release. 
The latest ImageView.py is here:


Luke

Michael Ramm

unread,
May 29, 2013, 4:06:03 PM5/29/13
to pyqt...@googlegroups.com
Thanks for your help, this fixed it. Sorry missed the previous discussion.

Michael Ramm

unread,
May 29, 2013, 10:55:53 PM5/29/13
to pyqt...@googlegroups.com
Some follow up things, hope you don't mind.

1. I'm using ImageView to stream live data and right now every time setImage() is called, the y axis of the histogram widget gets updated with the min and max values of the data. This behavior results in the y-axis jumping around quite a bit if the data range fluctuates significantly image to image. Is there an easy way to disable this update?  believe it happens since setImage() calls updateImage() which calls getProcessedImage which, in turn, calls self.ui.histogram.setHistogramRange(self.levelMin, self.levelMax).

2. What's the proper way to embed the ImageView (including the histogram) into a PlotItem? I'd like to have he coordinate axes for the image displayed. Right now if I do 

plt = pg.PlotItem()
img_view = pg.ImageView(view = plt)

but then the histogram is missing. 

Thanks again, Michael



On Wednesday, May 29, 2013 11:43:20 AM UTC-7, Luke Campagnola wrote:

Luke Campagnola

unread,
May 30, 2013, 9:38:30 AM5/30/13
to pyqt...@googlegroups.com
On Wed, May 29, 2013 at 10:55 PM, Michael Ramm <mic...@gmail.com> wrote:
Some follow up things, hope you don't mind.

1. I'm using ImageView to stream live data and right now every time setImage() is called, the y axis of the histogram widget gets updated with the min and max values of the data. This behavior results in the y-axis jumping around quite a bit if the data range fluctuates significantly image to image. Is there an easy way to disable this update?  believe it happens since setImage() calls updateImage() which calls getProcessedImage which, in turn, calls self.ui.histogram.setHistogramRange(self.levelMin, self.levelMax).

I made a few changes here to allow setting the image without affecting the histogram range:

imageView.setImage(data, autoHistogramRange=False)

This will be in the next release.
 
2. What's the proper way to embed the ImageView (including the histogram) into a PlotItem? I'd like to have he coordinate axes for the image displayed. Right now if I do 

plt = pg.PlotItem()
img_view = pg.ImageView(view = plt)

but then the histogram is missing. 

The PlotItem is embedded inside the ImageView, not vice-versa. So this should give you the desired result:

plt = pg.PlotItem()
img_view = pg.ImageView(view = plt)
img_view.show()


Luke
Reply all
Reply to author
Forward
0 new messages