bug in ImageView(... levels=(min,max))

592 views
Skip to first unread message

Karl Bedrich

unread,
Apr 10, 2013, 6:29:39 AM4/10/13
to pyqt...@googlegroups.com
hey,

my imagedata contains some nan-values. therefore i transform those values to 0. because the other data are far aboth 0 'autoLevel' doesn't show the right scale.

when i do:

self.view=pg.PlotItem(...)

self.plot = pg.ImageView(view=self.view)

self.plot.setImage(nanToZerosImg,autoRange=True,autoLevels=False, levels=( np.nanmin(img), np.nanmax(img)   )


the scale of all images stuck between 0-1


only the option:


self.plot.setLevels(np.nanmin(img), np.nanmax(img))


gives the right scale but doesn't move the colorbar on the right to it.


what can i do 

* to use the levels-keyword in setImage

* to move the colorbar to the right scale


thanks a lot,

karl

Luke Campagnola

unread,
Apr 10, 2013, 8:26:46 AM4/10/13
to pyqt...@googlegroups.com
On Wed, Apr 10, 2013 at 6:29 AM, Karl Bedrich <karlgeor...@gmail.com> wrote:
my imagedata contains some nan-values. therefore i transform those values to 0. because the other data are far aboth 0 'autoLevel' doesn't show the right scale.

when i do:

self.view=pg.PlotItem(...)

self.plot = pg.ImageView(view=self.view)

self.plot.setImage(nanToZerosImg,autoRange=True,autoLevels=False, levels=( np.nanmin(img), np.nanmax(img)   )


the scale of all images stuck between 0-1

only the option:

self.plot.setLevels(np.nanmin(img), np.nanmax(img))


The levels argument in setImage is broken and will be fixed in the next release. Thanks for reporting this!

I'm surprised that setLevels is also not working. The following example works correctly for me:

import pyqtgraph as pg
pg.mkQApp()
import numpy as np
img = np.random.normal(size=(100, 100), loc=100)
img[img<98] = 0
view = pg.ImageView()
view.show()
view.setImage(img)
view.setLevels(97, 103)

Can you modify this example to reproduce the problem you are having?


Thanks,
Luke

Karl Bedrich

unread,
Apr 23, 2013, 12:10:50 PM4/23/13
to pyqt...@googlegroups.com
hey luke,
sorry for my late response. i tried to to the problem by my own but i failed.

of course: setLevels() works. but the HistogramLUTWidget wont be updated.
your given example didn't work for me, so i used example/imageView.

i wrote imv.setLevels(106,108) right after imv.setImage and the same problem appeared.

i attached an image of this.
as you see the boundaries of the histogramm remain at the initial state.

bye,
karl
 


2013/4/10 Luke Campagnola <luke.ca...@gmail.com>

--
-- [ You are subscribed to pyqt...@googlegroups.com. To unsubscribe, send email to pyqtgraph+...@googlegroups.com ]
---
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Bildschirmfoto vom 2013-04-23 18:06:38.png

Luke Campagnola

unread,
Apr 23, 2013, 12:38:12 PM4/23/13
to pyqt...@googlegroups.com
On Tue, Apr 23, 2013 at 12:10 PM, Karl Bedrich <ka...@bedrich.de> wrote:
hey luke,
sorry for my late response. i tried to to the problem by my own but i failed.

of course: setLevels() works. but the HistogramLUTWidget wont be updated.
your given example didn't work for me, so i used example/imageView.

i wrote imv.setLevels(106,108) right after imv.setImage and the same problem appeared.

i attached an image of this.
as you see the boundaries of the histogramm remain at the initial state.

In this example, the ImageView is handling a 3D data set. The range on the histogram is set to the full range of the 3D image data--if you move the time line at the bottom, you'll see that the histogram ultimately occupies the entire range of the plot. So I think this is the expected behavior. 

Are you saying that you want to be able to zoom the histogram in to show just the selected region? For this, you could write:
    imv.ui.histogram.vb.setYRange(106,108)


Luke

Karl Bedrich

unread,
Apr 23, 2013, 12:45:05 PM4/23/13
to pyqt...@googlegroups.com
that's it:
imv.ui.histogram.vb.setYRange(106,108)

it can be so easy...

thanks a lot luke!

Farris Bush

unread,
Aug 15, 2014, 9:35:28 PM8/15/14
to pyqt...@googlegroups.com
Hey Luke,
       I'm trying to replicate this result of setLevels() with an image object. In the API it says that it is merely a window that wraps a ImageView into it. Unfortunately I can't find a way to access that object. How would you access the ImageView object so that you can call setLevels? 

Farris

Luke Campagnola

unread,
Aug 18, 2014, 4:19:28 PM8/18/14
to pyqt...@googlegroups.com
On Fri, Aug 15, 2014 at 9:35 PM, Farris Bush <far...@spotterrf.com> wrote:
Hey Luke,
       I'm trying to replicate this result of setLevels() with an image object. In the API it says that it is merely a window that wraps a ImageView into it. Unfortunately I can't find a way to access that object. How would you access the ImageView object so that you can call setLevels? 

I guess you are talking about ImageWindow, which is actually just a subclass of ImageView, so you should be able to call setLevels directly from there.



Reply all
Reply to author
Forward
0 new messages