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. Opening .tiff geoimages consumes enormous memory

Opening .tiff geoimages consumes enormous memory

Scheduled Pinned Locked Moved Solved General and Desktop
40 Posts 5 Posters 4.3k 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.
  • G Offline
    G Offline
    gde23
    wrote on 24 Dec 2020, 19:09 last edited by
    #4

    You're right. Didn't think about that.
    What size (in pixels) does the image have and what datatype do you load it to?
    Then you can easily calculate what size (in memory) it should have as a openCV mat object and if the image should fit into your PCs memory.

    1 Reply Last reply
    3
    • J Offline
      J Offline
      john_hobbyist
      wrote on 24 Dec 2020, 19:13 last edited by john_hobbyist
      #5

      5000 x 7000 pixels. I use opencv.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 24 Dec 2020, 19:14 last edited by mrjj
        #6

        Hi
        A 500 MB tiff is massive if high compression is used.
        Unless you have 32+ GB ram, it might not be possible to open it.

        The alternative is to load it in chunks
        https://wiki.qt.io/Loading_Large_Images

        But depending on what you need to do with it, it might not be a solution.
        Also I have not tested this with the TIFF format.

        Ah, never mind. you want use openCV to load the image.

        update:
        You might want to check out
        https://github.com/pearu/pylibtiff
        it's a python wrapper for libtiff which is supports tiles (chunks) directly.
        So you might be able to load it via this and us openCV to display.
        https://answers.opencv.org/question/86621/reading-geo-tiff/#86740

        1 Reply Last reply
        3
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 24 Dec 2020, 20:22 last edited by
          #7

          Hi,

          One thing to take into account: to represent a compressed image in a format like RGB, you will have to decompress it. You are mixing storage and usage. Depending on what you need from that image, you may have a thumbnail already embedded into it. In any case, you really should analyse what you need to do with that image and then adapt your code for that. Like suggested by my fellows there are tools to deal with these kind of data.

          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 28 Dec 2020, 19:28 last edited by john_hobbyist
            #8

            I am trying opening the tiff with this command:

            QImageReader reader("/home/UbuntuUser/Desktop/UAV.tif");
            print(reader)
            

            but something is wrong... Any idea?

            update:

            File "code.py", line 547
                QImageReader reader("/home/UbuntuUser/Desktop/UAV.tif");
                             ^
            SyntaxError: invalid syntax
            
            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 28 Dec 2020, 19:29 last edited by
              #9

              What does "but something is wrong" mean ?

              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
              • M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 28 Dec 2020, 20:05 last edited by
                #10

                Hi
                That looks like c++ syntax but you are using python, right ?
                So is it not like
                r = QImageReader("/home/UbuntuUser/Desktop/UAV.tif")

                1 Reply Last reply
                3
                • J Offline
                  J Offline
                  john_hobbyist
                  wrote on 28 Dec 2020, 23:00 last edited by john_hobbyist
                  #11
                  This post is deleted!
                  M 1 Reply Last reply 29 Dec 2020, 08:59
                  0
                  • J john_hobbyist
                    28 Dec 2020, 23:00

                    This post is deleted!

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 29 Dec 2020, 08:59 last edited by
                    #12

                    @john_hobbyist

                    Hi
                    Why this old version ?

                    Anyway, what are you trying ?

                    Building PyQT4 from source ?

                    Also is there any reason you want to use the competing Qt binding from another company instead of the
                    official support one called pyside2 ?
                    https://pypi.org/project/PySide2/
                    https://doc.qt.io/qtforpython/

                    1 Reply Last reply
                    2
                    • J Offline
                      J Offline
                      john_hobbyist
                      wrote on 29 Dec 2020, 09:14 last edited by john_hobbyist
                      #13

                      @mrjj

                      I don't know what goes wrong...

                      I just try to handle large tiff images instead of using opencv (that makes my program realy slow) with QTimagereader

                      Sorry, I didn't identify it was a competing company...just a result in google when tried to install PyQt4

                      Ok, I will look at it.

                      M 1 Reply Last reply 29 Dec 2020, 09:38
                      0
                      • J john_hobbyist
                        29 Dec 2020, 09:14

                        @mrjj

                        I don't know what goes wrong...

                        I just try to handle large tiff images instead of using opencv (that makes my program realy slow) with QTimagereader

                        Sorry, I didn't identify it was a competing company...just a result in google when tried to install PyQt4

                        Ok, I will look at it.

                        M Offline
                        M Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 29 Dec 2020, 09:38 last edited by mrjj
                        #14

                        @john_hobbyist
                        Hi
                        Np I just wondered why you want Qt4 version and build from the source when
                        PyQt5 is there and seems to be installable directly.
                        Also here is how to use it
                        https://programtalk.com/python-examples/PyQt5.Qt.QImageReader/
                        Do note none of them use setClipRect to load image in chunks but
                        should be easy to add.

                        1 Reply Last reply
                        1
                        • C Offline
                          C Offline
                          Christian Ehrlicher
                          Lifetime Qt Champion
                          wrote on 29 Dec 2020, 11:07 last edited by
                          #15

                          QtImagrReader is for sure not the correct way to handle geotiff. Either use openCV or better gdal for such tasks.

                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                          Visit the Qt Academy at https://academy.qt.io/catalog

                          J 1 Reply Last reply 30 Dec 2020, 15:35
                          2
                          • C Christian Ehrlicher
                            29 Dec 2020, 11:07

                            QtImagrReader is for sure not the correct way to handle geotiff. Either use openCV or better gdal for such tasks.

                            J Offline
                            J Offline
                            john_hobbyist
                            wrote on 30 Dec 2020, 15:35 last edited by
                            #16

                            @Christian-Ehrlicher

                            I am trying GDAL in order to print the image:

                            from osgeo import gdal
                            import sys
                            
                            ds = gdal.Open('UAV_image.tif')
                            print(ds)
                            

                            and I get this error:

                            <osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *' at 0x7fb89062b840> >
                            

                            Any idea what I am missing here?

                            1 Reply Last reply
                            0
                            • C Offline
                              C Offline
                              Christian Ehrlicher
                              Lifetime Qt Champion
                              wrote on 30 Dec 2020, 16:25 last edited by
                              #17

                              @john_hobbyist said in Opening .tiff geoimages consumes enormous memory:

                              Any idea what I am missing here?

                              Nothing. All is fine.

                              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                              Visit the Qt Academy at https://academy.qt.io/catalog

                              1 Reply Last reply
                              2
                              • J Offline
                                J Offline
                                john_hobbyist
                                wrote on 30 Dec 2020, 16:27 last edited by
                                #18

                                Why I cannot see the image?

                                1 Reply Last reply
                                0
                                • S Offline
                                  S Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on 30 Dec 2020, 16:29 last edited by
                                  #19

                                  The Python print function only print strings or a string representation of the object.

                                  Check if GDAL provides a widget or equivalent for that.

                                  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 30 Dec 2020, 16:46 last edited by john_hobbyist
                                    #20

                                    Ok, until now OpenCV requires ~24GB RAM, gdal does not work. Is there any QImageReader sample code to open the .tif? I am searching the google for this...nothing found.

                                    M C 2 Replies Last reply 30 Dec 2020, 17:03
                                    0
                                    • J john_hobbyist
                                      30 Dec 2020, 16:46

                                      Ok, until now OpenCV requires ~24GB RAM, gdal does not work. Is there any QImageReader sample code to open the .tif? I am searching the google for this...nothing found.

                                      M Offline
                                      M Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on 30 Dec 2020, 17:03 last edited by
                                      #21

                                      @john_hobbyist
                                      Hi
                                      in what way did GDAL not work ?

                                      Also, Mr @Christian-Ehrlicher made me realize that geotiff is a special tiff so
                                      even QImageReader can read an image in sections. it might not really do what you want.

                                      What do you need to do to this image ?

                                      1 Reply Last reply
                                      1
                                      • J john_hobbyist
                                        30 Dec 2020, 16:46

                                        Ok, until now OpenCV requires ~24GB RAM, gdal does not work. Is there any QImageReader sample code to open the .tif? I am searching the google for this...nothing found.

                                        C Offline
                                        C Offline
                                        Christian Ehrlicher
                                        Lifetime Qt Champion
                                        wrote on 30 Dec 2020, 17:05 last edited by
                                        #22

                                        @john_hobbyist I wonder what you want to do with this image when you even don't know the basics of this format... it's a georeferenced image with multiple images and bands inside. It's not a simple picture at all.

                                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                        Visit the Qt Academy at https://academy.qt.io/catalog

                                        1 Reply Last reply
                                        4
                                        • J Offline
                                          J Offline
                                          john_hobbyist
                                          wrote on 30 Dec 2020, 17:15 last edited by john_hobbyist
                                          #23

                                          @mrjj and @Christian-Ehrlicher:

                                          I want to open it and do some zooming with code I use. Also I want to read the coordinates from the image (I do not how, but I am searching it)

                                          M 1 Reply Last reply 30 Dec 2020, 17:29
                                          0

                                          13/40

                                          29 Dec 2020, 09:14

                                          topic:navigator.unread, 27
                                          • Login

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