c++ - 在 QLabel/QGraphicsView 中显示 Dicom 图像

标签 c++ qt visual-studio-2013 dicom mitk

我是 MITK 的新手,不是高级程序员。 我需要帮助在 QT 小部件中显示 DICOM 图像。 我正在使用 Visual Studio 2013、MITK 和 QT5 开发一个程序,该程序应该打开并查看 DICOM 图像。用户浏览然后显示的图像。 我在这里看到:Interactively editing an existing rectangle on a QPixmap? QLabel 和 QGraphicsview 是可能的。 我只是不知道如何在我的程序中使用它:

void MainWindow::on_openButton_pressed()
{
QString imagePath = QFileDialog::getOpenFileName(
    this, tr("Open File"),
    "",
    tr("JPEG(*.jpg *.jpeg);;DICOM(*.dcm)")
    );
imageObject = new QImage();
imageObject->load(imagePath); //bool status is false here
image = QPixmap::fromImage(*imageObject)
image.load(imagePath);

QSize bigsize = ui->bigImageLabel->size();
QSize bigsize = ui->label->size();
ui->label->setPixmap(image.scaled(bigsize, Qt::IgnoreAspectRatio, Qt::FastTransformation));
ui->label->show();
}

我还尝试使用 QGraphicsView(仅适用于 JPEG)。

scene = new QGraphicsScene(this);
scene->addPixmap(image);
scene->setSceneRect(image.rect());
ui->ViewCoronal->setScene(scene);

我希望有人能帮助我。 提前致谢

最佳答案

如果 QImage::load 失败,则没有必要将其转换为 QPixmap,因为默认情况下 QImage 的大小为 0,0,当您显示此类 QPixmap 时,您什么也看不到。默认情况下,Qt 不支持“DICOM”图像格式,因此您无法使用 Qt 功能的任何部分显示该图像。

因此您可以自己实现此图像格式的Qt 插件,参见http://doc.qt.io/qt-5/qtimageformats-index.html或采用现有的,mitk 根据 http://docs.mitk.org/2015.05/group__org__mitk__gui__qt__dicom.html#details 有一个

但要使用 mitk 插件,您应该将其放置在正确的位置,例如 path/to/qt5/plugins/imageformats 您还必须确保您的程序、Qt 和 MITK 使用相同的配置,例如调试/发布

关于c++ - 在 QLabel/QGraphicsView 中显示 Dicom 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33479405/

相关文章:

c++ - 如何知道 VerticalScrollBar 何时显示?

c++ - 使用 glad with a QOpenGLWidget 加载 OpenGL 函数指针

git - 一个用户创建的分支其他人看不到

c++ - 尝试使用带有 VC2013 编译器的 Qt5、OpenCV 2.4.9 制作项目时获取 LNK1104

c# - 如何在 Visual Studio 2013 中安装 MongoDB.Driver

c++ - 使用鼠标拖动旋转 QLabel

c++ - 为什么 std::streamsize 被定义为有符号而不是无符号?

c++ - QObject : Cannot create children for a parent that is in a different thread

c++ - HP-35计算器基本功能代码

c++ - 重载类型转换运算符 : const & non-const