Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. Loading Large Images in Qt
QtWS25 Last Chance

Loading Large Images in Qt

Scheduled Pinned Locked Moved Solved Brainstorm
14 Posts 6 Posters 6.7k 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.
  • Z Offline
    Z Offline
    zed962
    wrote on last edited by
    #1

    Hello,

    I am new to Qt and am looking to load an image of 18806 x 19794 pixels (467MB). My objective is to create a software that could manipulate large images.

    I tried loading the entire image as a QPixmap inside a scene but I got an "Out of memory exception" and the application crashed.

    Is there some kind of function or library for Qt that could handle large images (like tile rendering or something) ? What's the best way of achieving such a task?

    Thanks

    raven-worxR K 2 Replies Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome
      That is pretty massive image so you will need 64 bit machine ( for really huge)
      and you need a library to help with it.

      This i never tested myself but heard it loads huge files easy.
      http://www.vips.ecs.soton.ac.uk/index.php?title=Libvips#Main_features

      It says it can manipulated 10 GB image on 32 bit :)

      Z 1 Reply Last reply
      2
      • Z zed962

        Hello,

        I am new to Qt and am looking to load an image of 18806 x 19794 pixels (467MB). My objective is to create a software that could manipulate large images.

        I tried loading the entire image as a QPixmap inside a scene but I got an "Out of memory exception" and the application crashed.

        Is there some kind of function or library for Qt that could handle large images (like tile rendering or something) ? What's the best way of achieving such a task?

        Thanks

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #3

        @zed962 said in Loading Large Images in Qt:

        Is there some kind of function or library for Qt that could handle large images (like tile rendering or something) ? What's the best way of achieving such a task?

        Loading the whole image inside a QPixmap (= into memory) is completely overkill and also you probably wouldn't need 99% of the data.
        As you already mentioned you might only work on parts of the image currently needed. Such a heavy image-related task goes beyond the purpose of Qt.

        But if you can with basic support you may want to try QImageReader class. It's capable of reading the image-size and retrieve parts of the image (tiling) by specifying cliprect. But it heavily depends on the image format. Read this.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        Z 2 Replies Last reply
        4
        • raven-worxR raven-worx

          @zed962 said in Loading Large Images in Qt:

          Is there some kind of function or library for Qt that could handle large images (like tile rendering or something) ? What's the best way of achieving such a task?

          Loading the whole image inside a QPixmap (= into memory) is completely overkill and also you probably wouldn't need 99% of the data.
          As you already mentioned you might only work on parts of the image currently needed. Such a heavy image-related task goes beyond the purpose of Qt.

          But if you can with basic support you may want to try QImageReader class. It's capable of reading the image-size and retrieve parts of the image (tiling) by specifying cliprect. But it heavily depends on the image format. Read this.

          Z Offline
          Z Offline
          zed962
          wrote on last edited by
          #4

          @raven-worx Many thanks for the suggestion! I ended up creating my own tiling process for large images (Reading the image, dissecting it to multiple tiles and loading tiles accordingly). Gonna try QImageReader as it looks promising.

          B 1 Reply Last reply
          1
          • raven-worxR raven-worx

            @zed962 said in Loading Large Images in Qt:

            Is there some kind of function or library for Qt that could handle large images (like tile rendering or something) ? What's the best way of achieving such a task?

            Loading the whole image inside a QPixmap (= into memory) is completely overkill and also you probably wouldn't need 99% of the data.
            As you already mentioned you might only work on parts of the image currently needed. Such a heavy image-related task goes beyond the purpose of Qt.

            But if you can with basic support you may want to try QImageReader class. It's capable of reading the image-size and retrieve parts of the image (tiling) by specifying cliprect. But it heavily depends on the image format. Read this.

            Z Offline
            Z Offline
            zed962
            wrote on last edited by
            #5

            @raven-worx QImageReader didn't work for me when it comes to that size of image. I tried it with smaller images and it worked. I think I'll upgrade my machine to 64-bit to support more RAMs on my laptop.

            K 1 Reply Last reply
            1
            • mrjjM mrjj

              Hi and welcome
              That is pretty massive image so you will need 64 bit machine ( for really huge)
              and you need a library to help with it.

              This i never tested myself but heard it loads huge files easy.
              http://www.vips.ecs.soton.ac.uk/index.php?title=Libvips#Main_features

              It says it can manipulated 10 GB image on 32 bit :)

              Z Offline
              Z Offline
              zed962
              wrote on last edited by
              #6

              @mrjj Thanks for your reply. I'm going to try it and get back to you.

              1 Reply Last reply
              0
              • Z zed962

                @raven-worx QImageReader didn't work for me when it comes to that size of image. I tried it with smaller images and it worked. I think I'll upgrade my machine to 64-bit to support more RAMs on my laptop.

                K Offline
                K Offline
                Konstantin Tokarev
                wrote on last edited by
                #7

                @zed962 If your image is JPEG, QImageReader should work if you use QImageReader::setScaledSize and/or QImageReader::setScaledClipRect

                For PNG scaled size may not work, though clip rect should. This doesn't mean that huge PNG cannot be loaded with on the fly scaling, the most trivial version of this algorithm is to keep only selected pixels from each line. You can implement it with direct use of libpng, but it will lead to visual artifacts ("moire"). Maybe there is more clever ready to use algorithm somewhere though, but not in Qt

                1 Reply Last reply
                0
                • Z zed962

                  Hello,

                  I am new to Qt and am looking to load an image of 18806 x 19794 pixels (467MB). My objective is to create a software that could manipulate large images.

                  I tried loading the entire image as a QPixmap inside a scene but I got an "Out of memory exception" and the application crashed.

                  Is there some kind of function or library for Qt that could handle large images (like tile rendering or something) ? What's the best way of achieving such a task?

                  Thanks

                  K Offline
                  K Offline
                  Konstantin Tokarev
                  wrote on last edited by
                  #8

                  @zed962 BTW if you are working with so large images it might be better to use more scalable image format, like JPEG2000, where you can encode low-resolution overview and tiled high-resolution image in the same file without data duplication, and decode them separately. But Qt won't help you with it, it doesn't even support OpenJPEG

                  raven-worxR Z 2 Replies Last reply
                  0
                  • K Konstantin Tokarev

                    @zed962 BTW if you are working with so large images it might be better to use more scalable image format, like JPEG2000, where you can encode low-resolution overview and tiled high-resolution image in the same file without data duplication, and decode them separately. But Qt won't help you with it, it doesn't even support OpenJPEG

                    raven-worxR Offline
                    raven-worxR Offline
                    raven-worx
                    Moderators
                    wrote on last edited by
                    #9

                    @Konstantin-Tokarev said in Loading Large Images in Qt:

                    But Qt won't help you with it, it doesn't even support OpenJPEG

                    There is a Jpeg2000 imageformat plugin available (it used Jasper lib though)

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    K 1 Reply Last reply
                    0
                    • raven-worxR raven-worx

                      @Konstantin-Tokarev said in Loading Large Images in Qt:

                      But Qt won't help you with it, it doesn't even support OpenJPEG

                      There is a Jpeg2000 imageformat plugin available (it used Jasper lib though)

                      K Offline
                      K Offline
                      Konstantin Tokarev
                      wrote on last edited by Konstantin Tokarev
                      #10

                      @raven-worx Jasper is dead and supports only subset of J2K format

                      1 Reply Last reply
                      0
                      • K Konstantin Tokarev

                        @zed962 BTW if you are working with so large images it might be better to use more scalable image format, like JPEG2000, where you can encode low-resolution overview and tiled high-resolution image in the same file without data duplication, and decode them separately. But Qt won't help you with it, it doesn't even support OpenJPEG

                        Z Offline
                        Z Offline
                        zed962
                        wrote on last edited by
                        #11

                        @Konstantin-Tokarev My image is GeoTIFF (mainly a satellite image)

                        K 1 Reply Last reply
                        0
                        • Z zed962

                          @Konstantin-Tokarev My image is GeoTIFF (mainly a satellite image)

                          K Offline
                          K Offline
                          Konstantin Tokarev
                          wrote on last edited by
                          #12

                          @zed962 TIFF is horribly inefficient, and J2K should work nice for your case (even in lossy mode, I read somewhere that it is used for space photos because it never creates high-frequency artifacts)

                          1 Reply Last reply
                          0
                          • Z zed962

                            @raven-worx Many thanks for the suggestion! I ended up creating my own tiling process for large images (Reading the image, dissecting it to multiple tiles and loading tiles accordingly). Gonna try QImageReader as it looks promising.

                            B Offline
                            B Offline
                            BinuJanardhanan
                            wrote on last edited by
                            #13

                            @zed962 could you please help me to creating my own tiling process for large images (Reading the image, dissecting it to multiple tiles and loading tiles accordingly).

                            I am thankful to you.

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              Anastasia Stefanuk
                              Banned
                              wrote on last edited by
                              #14
                              This post is deleted!
                              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 Extensions
                              • Unsolved