0

I'm new to MITK and not an advanced programmer. I need help displaying a DICOM image in a QT Widget. I am using Visual Studio 2013, MITK, and QT5 to develop a program, that is supposed to open and view DICOM images. The user browses an image which is then displayed. I`ve seen here: Interactively editing an existing rectangle on a QPixmap? that it is possible with a QLabel and QGraphicsview. I just don't know how to use that in my program:

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();
}

I also tried using QGraphicsView (which only works for JPEGs).

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

I hope someone can help me. Thanks in advance

Community
  • 1
  • 1
user39458
  • 1
  • 3
  • What is the bug you're running into? does it crash? does the compiler give errors? – Jaap Nov 02 '15 at 14:06
  • I assume the problem is connecting MITK DICOM file support with Qt GUI. I say this is an XY problem. The OP should instead use the VTK support in the MITK library for the visualization of the DICOM images and put that in a QWidget. – drescherjm Nov 02 '15 at 14:16
  • @Jaap: there are no errors, just nothing happens.. the mbilog message says: "QPixmap::scales: Pixmap is a null pixmap" – user39458 Nov 03 '15 at 08:50

1 Answers1

1

If QImage::load failed there is no point to convert it QPixmap, because of QImage by default constructed with size 0,0 and you see nothing when you show such QPixmap. By default Qt not support "DICOM" image format, so you cann't show this image using any part of Qt functionality.

So you can implement Qt plugin for this image format by your self, see http://doc.qt.io/qt-5/qtimageformats-index.html or take existing one, mitk have one according to http://docs.mitk.org/2015.05/group__org__mitk__gui__qt__dicom.html#details

But to use mitk plugin you should place into right place, like path/to/qt5/plugins/imageformats also you have to make sure that your program, Qt and MITK using the same configuration like Debug/Release

fghj
  • 8,898
  • 4
  • 28
  • 56
  • 1
    That is correct. Your sample code does not use MITK at all. It's just straight Qt. The QImage load method cannot read a DICOM image. Using a framework like MITK requires a very large learning curve. To start I would recommend writing some code which loads non DICOM images and does some of the operations you require. Next use a simpler framework to learn how to load DICOM images. (GDCM for example) The most important things to know are 1- DICOM files have a lot of meta data that other image formats do not have, 2 - DICOM image data itself is often different from other image formats. – john elemans Nov 05 '15 at 18:11