Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to view dicom images using QT and VTK?
Forum Updated to NodeBB v4.3 + New Features

How to view dicom images using QT and VTK?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pvirk
    wrote on 9 Mar 2020, 13:37 last edited by
    #1

    Hello,

    I have created GUI using QT.
    Now I need to read dicom images using VTK and load it in qt widget. All I am using in Ubuntu system.
    I have installed VTK 8.2 and QT 4.10 successfully.
    I have checked some example to read dicom series from following sites -
    https://vtk.org/Wiki/VTK/Examples/Cxx/IO/ReadDICOMSeries
    https://github.com/fblupi/read-dicom-series-vtk-qt

    But I am unable to see images in qtwidget.
    There is no errors. That's why I am unable to understand what is the actual issue?

    P.S. I used the same code in windows system and there it is working fine. I can see dicom images in qt widget.

    So, anyone knows, What is the problem and is it due to Ubuntu system or QT?

    If anyone shares useful code to view dicom images using QT and VTK, that will also really helpful.
    Please help me to solve this issue.

    Thanks in advance.

    J 1 Reply Last reply 9 Mar 2020, 14:00
    0
    • P pvirk
      9 Mar 2020, 13:37

      Hello,

      I have created GUI using QT.
      Now I need to read dicom images using VTK and load it in qt widget. All I am using in Ubuntu system.
      I have installed VTK 8.2 and QT 4.10 successfully.
      I have checked some example to read dicom series from following sites -
      https://vtk.org/Wiki/VTK/Examples/Cxx/IO/ReadDICOMSeries
      https://github.com/fblupi/read-dicom-series-vtk-qt

      But I am unable to see images in qtwidget.
      There is no errors. That's why I am unable to understand what is the actual issue?

      P.S. I used the same code in windows system and there it is working fine. I can see dicom images in qt widget.

      So, anyone knows, What is the problem and is it due to Ubuntu system or QT?

      If anyone shares useful code to view dicom images using QT and VTK, that will also really helpful.
      Please help me to solve this issue.

      Thanks in advance.

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 9 Mar 2020, 14:00 last edited by
      #2

      @pvirk said in How to view dicom images using QT and VTK?:

      I have installed VTK 8.2 and QT 4.10 successfully.

      unlikely, as Qt 4.10 does not exist. You may have installed QtCreator 4.10 which is an old version, but possible.

      Please identify the Qt version you use for your project.

      P.S. I used the same code in windows system and there it is working fine. I can see dicom images in qt widget.

      I doubt anyone can help you without you actually posting "the code that works on windows but not on Linux"


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      1
      • P Offline
        P Offline
        pvirk
        wrote on 9 Mar 2020, 14:26 last edited by
        #3

        Thanks for reply.

        I have installed the QT version is 5.13.1 both in Ubuntu and QT 5.12.5 for Windows systems.

        First, I used the same code from https://github.com/fblupi/read-dicom-series-vtk-qt
        which is working in windows, but not in Ubuntu.

        The some part of my code is -

        void ReadDICOMSeriesQt::openDICOMFolder() {
        QString folderNameDICOM = QFileDialog::getExistingDirectory(this, tr("Open DICOM Folder"), QDir::currentPath(), QFileDialog::ShowDirsOnly | QFileDialog::DontUseNativeDialog);

        drawDICOMSeries(folderNameDICOM.toUtf8().constData());
        

        }

        void ReadDICOMSeriesQt::drawDICOMSeries(std::string folderDICOM) {
        readerDCMSeries->SetDirectoryName(folderDICOM.c_str());
        readerDCMSeries->Update();
        imageViewer->SetInputConnection(readerDCMSeries->GetOutputPort());

        ui->widget->SetRenderWindow(renderWindow);
        
        renderWindowInteractor = ui->widget->GetInteractor();
        
        imageViewer->SetRenderWindow(ui->widget->GetRenderWindow());
        myInteractorStyle->SetImageViewer(imageViewer);
        myInteractorStyle->SetStatusMapper(sliceTextMapper);
        
        imageViewer->SetupInteractor(renderWindowInteractor);
        renderWindowInteractor->SetInteractorStyle(myInteractorStyle);
        // add slice status message and usage hint message to the renderer
        imageViewer->GetRenderer()->AddActor2D(sliceTextActor);
        imageViewer->GetRenderer()->AddActor2D(usageTextActor);
        
        imageViewer->Render();
        imageViewer->GetRenderer()->ResetCamera();
        imageViewer->Render();
        
        renderWindowInteractor->Start();
        

        This part of code is used to view dicom series qt widget by opening folder.
        Could you please check it and tell me what is the problem?
        Also could you please share some code for the same?
        Thanks again.

        J 1 Reply Last reply 9 Mar 2020, 14:38
        0
        • P pvirk
          9 Mar 2020, 14:26

          Thanks for reply.

          I have installed the QT version is 5.13.1 both in Ubuntu and QT 5.12.5 for Windows systems.

          First, I used the same code from https://github.com/fblupi/read-dicom-series-vtk-qt
          which is working in windows, but not in Ubuntu.

          The some part of my code is -

          void ReadDICOMSeriesQt::openDICOMFolder() {
          QString folderNameDICOM = QFileDialog::getExistingDirectory(this, tr("Open DICOM Folder"), QDir::currentPath(), QFileDialog::ShowDirsOnly | QFileDialog::DontUseNativeDialog);

          drawDICOMSeries(folderNameDICOM.toUtf8().constData());
          

          }

          void ReadDICOMSeriesQt::drawDICOMSeries(std::string folderDICOM) {
          readerDCMSeries->SetDirectoryName(folderDICOM.c_str());
          readerDCMSeries->Update();
          imageViewer->SetInputConnection(readerDCMSeries->GetOutputPort());

          ui->widget->SetRenderWindow(renderWindow);
          
          renderWindowInteractor = ui->widget->GetInteractor();
          
          imageViewer->SetRenderWindow(ui->widget->GetRenderWindow());
          myInteractorStyle->SetImageViewer(imageViewer);
          myInteractorStyle->SetStatusMapper(sliceTextMapper);
          
          imageViewer->SetupInteractor(renderWindowInteractor);
          renderWindowInteractor->SetInteractorStyle(myInteractorStyle);
          // add slice status message and usage hint message to the renderer
          imageViewer->GetRenderer()->AddActor2D(sliceTextActor);
          imageViewer->GetRenderer()->AddActor2D(usageTextActor);
          
          imageViewer->Render();
          imageViewer->GetRenderer()->ResetCamera();
          imageViewer->Render();
          
          renderWindowInteractor->Start();
          

          This part of code is used to view dicom series qt widget by opening folder.
          Could you please check it and tell me what is the problem?
          Also could you please share some code for the same?
          Thanks again.

          J Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 9 Mar 2020, 14:38 last edited by
          #4

          @pvirk said in How to view dicom images using QT and VTK?:

          openDICOMFolder

          looking through the code provided, seems like reader reader->SetDirectoryName(folderDICOM.c_str()); does not use QFile so the returned path has probably the wrong folder separation on linux & macOS

          It was probably never meant for cross compilation.
          I would suggest contacting the repo owner 🤷‍♂️


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          1
          • P Offline
            P Offline
            pvirk
            wrote on 9 Mar 2020, 15:07 last edited by
            #5

            Sorry but i am unable to understand the problem.
            The reader used in code is vtkDICOMImageReader which has function SetDirectoryName.

            So you are saying, it will be different on linux system to get the directory path?

            I have asked already to the repo owner, they have also told me that for them there was some issue on linux that time. But they don't remember it now.

            Could you please suggest me some other solution?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on 9 Mar 2020, 22:21 last edited by
              #6

              Hi,

              If it's really a question of separator you can use QDir::toNativeSeparators for the conversion.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • P Offline
                P Offline
                pvirk
                wrote on 10 Mar 2020, 09:37 last edited by
                #7

                Hello,
                Could you please tell me how to use it in my example?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 10 Mar 2020, 21:24 last edited by
                  #8

                  Use it on folderDICOM before passing it further.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  1/8

                  9 Mar 2020, 13:37

                  • Login

                  • Login or register to search.
                  1 out of 8
                  • First post
                    1/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved