hmeine / qimage2ndarray

qimage2ndarray is a small python extension for quickly converting between QImages and numpy.ndarrays (in both directions).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

2D Array float 64

ReDoDx09 opened this issue · comments

Hello,
i'm trying to use your lib in order to display some images of type array float64 (values are between -3.14 and 3.14), but it seems that it doesn't work for me. actually, It show me a black screen. does your lib support this kind of images ?
here is part of my code:
win = QWidget()
label = QLabel()
img=objdata[0] (type :array of float64, size (960,768)
yourQImage=qimage2ndarray.array2qimage(img)
qImg=QPixmap(yourQImage)
label.setPixmap(qImg)
vbox = QVBoxLayout()
vbox.addWidget(label)
win.setLayout(vbox)
win.show()
sys.exit(app.exec_())

the problem came from my code?
Thank you

Hi, I am sorry that for some reason, I missed your question for such a long time. Yes, qimage2ndarray was developed with exactly this use case in mind. The reason your image is black may be that the value range of -3..3 is very dark when considering the 0…255 range of QImage – typically, one performs a linear mapping or a look up table in such cases. In your example, setting normalize = True in the call to array2qimage might be enough? (See the documentation for more options.)

I will close this issue for now; please reopen if you think there is an issue with this package.