Problem when displaying an image having all its pixels forced at the same value

42 views
Skip to first unread message

mler...@gmail.com

unread,
Oct 11, 2018, 3:52:45 PM10/11/18
to pyqtgraph
Hello,

I have a problem when displaying an image having all its pixels forced at the same value, for example 0.
This trivial example illustrates the problem :

import numpy as np
import pyqtgraph as pg

imageData = np.zeros(shape=(150,150), dtype=np.int)
pg.image(imageData)


The result is :

runfile('C:/Users/Marc/.spyder-py3/temp.py', wdir='C:/Users/Marc/.spyder-py3')
C:\Users\Marc\Anaconda3\lib\site-packages\pyqtgraph\graphicsItems\ImageItem.py:464: RuntimeWarning: invalid value encountered in double_scalars
  bins = np.arange(mn, mx+1.01*step, step, dtype=np.int)
Traceback (most recent call last):

  File "C:\Users\Marc\Anaconda3\lib\site-packages\pyqtgraph\graphicsItems\HistogramLUTItem.py", line 195, in imageChanged
    h = self.imageItem().getHistogram()

  File "C:\Users\Marc\Anaconda3\lib\site-packages\pyqtgraph\graphicsItems\ImageItem.py", line 464, in getHistogram
    bins = np.arange(mn, mx+1.01*step, step, dtype=np.int)

ValueError: arange: cannot compute length



Any idea on the way to solve this without disabling the nice histogram functionality ?
My real application is displaying images updated slighly more than one time per second, and sometimes a constant image is generated.
As a work around when I find such an image, I add a small value to one of the pixels, but this is not a nice solution because the auto adujstment of the luminance scale displays a white dot on a black image ;-)

Marc

Jim Crowell

unread,
Oct 12, 2018, 7:38:30 AM10/12/18
to pyqtgraph
Reply all
Reply to author
Forward
0 new messages