我使用的是Pyside2,在这里我在屏幕上显示图像并编辑图像。我通过传递一个OpenCV图像来创建一个QImage对象。以下是我使用的代码:
# Convert hu into normalized values between 0 and 255
img = ( (img - img.max())/(img.max()-img.min()) ) * -1
img *= 255
img = img.astype(int)
img = (255 - img)
# Convert to opencv format
a = np.expand_dims(img, axis = 2)
img = np.concatenate((a, a, a), axis = 2)
img = np.require(img, np.uint8, 'C')
# QT Stuff
width, height, channel = img.shape
bytesPerLine = 3 * width
imgQT = QImage(img, height, width, bytesPerLine,
QImage.Format_RGB888).rgbSwapped()
self.imgQP = QPixmap.fromImage(imgQT)
imgQPrs = self.imgQP.scaled(768, 768)
self.scene_edit.addPixmap(imgQPrs)
self.edit_l.setScene(self.scene_edit)
问题是图像的亮度会根据显示的内容自动调整,这对这个应用来说是个大问题,因为它需要保持一致。在文档中我似乎真的不知道如何手动设置亮度,这样它就不会自动调整了。在
哦,好吧,愚蠢的问题。正常化导致问题。。。当然。我将不得不重新考虑如何将hounsfield单位转换为像素强度。在
感谢那些评论!在
相关问题 更多 >
编程相关推荐