Okay, so it worked:
I used the following function to create a QImage:
def numpyQImage(image):
qImg = QImage()
if image.dtype == np.uint8:
if len(image.shape) == 2:
channels = 1
height, width = image.shape
bytesPerLine = channels * width
qImg = QImage(
image.data, width, height, bytesPerLine, QImage.Format_Indexed8
)
qImg.setColorTable([qRgb(i, i, i) for i in range(256)])
elif len(image.shape) == 3:
if image.shape[2] == 3:
height, width, channels = image.shape
bytesPerLine = channels * width
qImg = QImage(
image.data, width, height, bytesPerLine, QImage.Format_RGB888
)
elif image.shape[2] == 4:
height, width, channels = image.shape
bytesPerLine = channels * width
fmt = QImage.Format_ARGB32
qImg = QImage(
image.data, width, height, bytesPerLine, QImage.Format_ARGB32
)
return qImg
After this,
new = out.copy()
image = numpyQImage(new)
pixmap = QPixmap.fromImage(image)
label.setPixmap(pixmap)
vbox = QVBoxLayout()
vbox.addWidget(label)
win.setLayout(vbox)
win.show()
sys.exit(app.exec_())
@SGaist Thank you for your help!