Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Matching 2 .tiff images pixel-by-pixel
Qt 6.12 LTS is out! See what's new in the release blog

Matching 2 .tiff images pixel-by-pixel

Scheduled Pinned Locked Moved Solved General and Desktop
55 Posts 5 Posters 43.7k Views 2 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.
  • J Offline
    J Offline
    john_hobbyist
    wrote on last edited by
    #3
    This post is deleted!
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #4

      Check with the tifffile project.

      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
      1
      • J Offline
        J Offline
        john_hobbyist
        wrote on last edited by
        #5

        I don't know if I need to open a new thread, but in the .tif image I open, how to I specify with a rectangle the area I want to process? I do not want to put the rectangle a priori, but in "real time" as I examine the image and to help my code do process on the specific space bounded by the rectangle....

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #6

          QRubberBand comes to mind.

          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
          • J Offline
            J Offline
            john_hobbyist
            wrote on last edited by
            #7
            This post is deleted!
            1 Reply Last reply
            0
            • J Offline
              J Offline
              john_hobbyist
              wrote on last edited by
              #8

              I use this code: https://stackoverflow.com/questions/13840289/how-to-use-qrubberband-with-qrect-class-in-pyqt
              inside my widget, more specifically, this code:

              def mousePressEvent(self, event):
                  self.origin = event.pos()
                  self.rubberband.setGeometry(
                      QtCore.QRect(self.origin, QtCore.QSize()))
                  self.rubberband.show()
                  QtGui.QWidget.mousePressEvent(self, event)
              
              def mouseMoveEvent(self, event):
                  if self.rubberband.isVisible():
                      self.rubberband.setGeometry(
                          QtCore.QRect(self.origin, event.pos()).normalized())
                  QtGui.QWidget.mouseMoveEvent(self, event)
              
              def mouseReleaseEvent(self, event):
                  if self.rubberband.isVisible():
                      self.rubberband.hide()
                      selected = []
                      rect = self.rubberband.geometry()
                      for child in self.findChildren(QtGui.QPushButton):
                          if rect.intersects(child.geometry()):
                              selected.append(child)
                      print 'Selection Contains:\n ',
                      if selected:
                          print '  '.join(
                              'Button: %s\n' % child.text() for child in selected)
                      else:
                          print ' Nothing\n'
                  QtGui.QWidget.mouseReleaseEvent(self, event)
              

              but I don't see any rectangle...

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #9

                Are you sure your methods are called ?

                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
                • J Offline
                  J Offline
                  john_hobbyist
                  wrote on last edited by
                  #10

                  I use these method calls:

                      self.mousePressEvent()
                      self.mouseMoveEvent()
                      self.mouseReleaseEvent()
                  

                  inside the main widget class..but what do I put inside the parenthesis? Because "event" does not seem to work...

                  JonBJ 1 Reply Last reply
                  0
                  • J john_hobbyist

                    I use these method calls:

                        self.mousePressEvent()
                        self.mouseMoveEvent()
                        self.mouseReleaseEvent()
                    

                    inside the main widget class..but what do I put inside the parenthesis? Because "event" does not seem to work...

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #11

                    @john_hobbyist
                    What do you mean by "I use these method calls"? These methods are supposed to be overrides. Qt infrastructure calls them when it detects the mouse event, with the appropriate event parameter.

                    And anyway @SGaist was asking you put a debugging print() statement inside these override methods to make sure they are getting called.

                    1 Reply Last reply
                    2
                    • J Offline
                      J Offline
                      john_hobbyist
                      wrote on last edited by john_hobbyist
                      #12

                      I am trying some ready examples in order to understand the rationale. I run the first code from here: https://stackoverflow.com/questions/34220275/how-to-select-a-region-with-qrubberband-on-a-qlabel-like-in-ksnapshot

                      I have changed PyQt4 ---> PyQt5 and QtGui ----> QtWidgets. I also changed this line:

                      pixmap = QPixmap.grabWindow(app.desktop().winId())
                      

                      with this:

                      pixmap = QScreen.grabWindow(app.desktop().winId())
                      

                      but I get this error:

                      File "QRubberBandonaQLabelKSnapshot.py", line 47, in initUI
                          pixmap = QScreen.grabWindow(app.desktop().winId())
                      TypeError: grabWindow(self, sip.voidptr, x: int = 0, y: int = 0, width: int = -1, height: int = -1): first argument of unbound method must have type 'QScreen'
                      

                      Any idea what to do here?

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        You're using it as if it were a static method which it's not. You need an instance of QScreen.

                        You can get one from your QApplication.

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

                        J 1 Reply Last reply
                        1
                        • SGaistS SGaist

                          You're using it as if it were a static method which it's not. You need an instance of QScreen.

                          You can get one from your QApplication.

                          J Offline
                          J Offline
                          john_hobbyist
                          wrote on last edited by john_hobbyist
                          #14

                          @SGaist Sorry I do not understand...how I get an instance from QApplication in QScreen?

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #15

                            It's the other way around.

                            In any case, you should rather get the screen from your widget.

                            Take a look at the screenshot example.

                            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
                            • J Offline
                              J Offline
                              john_hobbyist
                              wrote on last edited by john_hobbyist
                              #16

                              @SGaist

                              I just try to see how to run the QRubberBand in PyQt5....

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #17

                                Did you check the example from the class documentation ?

                                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
                                1
                                • J Offline
                                  J Offline
                                  john_hobbyist
                                  wrote on last edited by john_hobbyist
                                  #18

                                  I added them to the main class. I am trying to call the methods, like this:

                                  self.mousePressEvent(event)
                                  self.mouseMoveEvent(event)
                                  

                                  etc.

                                  But what do I put inside/instead of "event"?

                                  mrjjM 1 Reply Last reply
                                  0
                                  • J john_hobbyist

                                    I added them to the main class. I am trying to call the methods, like this:

                                    self.mousePressEvent(event)
                                    self.mouseMoveEvent(event)
                                    

                                    etc.

                                    But what do I put inside/instead of "event"?

                                    mrjjM Offline
                                    mrjjM Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on last edited by mrjj
                                    #19

                                    @john_hobbyist

                                    The code you showed higher up to drive the rubber band.
                                    Or the docs @SGaist points to. they explain in detail what is needed.

                                    def mousePressEvent(self, event):   ///// this set the start location of the band
                                        self.origin = event.pos()
                                        self.rubberband.setGeometry(
                                            QtCore.QRect(self.origin, QtCore.QSize()))
                                        self.rubberband.show()
                                        QtGui.QWidget.mousePressEvent(self, event)
                                    
                                    def mouseMoveEvent(self, event): // this makes the band follow the mouse to adjust the size
                                        if self.rubberband.isVisible():
                                            self.rubberband.setGeometry(
                                                QtCore.QRect(self.origin, event.pos()).normalized())
                                        QtGui.QWidget.mouseMoveEvent(self, event)
                                    
                                    def mouseReleaseEvent(self, event): // this is the end of the operation and you use the rectange defined by the band
                                        if self.rubberband.isVisible():
                                            self.rubberband.hide()
                                       rect = self.rubberband.geometry()
                                    
                                     ... then use rect for whatever you need
                                    
                                    1 Reply Last reply
                                    2
                                    • J Offline
                                      J Offline
                                      john_hobbyist
                                      wrote on last edited by john_hobbyist
                                      #20

                                      @mrjj: Thanks for your help! I am searching all morning. Here https://doc.qt.io/qtforpython/PySide6/QtWidgets/QRubberBand.html#more I don't see something about what to put inside the "event". The only I can understand is to use this inside events: https://doc.qt.io/qtforpython-5/PySide2/QtGui/QMouseEvent.html

                                      mrjjM 1 Reply Last reply
                                      0
                                      • J john_hobbyist

                                        @mrjj: Thanks for your help! I am searching all morning. Here https://doc.qt.io/qtforpython/PySide6/QtWidgets/QRubberBand.html#more I don't see something about what to put inside the "event". The only I can understand is to use this inside events: https://doc.qt.io/qtforpython-5/PySide2/QtGui/QMouseEvent.html

                                        mrjjM Offline
                                        mrjjM Offline
                                        mrjj
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #21

                                        @john_hobbyist

                                        Im not sure what you refer too ?

                                        def mouseReleaseEvent(self, event): <<< this event ? the paramter ?

                                        To use the rubberband, we use 3 functions as shown.

                                        1 Reply Last reply
                                        1
                                        • J Offline
                                          J Offline
                                          john_hobbyist
                                          wrote on last edited by john_hobbyist
                                          #22

                                          @mrjj
                                          Yes, I try this:

                                          self.mousePressEvent(event)
                                          

                                          and the code requires to put something instead of "event". This is the error:

                                          File "code.py", line 310, in __init__
                                            self.mousePressEvent(event)
                                          NameError: name 'event' is not defined
                                          
                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt
                                          • Unsolved