Results 1 to 4 of 4

Thread: Show Dicom Image using PyQt4

  1. #1
    Join Date
    Sep 2015
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Show Dicom Image using PyQt4

    Hello, I am studying the Qt Designer and PyQt4 to make a GUI, one of the GUI features will display a DICOM image that I implemented already using VTK and made a simple test on Qt to try to show that image, but I do not know how to link the image to Qt using PyQt, if anyone can help me how to do this, thank you!

    PyQt program obtained by pyuic4:

    from PyQt4 import QtCore, QtGui

    try:
    _fromUtf8 = QtCore.QString.fromUtf8
    except AttributeError:
    def _fromUtf8(s):
    return s

    try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
    return QtGui.QApplication.translate(context, text, disambig, _encoding)
    except AttributeError:
    def _translate(context, text, disambig):
    return QtGui.QApplication.translate(context, text, disambig)

    class Ui_Form(object):
    def setupUi(self, Form):
    Form.setObjectName(_fromUtf8("Form"))
    Form.resize(292, 337)
    self.image_vtk = QVTKRenderWindowInteractor(Form)
    self.image_vtk.setGeometry(QtCore.QRect(0, 10, 291, 331))
    self.image_vtk.setObjectName(_fromUtf8("image_vtk" ))

    self.retranslateUi(Form)
    QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
    Form.setWindowTitle(_translate("Form", "Form", None))

    from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor

    if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    Form = QtGui.QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)
    Form.show()
    sys.exit(app.exec_())


    My test program to open the interface, but not knowing how to link the image:

    import sys
    from PyQt4.QtCore import *
    from PyQt4.QtGui import *
    from xob import *

    class test(QWidget, Ui_Form):
    def __init__(self, parent=None):
    super(test, self).__init__(parent)
    self.setupUi(self)

    app = QApplication(sys.argv)
    dlg = test()
    dlg.show()
    app.exec_()


    Finally, the program using VTK opening DICOM image:

    import vtk

    def show_dicom_image(ndicom):
    reader = vtk.vtkDICOMImageReader()
    reader.SetFileName(ndicom)
    reader.Update()

    # Visualize
    imageViewer = vtk.vtkImageViewer()
    imageViewer.SetInputConnection(reader.GetOutputPor t())
    renderWindowInteractor = vtk.vtkRenderWindowInteractor()
    imageViewer.SetupInteractor(renderWindowInteractor )
    imageViewer.Render()
    imageViewer.GetRenderer().ResetCamera()
    imageViewer.Render()
    renderWindowInteractor.Start()

    show_dicom_image('image.dcm')

  2. #2
    Join Date
    Jul 2018
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Show Dicom Image using PyQt4

    Hello, you wrote that you have already implemented the task of showing Dicom images in Qt using VTK. Please, can you share the code? I am having errors like different header files are not found. I am new to app development and this project is given to me by my professor that I have to develop and application in Qt c++ that can open and analyze Dicom images in Linux environment. Please, help me. I have not been able to find a single way to read Dicom images in Qt so far. I am using Qt 5. Cmake 3.10.2.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Show Dicom Image using PyQt4

    He -did- share the code, most of it at least.

    VTK has the methods to read Dicom images. See vtkDICOMImageReader. Once you have read the image into a vtkImageData instance, you can modify the VTK VisualizeImageData example to put it into a vtkRenderWindow, which you then display using a QVTKWidget. Here is a complete example.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  4. #4
    Join Date
    Jul 2018
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Show Dicom Image using PyQt4

    I alread am fully aware of the example that you shared. That example does not work on my system and I have installed 5 different versions of vtk yet, the example works with none of those versions. Everytime I get the error, ui::mainwindow has no member named vtkrenderer or that qvtkwidget.h not found or some other error. I get a dozen errors with that example.

Similar Threads

  1. Qt Creator + gdcm (Grassroots DICOM): can't link libraries?
    By nimoleo in forum Installation and Deployment
    Replies: 6
    Last Post: 3rd April 2012, 13:49
  2. Problems compiling qdcws (Dicom Widget)
    By shadowroot in forum Qt Programming
    Replies: 3
    Last Post: 6th December 2011, 08:22
  3. Replies: 0
    Last Post: 7th May 2010, 23:45
  4. problem in Display sequence of DICOM images
    By vincat in forum Qt Programming
    Replies: 0
    Last Post: 26th May 2009, 07:42
  5. Show Image on a QLabel
    By ^NyAw^ in forum Newbie
    Replies: 11
    Last Post: 15th April 2008, 16:45

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.