Discussion:
ImageDialog fails to show uint32 numpy images
coutinhotiago
2011-06-01 14:33:58 UTC
Permalink
Hello,
I am using a numpy.ndarray with dtype=uint32 as data source to the
image dialog.
I only get an empty widget.
I works fine with uint16 and float.

I have guidata 1.3.1 and guiqwt 2.1.3

here is the code I used:

#!/usr/bin/env python

import sys
import numpy

from guiqwt.plot import ImageDialog
from guiqwt.builder import make

from PyQt4 import Qt

app = Qt.QApplication([])
args = app.get_command_line_args()
image = numpy.arange(10000, dtype=numpy.uint32).reshape((100,100)) #
if I use uint16 here it works
image_item = make.image(image)
w = ImageDialog(edit=False, toolbar=True)
plot = w.get_plot()
plot.add_item(image_item)
w.show()

sys.exit(app.exec_())


thanks
Ludovic Aubry
2011-06-09 17:33:51 UTC
Permalink
Hi,

For now, uint32 is reserved for rgba images in the main scaler
routine.

int32 will work but you'll need to shift your pixels' values with
something like
(image - 2**31).astype(np.int32)
Post by coutinhotiago
Hello,
I am using a numpy.ndarray with dtype=uint32 as data source to the
image dialog.
I only get an empty widget.
I works fine with uint16 and float.
I have guidata 1.3.1 and guiqwt 2.1.3
#!/usr/bin/env python
import sys
import numpy
from guiqwt.plot import ImageDialog
from guiqwt.builder import make
from PyQt4 import Qt
app = Qt.QApplication([])
args = app.get_command_line_args()
image = numpy.arange(10000, dtype=numpy.uint32).reshape((100,100)) #
if I use uint16 here it works
image_item = make.image(image)
w = ImageDialog(edit=False, toolbar=True)
plot = w.get_plot()
plot.add_item(image_item)
w.show()
sys.exit(app.exec_())
thanks
Loading...