Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PyQt QImage cna't copy, crash without error code

PyQt QImage cna't copy, crash without error code

Scheduled Pinned Locked Moved Solved Qt for Python
27 Posts 5 Posters 4.2k Views
  • 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.
  • D Offline
    D Offline
    darrenleeleelee1
    wrote on 7 Jun 2021, 04:39 last edited by
    #1

    I want to show on a QImage and translate to QPixmap, but when I want to manipulate(copy, scaled, or construct by QPixmap) qimage then the process will crash.But If I copy to a small rectangle like(2048, 2048) It was not crash any more.

    This arr is numpy ndarray, shape:(3408, 2235) dtype:uint16, maximum value is 65535 and minimum is 0.

    I wonder why the process will crash without error code.

    How can I fix it?

    from PyQt5 import QtCore, QtGui, QtWidgets
    from pydicom import dcmread
    import numpy as np
    class Ui_MainWindow(object):
        def setupUi(self, MainWindow):
            MainWindow.setObjectName("MainWindow")
            MainWindow.resize(2048, 2048)
            self.centralwidget = QtWidgets.QWidget(MainWindow)
            self.centralwidget.setObjectName("centralwidget")
            self.photo = QtWidgets.QLabel(self.centralwidget)
            self.photo.setGeometry(QtCore.QRect(0, 0, 2048, 2048))
            self.photo.setText("")
            ds = dcmread('./5F329172_20170623_CR_2_1_1')
            arr = ds.pixel_array
            print("ndarray shape: ", arr.shape, " dtype: ", arr.dtype)
            print("ndarray max: ", np.max(arr), " min: ", np.min(arr))
            qimage = QtGui.QImage(arr, arr.shape[1], arr.shape[0], QtGui.QImage.Format_Grayscale16)
            qimage = qimage.copy()
            # qimage = qimage.copy(QtCore.QRect(0, 0, 2048, 2048)) this will not crash
            pixmap = QtGui.QPixmap.fromImage(qimage)
            self.photo.setPixmap(pixmap)
            self.photo.setScaledContents(True)
            self.photo.setObjectName("photo")
            MainWindow.setCentralWidget(self.centralwidget)
            self.menubar = QtWidgets.QMenuBar(MainWindow)
            self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
            self.menubar.setObjectName("menubar")
            MainWindow.setMenuBar(self.menubar)
            self.statusbar = QtWidgets.QStatusBar(MainWindow)
            self.statusbar.setObjectName("statusbar")
            MainWindow.setStatusBar(self.statusbar)
    
            self.retranslateUi(MainWindow)
            QtCore.QMetaObject.connectSlotsByName(MainWindow)
    
    
        def retranslateUi(self, MainWindow):
            _translate = QtCore.QCoreApplication.translate
            MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
         
    
    if __name__ == "__main__":
        import sys
        app = QtWidgets.QApplication(sys.argv)
        MainWindow = QtWidgets.QMainWindow()
        ui = Ui_MainWindow()
        ui.setupUi(MainWindow)
        MainWindow.show()
        sys.exit(app.exec_())
    

    dicom data: 5F329172_20170623_CR_2_1_1

    J J 2 Replies Last reply 7 Jun 2021, 05:11
    0
    • D darrenleeleelee1
      8 Jun 2021, 07:09

      @KroMignon said in PyQt QImage cna't copy, crash without error code:

      arr.shape[1]*2

      sorry, I read through the QImage API, but I don;t get why I need to add this.
      After I add this it seems can work.

      K Offline
      K Offline
      KroMignon
      wrote on 8 Jun 2021, 07:15 last edited by KroMignon 6 Aug 2021, 07:16
      #26

      @darrenleeleelee1 said in PyQt QImage cna't copy, crash without error code:

      sorry, I read through the QImage API, but I don;t get why I need to add this.

      Then you don't read carefully ;)
      The point is when you only specify width and height: The width and height must be specified in pixels, data must be 32-bit aligned, and each scanline of data in the image must also be 32-bit aligned.

      To avoid this, you can use width, height and scanline length in bytes, which is pixel_per_line x pixel_size:

      • pixel_per_line is arr.shape[1]
      • pixel_size is uint16 which are 2 bytes

      ==> scanline_size = arr.shape[1]*2

      After I add this it seems can work.

      Great

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      D 1 Reply Last reply 8 Jun 2021, 11:51
      4
      • D darrenleeleelee1
        7 Jun 2021, 04:39

        I want to show on a QImage and translate to QPixmap, but when I want to manipulate(copy, scaled, or construct by QPixmap) qimage then the process will crash.But If I copy to a small rectangle like(2048, 2048) It was not crash any more.

        This arr is numpy ndarray, shape:(3408, 2235) dtype:uint16, maximum value is 65535 and minimum is 0.

        I wonder why the process will crash without error code.

        How can I fix it?

        from PyQt5 import QtCore, QtGui, QtWidgets
        from pydicom import dcmread
        import numpy as np
        class Ui_MainWindow(object):
            def setupUi(self, MainWindow):
                MainWindow.setObjectName("MainWindow")
                MainWindow.resize(2048, 2048)
                self.centralwidget = QtWidgets.QWidget(MainWindow)
                self.centralwidget.setObjectName("centralwidget")
                self.photo = QtWidgets.QLabel(self.centralwidget)
                self.photo.setGeometry(QtCore.QRect(0, 0, 2048, 2048))
                self.photo.setText("")
                ds = dcmread('./5F329172_20170623_CR_2_1_1')
                arr = ds.pixel_array
                print("ndarray shape: ", arr.shape, " dtype: ", arr.dtype)
                print("ndarray max: ", np.max(arr), " min: ", np.min(arr))
                qimage = QtGui.QImage(arr, arr.shape[1], arr.shape[0], QtGui.QImage.Format_Grayscale16)
                qimage = qimage.copy()
                # qimage = qimage.copy(QtCore.QRect(0, 0, 2048, 2048)) this will not crash
                pixmap = QtGui.QPixmap.fromImage(qimage)
                self.photo.setPixmap(pixmap)
                self.photo.setScaledContents(True)
                self.photo.setObjectName("photo")
                MainWindow.setCentralWidget(self.centralwidget)
                self.menubar = QtWidgets.QMenuBar(MainWindow)
                self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
                self.menubar.setObjectName("menubar")
                MainWindow.setMenuBar(self.menubar)
                self.statusbar = QtWidgets.QStatusBar(MainWindow)
                self.statusbar.setObjectName("statusbar")
                MainWindow.setStatusBar(self.statusbar)
        
                self.retranslateUi(MainWindow)
                QtCore.QMetaObject.connectSlotsByName(MainWindow)
        
        
            def retranslateUi(self, MainWindow):
                _translate = QtCore.QCoreApplication.translate
                MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
             
        
        if __name__ == "__main__":
            import sys
            app = QtWidgets.QApplication(sys.argv)
            MainWindow = QtWidgets.QMainWindow()
            ui = Ui_MainWindow()
            ui.setupUi(MainWindow)
            MainWindow.show()
            sys.exit(app.exec_())
        

        dicom data: 5F329172_20170623_CR_2_1_1

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 7 Jun 2021, 05:11 last edited by
        #2

        @darrenleeleelee1 said in PyQt QImage cna't copy, crash without error code:

        I wonder why the process will crash without error code.

        Did you use debugger to see where exactly it is crashing?
        You should also check https://doc.qt.io/qt-5/qpixmap.html#isNull and https://doc.qt.io/qt-5/qimage.html#isNull before using the QImage/QPixmap.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        D 1 Reply Last reply 7 Jun 2021, 08:06
        1
        • J jsulm
          7 Jun 2021, 05:11

          @darrenleeleelee1 said in PyQt QImage cna't copy, crash without error code:

          I wonder why the process will crash without error code.

          Did you use debugger to see where exactly it is crashing?
          You should also check https://doc.qt.io/qt-5/qpixmap.html#isNull and https://doc.qt.io/qt-5/qimage.html#isNull before using the QImage/QPixmap.

          D Offline
          D Offline
          darrenleeleelee1
          wrote on 7 Jun 2021, 08:06 last edited by
          #3

          @jsulm I used debugger, it will process to qimage = qimage.copy() this command,then just crash without any error code.And I try to use qimage.isNull() it return False.

          J.HilkJ 1 Reply Last reply 7 Jun 2021, 08:20
          0
          • D darrenleeleelee1
            7 Jun 2021, 08:06

            @jsulm I used debugger, it will process to qimage = qimage.copy() this command,then just crash without any error code.And I try to use qimage.isNull() it return False.

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on 7 Jun 2021, 08:20 last edited by
            #4

            @darrenleeleelee1 out of curiosity, does it also crash, if you try to not copy it into itself but a different variable?


            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.

            D 1 Reply Last reply 7 Jun 2021, 08:27
            0
            • J.HilkJ J.Hilk
              7 Jun 2021, 08:20

              @darrenleeleelee1 out of curiosity, does it also crash, if you try to not copy it into itself but a different variable?

              D Offline
              D Offline
              darrenleeleelee1
              wrote on 7 Jun 2021, 08:27 last edited by darrenleeleelee1 6 Jul 2021, 08:53
              #5

              @J-Hilk said in PyQt QImage cna't copy, crash without error code:

              curiosity

              Yes,it also crash.

              J 1 Reply Last reply 7 Jun 2021, 08:55
              0
              • D darrenleeleelee1
                7 Jun 2021, 04:39

                I want to show on a QImage and translate to QPixmap, but when I want to manipulate(copy, scaled, or construct by QPixmap) qimage then the process will crash.But If I copy to a small rectangle like(2048, 2048) It was not crash any more.

                This arr is numpy ndarray, shape:(3408, 2235) dtype:uint16, maximum value is 65535 and minimum is 0.

                I wonder why the process will crash without error code.

                How can I fix it?

                from PyQt5 import QtCore, QtGui, QtWidgets
                from pydicom import dcmread
                import numpy as np
                class Ui_MainWindow(object):
                    def setupUi(self, MainWindow):
                        MainWindow.setObjectName("MainWindow")
                        MainWindow.resize(2048, 2048)
                        self.centralwidget = QtWidgets.QWidget(MainWindow)
                        self.centralwidget.setObjectName("centralwidget")
                        self.photo = QtWidgets.QLabel(self.centralwidget)
                        self.photo.setGeometry(QtCore.QRect(0, 0, 2048, 2048))
                        self.photo.setText("")
                        ds = dcmread('./5F329172_20170623_CR_2_1_1')
                        arr = ds.pixel_array
                        print("ndarray shape: ", arr.shape, " dtype: ", arr.dtype)
                        print("ndarray max: ", np.max(arr), " min: ", np.min(arr))
                        qimage = QtGui.QImage(arr, arr.shape[1], arr.shape[0], QtGui.QImage.Format_Grayscale16)
                        qimage = qimage.copy()
                        # qimage = qimage.copy(QtCore.QRect(0, 0, 2048, 2048)) this will not crash
                        pixmap = QtGui.QPixmap.fromImage(qimage)
                        self.photo.setPixmap(pixmap)
                        self.photo.setScaledContents(True)
                        self.photo.setObjectName("photo")
                        MainWindow.setCentralWidget(self.centralwidget)
                        self.menubar = QtWidgets.QMenuBar(MainWindow)
                        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
                        self.menubar.setObjectName("menubar")
                        MainWindow.setMenuBar(self.menubar)
                        self.statusbar = QtWidgets.QStatusBar(MainWindow)
                        self.statusbar.setObjectName("statusbar")
                        MainWindow.setStatusBar(self.statusbar)
                
                        self.retranslateUi(MainWindow)
                        QtCore.QMetaObject.connectSlotsByName(MainWindow)
                
                
                    def retranslateUi(self, MainWindow):
                        _translate = QtCore.QCoreApplication.translate
                        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
                     
                
                if __name__ == "__main__":
                    import sys
                    app = QtWidgets.QApplication(sys.argv)
                    MainWindow = QtWidgets.QMainWindow()
                    ui = Ui_MainWindow()
                    ui.setupUi(MainWindow)
                    MainWindow.show()
                    sys.exit(app.exec_())
                

                dicom data: 5F329172_20170623_CR_2_1_1

                J Offline
                J Offline
                JonB
                wrote on 7 Jun 2021, 08:54 last edited by JonB 6 Jul 2021, 08:55
                #6

                @darrenleeleelee1 said in PyQt QImage cna't copy, crash without error code:

                    qimage = qimage.copy()
                    # qimage = qimage.copy(QtCore.QRect(0, 0, 2048, 2048)) this will not crash
                

                So do you want to tell us what qImage.width() & qImage.height() of the image actually are?

                D 1 Reply Last reply 7 Jun 2021, 09:39
                0
                • D darrenleeleelee1
                  7 Jun 2021, 08:27

                  @J-Hilk said in PyQt QImage cna't copy, crash without error code:

                  curiosity

                  Yes,it also crash.

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 7 Jun 2021, 08:55 last edited by
                  #7

                  @darrenleeleelee1 Did you check whether the image is a null image as I already suggested?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  J 1 Reply Last reply 7 Jun 2021, 08:58
                  0
                  • J jsulm
                    7 Jun 2021, 08:55

                    @darrenleeleelee1 Did you check whether the image is a null image as I already suggested?

                    J Offline
                    J Offline
                    JonB
                    wrote on 7 Jun 2021, 08:58 last edited by
                    #8

                    @jsulm
                    He claims

                    And I try to use qimage.isNull() it return False.

                    assuming this check is done in the right place.

                    J 1 Reply Last reply 7 Jun 2021, 09:02
                    2
                    • J JonB
                      7 Jun 2021, 08:58

                      @jsulm
                      He claims

                      And I try to use qimage.isNull() it return False.

                      assuming this check is done in the right place.

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 7 Jun 2021, 09:02 last edited by
                      #9

                      @JonB I need to read more carefully sometimes :-)

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1
                      • J JonB
                        7 Jun 2021, 08:54

                        @darrenleeleelee1 said in PyQt QImage cna't copy, crash without error code:

                            qimage = qimage.copy()
                            # qimage = qimage.copy(QtCore.QRect(0, 0, 2048, 2048)) this will not crash
                        

                        So do you want to tell us what qImage.width() & qImage.height() of the image actually are?

                        D Offline
                        D Offline
                        darrenleeleelee1
                        wrote on 7 Jun 2021, 09:39 last edited by
                        #10

                        @JonB 1767f8ea-cdc2-4a02-8f12-b6034f2aac2e-image.png
                        and it return 2235 3408
                        @J-Hilk I copy to tmp and it still crash.

                        J 1 Reply Last reply 7 Jun 2021, 09:50
                        0
                        • D darrenleeleelee1
                          7 Jun 2021, 09:39

                          @JonB 1767f8ea-cdc2-4a02-8f12-b6034f2aac2e-image.png
                          and it return 2235 3408
                          @J-Hilk I copy to tmp and it still crash.

                          J Offline
                          J Offline
                          JonB
                          wrote on 7 Jun 2021, 09:50 last edited by
                          #11

                          @darrenleeleelee1
                          Then OOI how does

                          qimage = qimage.copy(QtCore.QRect(0, 0, 2235, 3408))
                          

                          behave?

                          D 1 Reply Last reply 7 Jun 2021, 12:20
                          0
                          • J JonB
                            7 Jun 2021, 09:50

                            @darrenleeleelee1
                            Then OOI how does

                            qimage = qimage.copy(QtCore.QRect(0, 0, 2235, 3408))
                            

                            behave?

                            D Offline
                            D Offline
                            darrenleeleelee1
                            wrote on 7 Jun 2021, 12:20 last edited by darrenleeleelee1 6 Jul 2021, 12:22
                            #12

                            @JonB It won't crash!But when I change to

                            qimage.copy(0, 0, qimage.width(), qimage.height()) 
                            

                            then it crash.Even I give to other variable first it still not work

                            wt = qimage.width()
                            ht = qimage.height()
                            qimage = qimage.copy(0, 0, wt, ht)
                            
                            J.HilkJ K J 3 Replies Last reply 7 Jun 2021, 12:21
                            0
                            • D darrenleeleelee1
                              7 Jun 2021, 12:20

                              @JonB It won't crash!But when I change to

                              qimage.copy(0, 0, qimage.width(), qimage.height()) 
                              

                              then it crash.Even I give to other variable first it still not work

                              wt = qimage.width()
                              ht = qimage.height()
                              qimage = qimage.copy(0, 0, wt, ht)
                              
                              J.HilkJ Offline
                              J.HilkJ Offline
                              J.Hilk
                              Moderators
                              wrote on 7 Jun 2021, 12:21 last edited by
                              #13

                              @darrenleeleelee1 what about
                              qimage = qimage.copy(QtCore.QRect())


                              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.

                              D 1 Reply Last reply 7 Jun 2021, 12:35
                              0
                              • J.HilkJ J.Hilk
                                7 Jun 2021, 12:21

                                @darrenleeleelee1 what about
                                qimage = qimage.copy(QtCore.QRect())

                                D Offline
                                D Offline
                                darrenleeleelee1
                                wrote on 7 Jun 2021, 12:35 last edited by
                                #14

                                @J-Hilk I try it.But also crash.

                                1 Reply Last reply
                                0
                                • D darrenleeleelee1
                                  7 Jun 2021, 12:20

                                  @JonB It won't crash!But when I change to

                                  qimage.copy(0, 0, qimage.width(), qimage.height()) 
                                  

                                  then it crash.Even I give to other variable first it still not work

                                  wt = qimage.width()
                                  ht = qimage.height()
                                  qimage = qimage.copy(0, 0, wt, ht)
                                  
                                  K Offline
                                  K Offline
                                  KroMignon
                                  wrote on 7 Jun 2021, 12:36 last edited by KroMignon 6 Jul 2021, 12:37
                                  #15

                                  @darrenleeleelee1 said in PyQt QImage cna't copy, crash without error code:

                                  qimage.copy(0, 0, qimage.width(), qimage.height())

                                  then it crash

                                  It looks very strange to me, because when looking for QImage::copy(int x, int y, int w, int h), I found:

                                     inline QImage copy(int x, int y, int w, int h) const
                                          { return copy(QRect(x, y, w, h)); }
                                  
                                  

                                  What if when you change your code to:

                                  qimage = QtGui.QImage(arr, arr.shape[1], arr.shape[0], QtGui.QImage.Format_Grayscale16)
                                  qimageCopy = qimage.copy()
                                  

                                  Does this also crash?

                                  It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                                  1 Reply Last reply
                                  0
                                  • D darrenleeleelee1
                                    7 Jun 2021, 12:20

                                    @JonB It won't crash!But when I change to

                                    qimage.copy(0, 0, qimage.width(), qimage.height()) 
                                    

                                    then it crash.Even I give to other variable first it still not work

                                    wt = qimage.width()
                                    ht = qimage.height()
                                    qimage = qimage.copy(0, 0, wt, ht)
                                    
                                    J Offline
                                    J Offline
                                    JonB
                                    wrote on 7 Jun 2021, 12:53 last edited by JonB 6 Jul 2021, 13:00
                                    #16

                                    @darrenleeleelee1 said in PyQt QImage cna't copy, crash without error code:

                                    @JonB It won't crash!But when I change to
                                    qimage.copy(0, 0, qimage.width(), qimage.height())

                                    then it crash.Even I give to other variable first it still not work
                                    wt = qimage.width()
                                    ht = qimage.height()
                                    qimage = qimage.copy(0, 0, wt, ht)

                                    This all implies that the source qimage you start with is the issue.

                                    Start by looking at exactly what your arr = ds.pixel_array holds/returns. The QImage() constructor you use states "it must remain valid". That looks to me like the danger area. I think when you copy a portion of the image Qt takes a copy of its own. But probably not when you copy the whole thing. For example, are you able to do a Python copy() on it so you have your own separate copy, which you then use for the image? And btw, if you have any threading involved anywhere, please say so......

                                    D 1 Reply Last reply 7 Jun 2021, 13:04
                                    0
                                    • J JonB
                                      7 Jun 2021, 12:53

                                      @darrenleeleelee1 said in PyQt QImage cna't copy, crash without error code:

                                      @JonB It won't crash!But when I change to
                                      qimage.copy(0, 0, qimage.width(), qimage.height())

                                      then it crash.Even I give to other variable first it still not work
                                      wt = qimage.width()
                                      ht = qimage.height()
                                      qimage = qimage.copy(0, 0, wt, ht)

                                      This all implies that the source qimage you start with is the issue.

                                      Start by looking at exactly what your arr = ds.pixel_array holds/returns. The QImage() constructor you use states "it must remain valid". That looks to me like the danger area. I think when you copy a portion of the image Qt takes a copy of its own. But probably not when you copy the whole thing. For example, are you able to do a Python copy() on it so you have your own separate copy, which you then use for the image? And btw, if you have any threading involved anywhere, please say so......

                                      D Offline
                                      D Offline
                                      darrenleeleelee1
                                      wrote on 7 Jun 2021, 13:04 last edited by
                                      #17

                                      @JonB Sorry I am not really get what did you mean.And I think I don't have any threading.(I think..)

                                      J 1 Reply Last reply 7 Jun 2021, 13:10
                                      0
                                      • D darrenleeleelee1
                                        7 Jun 2021, 13:04

                                        @JonB Sorry I am not really get what did you mean.And I think I don't have any threading.(I think..)

                                        J Offline
                                        J Offline
                                        JonB
                                        wrote on 7 Jun 2021, 13:10 last edited by JonB 6 Jul 2021, 13:11
                                        #18

                                        @darrenleeleelee1
                                        I have no idea what is behind your

                                                ds = dcmread('./5F329172_20170623_CR_2_1_1')
                                                arr = ds.pixel_array
                                        

                                        It's some external library stuff. (And btw I have no idea whether arr.shape[1], arr.shape[0] is the right thing to use. Don't bother to explain, just make sure it's correct for whatever this ds stuff is.)

                                        Try this:

                                        import copy
                                        ...
                                                arr = copy.copy(ds.pixel_array)
                                        # or even:
                                        #        arr = copy.deepcopy(ds.pixel_array)
                                        

                                        before you proceed to qimage = QtGui.QImage(arr, ...). Any better, crash-wise?

                                        D 1 Reply Last reply 7 Jun 2021, 13:20
                                        0
                                        • J JonB
                                          7 Jun 2021, 13:10

                                          @darrenleeleelee1
                                          I have no idea what is behind your

                                                  ds = dcmread('./5F329172_20170623_CR_2_1_1')
                                                  arr = ds.pixel_array
                                          

                                          It's some external library stuff. (And btw I have no idea whether arr.shape[1], arr.shape[0] is the right thing to use. Don't bother to explain, just make sure it's correct for whatever this ds stuff is.)

                                          Try this:

                                          import copy
                                          ...
                                                  arr = copy.copy(ds.pixel_array)
                                          # or even:
                                          #        arr = copy.deepcopy(ds.pixel_array)
                                          

                                          before you proceed to qimage = QtGui.QImage(arr, ...). Any better, crash-wise?

                                          D Offline
                                          D Offline
                                          darrenleeleelee1
                                          wrote on 7 Jun 2021, 13:20 last edited by
                                          #19

                                          @JonB 72c6dea2-3187-4f9b-b755-d7939e474ce1-image.png
                                          I add deepcopy,and it also crash. I add some arr attribute for you.
                                          ed678234-91b9-475e-b889-0117c72ec04c-image.png

                                          K 1 Reply Last reply 7 Jun 2021, 13:25
                                          0
                                          • D darrenleeleelee1
                                            7 Jun 2021, 13:20

                                            @JonB 72c6dea2-3187-4f9b-b755-d7939e474ce1-image.png
                                            I add deepcopy,and it also crash. I add some arr attribute for you.
                                            ed678234-91b9-475e-b889-0117c72ec04c-image.png

                                            K Offline
                                            K Offline
                                            KroMignon
                                            wrote on 7 Jun 2021, 13:25 last edited by KroMignon 6 Jul 2021, 13:27
                                            #20

                                            @darrenleeleelee1 I think you should change your code to:

                                            qimage = QtGui.QImage(arr.data, arr.shape[1], arr.shape[0], QtGui.QImage.Format_Grayscale16)
                                            

                                            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                                            D 1 Reply Last reply 7 Jun 2021, 13:36
                                            0

                                            1/27

                                            7 Jun 2021, 04:39

                                            • Login

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