libvips extract area of NDPI from Ex40 not from map












0















I am using libvips to get pyramids of .ndpi images.



through this answer and searching the documentation I found this command



vips extract_area myimage.ndpi[level=0] mypyramid.dz 0 0 10000 10000


Which extracts a crop starting at 0 0 and size 10000 10000 to a dzi file.



The level parameter is the magnification, 0 is the highest.



The problem is that the ndpi has the following images inside:




  • myimage_macro.tif

  • myimage_map.tif

  • myimage_x0.15625_z0.tif

  • myimage_x0.625_z0.tif

  • myimage_x10_z0.tif

  • myimage_x2.5_z0.tif

  • myimage_x40_z0.tif


And vips is taking myimage_macro.tif while I need myimage_x40_z0.tif



There should be a parameter like level to choose which from the images inside the OpenSlide (ndpi) I want.



Some people ask. Why not extracting the tif and then running vips?



Well, because vips tells me this:



openslide2vips: opening slide: No such value: directory 0, tag 278


Which means that using ndpisplit to extract the tif is somehow not saving the metadata to allow vips to recognize the image



So I am in a bit of a pesky situation. I have enormous images and I need to extract a slightly less enourmous piece and then have its pyramid.



Please help me, right now I am basically coding it all my self and it works but it is EXTREMELY slow.










share|improve this question



























    0















    I am using libvips to get pyramids of .ndpi images.



    through this answer and searching the documentation I found this command



    vips extract_area myimage.ndpi[level=0] mypyramid.dz 0 0 10000 10000


    Which extracts a crop starting at 0 0 and size 10000 10000 to a dzi file.



    The level parameter is the magnification, 0 is the highest.



    The problem is that the ndpi has the following images inside:




    • myimage_macro.tif

    • myimage_map.tif

    • myimage_x0.15625_z0.tif

    • myimage_x0.625_z0.tif

    • myimage_x10_z0.tif

    • myimage_x2.5_z0.tif

    • myimage_x40_z0.tif


    And vips is taking myimage_macro.tif while I need myimage_x40_z0.tif



    There should be a parameter like level to choose which from the images inside the OpenSlide (ndpi) I want.



    Some people ask. Why not extracting the tif and then running vips?



    Well, because vips tells me this:



    openslide2vips: opening slide: No such value: directory 0, tag 278


    Which means that using ndpisplit to extract the tif is somehow not saving the metadata to allow vips to recognize the image



    So I am in a bit of a pesky situation. I have enormous images and I need to extract a slightly less enourmous piece and then have its pyramid.



    Please help me, right now I am basically coding it all my self and it works but it is EXTREMELY slow.










    share|improve this question

























      0












      0








      0








      I am using libvips to get pyramids of .ndpi images.



      through this answer and searching the documentation I found this command



      vips extract_area myimage.ndpi[level=0] mypyramid.dz 0 0 10000 10000


      Which extracts a crop starting at 0 0 and size 10000 10000 to a dzi file.



      The level parameter is the magnification, 0 is the highest.



      The problem is that the ndpi has the following images inside:




      • myimage_macro.tif

      • myimage_map.tif

      • myimage_x0.15625_z0.tif

      • myimage_x0.625_z0.tif

      • myimage_x10_z0.tif

      • myimage_x2.5_z0.tif

      • myimage_x40_z0.tif


      And vips is taking myimage_macro.tif while I need myimage_x40_z0.tif



      There should be a parameter like level to choose which from the images inside the OpenSlide (ndpi) I want.



      Some people ask. Why not extracting the tif and then running vips?



      Well, because vips tells me this:



      openslide2vips: opening slide: No such value: directory 0, tag 278


      Which means that using ndpisplit to extract the tif is somehow not saving the metadata to allow vips to recognize the image



      So I am in a bit of a pesky situation. I have enormous images and I need to extract a slightly less enourmous piece and then have its pyramid.



      Please help me, right now I am basically coding it all my self and it works but it is EXTREMELY slow.










      share|improve this question














      I am using libvips to get pyramids of .ndpi images.



      through this answer and searching the documentation I found this command



      vips extract_area myimage.ndpi[level=0] mypyramid.dz 0 0 10000 10000


      Which extracts a crop starting at 0 0 and size 10000 10000 to a dzi file.



      The level parameter is the magnification, 0 is the highest.



      The problem is that the ndpi has the following images inside:




      • myimage_macro.tif

      • myimage_map.tif

      • myimage_x0.15625_z0.tif

      • myimage_x0.625_z0.tif

      • myimage_x10_z0.tif

      • myimage_x2.5_z0.tif

      • myimage_x40_z0.tif


      And vips is taking myimage_macro.tif while I need myimage_x40_z0.tif



      There should be a parameter like level to choose which from the images inside the OpenSlide (ndpi) I want.



      Some people ask. Why not extracting the tif and then running vips?



      Well, because vips tells me this:



      openslide2vips: opening slide: No such value: directory 0, tag 278


      Which means that using ndpisplit to extract the tif is somehow not saving the metadata to allow vips to recognize the image



      So I am in a bit of a pesky situation. I have enormous images and I need to extract a slightly less enourmous piece and then have its pyramid.



      Please help me, right now I am basically coding it all my self and it works but it is EXTREMELY slow.







      image image-processing tiff medical vips






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 21:40









      Zloy SmiertniyZloy Smiertniy

      1,60152541




      1,60152541
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I've written this as an answer, though it's not really an answer. It seemed too long as just a comment.



          The libvips openslideload operation lets you pick an associated image to load. You can get a list of the associated images from the slide-associated-images metadata tag. For example:



          $ vipsheader -f slide-associated-images 2013_09_20_29.ndpi 
          macro
          $ vipsheader -f slide-associated-images CMU-1.svs
          label, macro, thumbnail


          You then pick out an associated image with perhaps:



          $ vips crop CMU-1.svs[associated=label] x.jpg 10 10 100 100


          To get a small part of the label.



          So ... check what associated images openslide reports for your slide. If you can get the one you need, pick that with the associated parameter. If the image you need is not listed, I would contact the openslide project, since they will need to add support.



          You could also check the openslide command-line tools, they might perhaps offer more options.






          share|improve this answer
























          • Oh that looks fantastic, it was the "associated" keyword I was looking for. I will try it. In the meantime I already did a python script to do this for me but my DZI looks a bit weird in the smaller resolutions haha

            – Zloy Smiertniy
            Nov 22 '18 at 10:34











          • Oh no, sadly it didn't work. I tried vipsheader myimage.ndpi myimage.ndpi: 226176x90880 uchar, 4 bands, rgb, openslideload and vipsheader -f slide-associated-images : macro then I did vips crop myimage.ndpi[associated=macro] macrofromheader.dz 0 0 10000 10000 and it says extract_area: bad extract area

            – Zloy Smiertniy
            Nov 22 '18 at 10:38













          • Also for crop since crop is an alias of extract_area.

            – Zloy Smiertniy
            Nov 22 '18 at 10:41











          • Ok so now something worked and I am at a loss why but it is good. Thank you for helping me out! What I finally ran was vips extract_area myimage.ndpi[level=0] mypyramid.dz[tile-size=1024] 0 0 20000 20000 (which was the same from my question), but now it loads the colors properly. The only difference is the tile-size property for the dzi. I wonder if it is a bug because at first it only gave me a weird greyscale image.

            – Zloy Smiertniy
            Nov 22 '18 at 10:59













          • Oh huh how strange. level=0 is the default, you shouldn't need that. If you can find a smallish image which shows the problem, please open an issue on the libvips bug tracker github.com/libvips/libvips/issues/new

            – jcupitt
            Nov 22 '18 at 11:45











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420846%2flibvips-extract-area-of-ndpi-from-ex40-not-from-map%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I've written this as an answer, though it's not really an answer. It seemed too long as just a comment.



          The libvips openslideload operation lets you pick an associated image to load. You can get a list of the associated images from the slide-associated-images metadata tag. For example:



          $ vipsheader -f slide-associated-images 2013_09_20_29.ndpi 
          macro
          $ vipsheader -f slide-associated-images CMU-1.svs
          label, macro, thumbnail


          You then pick out an associated image with perhaps:



          $ vips crop CMU-1.svs[associated=label] x.jpg 10 10 100 100


          To get a small part of the label.



          So ... check what associated images openslide reports for your slide. If you can get the one you need, pick that with the associated parameter. If the image you need is not listed, I would contact the openslide project, since they will need to add support.



          You could also check the openslide command-line tools, they might perhaps offer more options.






          share|improve this answer
























          • Oh that looks fantastic, it was the "associated" keyword I was looking for. I will try it. In the meantime I already did a python script to do this for me but my DZI looks a bit weird in the smaller resolutions haha

            – Zloy Smiertniy
            Nov 22 '18 at 10:34











          • Oh no, sadly it didn't work. I tried vipsheader myimage.ndpi myimage.ndpi: 226176x90880 uchar, 4 bands, rgb, openslideload and vipsheader -f slide-associated-images : macro then I did vips crop myimage.ndpi[associated=macro] macrofromheader.dz 0 0 10000 10000 and it says extract_area: bad extract area

            – Zloy Smiertniy
            Nov 22 '18 at 10:38













          • Also for crop since crop is an alias of extract_area.

            – Zloy Smiertniy
            Nov 22 '18 at 10:41











          • Ok so now something worked and I am at a loss why but it is good. Thank you for helping me out! What I finally ran was vips extract_area myimage.ndpi[level=0] mypyramid.dz[tile-size=1024] 0 0 20000 20000 (which was the same from my question), but now it loads the colors properly. The only difference is the tile-size property for the dzi. I wonder if it is a bug because at first it only gave me a weird greyscale image.

            – Zloy Smiertniy
            Nov 22 '18 at 10:59













          • Oh huh how strange. level=0 is the default, you shouldn't need that. If you can find a smallish image which shows the problem, please open an issue on the libvips bug tracker github.com/libvips/libvips/issues/new

            – jcupitt
            Nov 22 '18 at 11:45
















          0














          I've written this as an answer, though it's not really an answer. It seemed too long as just a comment.



          The libvips openslideload operation lets you pick an associated image to load. You can get a list of the associated images from the slide-associated-images metadata tag. For example:



          $ vipsheader -f slide-associated-images 2013_09_20_29.ndpi 
          macro
          $ vipsheader -f slide-associated-images CMU-1.svs
          label, macro, thumbnail


          You then pick out an associated image with perhaps:



          $ vips crop CMU-1.svs[associated=label] x.jpg 10 10 100 100


          To get a small part of the label.



          So ... check what associated images openslide reports for your slide. If you can get the one you need, pick that with the associated parameter. If the image you need is not listed, I would contact the openslide project, since they will need to add support.



          You could also check the openslide command-line tools, they might perhaps offer more options.






          share|improve this answer
























          • Oh that looks fantastic, it was the "associated" keyword I was looking for. I will try it. In the meantime I already did a python script to do this for me but my DZI looks a bit weird in the smaller resolutions haha

            – Zloy Smiertniy
            Nov 22 '18 at 10:34











          • Oh no, sadly it didn't work. I tried vipsheader myimage.ndpi myimage.ndpi: 226176x90880 uchar, 4 bands, rgb, openslideload and vipsheader -f slide-associated-images : macro then I did vips crop myimage.ndpi[associated=macro] macrofromheader.dz 0 0 10000 10000 and it says extract_area: bad extract area

            – Zloy Smiertniy
            Nov 22 '18 at 10:38













          • Also for crop since crop is an alias of extract_area.

            – Zloy Smiertniy
            Nov 22 '18 at 10:41











          • Ok so now something worked and I am at a loss why but it is good. Thank you for helping me out! What I finally ran was vips extract_area myimage.ndpi[level=0] mypyramid.dz[tile-size=1024] 0 0 20000 20000 (which was the same from my question), but now it loads the colors properly. The only difference is the tile-size property for the dzi. I wonder if it is a bug because at first it only gave me a weird greyscale image.

            – Zloy Smiertniy
            Nov 22 '18 at 10:59













          • Oh huh how strange. level=0 is the default, you shouldn't need that. If you can find a smallish image which shows the problem, please open an issue on the libvips bug tracker github.com/libvips/libvips/issues/new

            – jcupitt
            Nov 22 '18 at 11:45














          0












          0








          0







          I've written this as an answer, though it's not really an answer. It seemed too long as just a comment.



          The libvips openslideload operation lets you pick an associated image to load. You can get a list of the associated images from the slide-associated-images metadata tag. For example:



          $ vipsheader -f slide-associated-images 2013_09_20_29.ndpi 
          macro
          $ vipsheader -f slide-associated-images CMU-1.svs
          label, macro, thumbnail


          You then pick out an associated image with perhaps:



          $ vips crop CMU-1.svs[associated=label] x.jpg 10 10 100 100


          To get a small part of the label.



          So ... check what associated images openslide reports for your slide. If you can get the one you need, pick that with the associated parameter. If the image you need is not listed, I would contact the openslide project, since they will need to add support.



          You could also check the openslide command-line tools, they might perhaps offer more options.






          share|improve this answer













          I've written this as an answer, though it's not really an answer. It seemed too long as just a comment.



          The libvips openslideload operation lets you pick an associated image to load. You can get a list of the associated images from the slide-associated-images metadata tag. For example:



          $ vipsheader -f slide-associated-images 2013_09_20_29.ndpi 
          macro
          $ vipsheader -f slide-associated-images CMU-1.svs
          label, macro, thumbnail


          You then pick out an associated image with perhaps:



          $ vips crop CMU-1.svs[associated=label] x.jpg 10 10 100 100


          To get a small part of the label.



          So ... check what associated images openslide reports for your slide. If you can get the one you need, pick that with the associated parameter. If the image you need is not listed, I would contact the openslide project, since they will need to add support.



          You could also check the openslide command-line tools, they might perhaps offer more options.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 '18 at 9:36









          jcupittjcupitt

          4,29411421




          4,29411421













          • Oh that looks fantastic, it was the "associated" keyword I was looking for. I will try it. In the meantime I already did a python script to do this for me but my DZI looks a bit weird in the smaller resolutions haha

            – Zloy Smiertniy
            Nov 22 '18 at 10:34











          • Oh no, sadly it didn't work. I tried vipsheader myimage.ndpi myimage.ndpi: 226176x90880 uchar, 4 bands, rgb, openslideload and vipsheader -f slide-associated-images : macro then I did vips crop myimage.ndpi[associated=macro] macrofromheader.dz 0 0 10000 10000 and it says extract_area: bad extract area

            – Zloy Smiertniy
            Nov 22 '18 at 10:38













          • Also for crop since crop is an alias of extract_area.

            – Zloy Smiertniy
            Nov 22 '18 at 10:41











          • Ok so now something worked and I am at a loss why but it is good. Thank you for helping me out! What I finally ran was vips extract_area myimage.ndpi[level=0] mypyramid.dz[tile-size=1024] 0 0 20000 20000 (which was the same from my question), but now it loads the colors properly. The only difference is the tile-size property for the dzi. I wonder if it is a bug because at first it only gave me a weird greyscale image.

            – Zloy Smiertniy
            Nov 22 '18 at 10:59













          • Oh huh how strange. level=0 is the default, you shouldn't need that. If you can find a smallish image which shows the problem, please open an issue on the libvips bug tracker github.com/libvips/libvips/issues/new

            – jcupitt
            Nov 22 '18 at 11:45



















          • Oh that looks fantastic, it was the "associated" keyword I was looking for. I will try it. In the meantime I already did a python script to do this for me but my DZI looks a bit weird in the smaller resolutions haha

            – Zloy Smiertniy
            Nov 22 '18 at 10:34











          • Oh no, sadly it didn't work. I tried vipsheader myimage.ndpi myimage.ndpi: 226176x90880 uchar, 4 bands, rgb, openslideload and vipsheader -f slide-associated-images : macro then I did vips crop myimage.ndpi[associated=macro] macrofromheader.dz 0 0 10000 10000 and it says extract_area: bad extract area

            – Zloy Smiertniy
            Nov 22 '18 at 10:38













          • Also for crop since crop is an alias of extract_area.

            – Zloy Smiertniy
            Nov 22 '18 at 10:41











          • Ok so now something worked and I am at a loss why but it is good. Thank you for helping me out! What I finally ran was vips extract_area myimage.ndpi[level=0] mypyramid.dz[tile-size=1024] 0 0 20000 20000 (which was the same from my question), but now it loads the colors properly. The only difference is the tile-size property for the dzi. I wonder if it is a bug because at first it only gave me a weird greyscale image.

            – Zloy Smiertniy
            Nov 22 '18 at 10:59













          • Oh huh how strange. level=0 is the default, you shouldn't need that. If you can find a smallish image which shows the problem, please open an issue on the libvips bug tracker github.com/libvips/libvips/issues/new

            – jcupitt
            Nov 22 '18 at 11:45

















          Oh that looks fantastic, it was the "associated" keyword I was looking for. I will try it. In the meantime I already did a python script to do this for me but my DZI looks a bit weird in the smaller resolutions haha

          – Zloy Smiertniy
          Nov 22 '18 at 10:34





          Oh that looks fantastic, it was the "associated" keyword I was looking for. I will try it. In the meantime I already did a python script to do this for me but my DZI looks a bit weird in the smaller resolutions haha

          – Zloy Smiertniy
          Nov 22 '18 at 10:34













          Oh no, sadly it didn't work. I tried vipsheader myimage.ndpi myimage.ndpi: 226176x90880 uchar, 4 bands, rgb, openslideload and vipsheader -f slide-associated-images : macro then I did vips crop myimage.ndpi[associated=macro] macrofromheader.dz 0 0 10000 10000 and it says extract_area: bad extract area

          – Zloy Smiertniy
          Nov 22 '18 at 10:38







          Oh no, sadly it didn't work. I tried vipsheader myimage.ndpi myimage.ndpi: 226176x90880 uchar, 4 bands, rgb, openslideload and vipsheader -f slide-associated-images : macro then I did vips crop myimage.ndpi[associated=macro] macrofromheader.dz 0 0 10000 10000 and it says extract_area: bad extract area

          – Zloy Smiertniy
          Nov 22 '18 at 10:38















          Also for crop since crop is an alias of extract_area.

          – Zloy Smiertniy
          Nov 22 '18 at 10:41





          Also for crop since crop is an alias of extract_area.

          – Zloy Smiertniy
          Nov 22 '18 at 10:41













          Ok so now something worked and I am at a loss why but it is good. Thank you for helping me out! What I finally ran was vips extract_area myimage.ndpi[level=0] mypyramid.dz[tile-size=1024] 0 0 20000 20000 (which was the same from my question), but now it loads the colors properly. The only difference is the tile-size property for the dzi. I wonder if it is a bug because at first it only gave me a weird greyscale image.

          – Zloy Smiertniy
          Nov 22 '18 at 10:59







          Ok so now something worked and I am at a loss why but it is good. Thank you for helping me out! What I finally ran was vips extract_area myimage.ndpi[level=0] mypyramid.dz[tile-size=1024] 0 0 20000 20000 (which was the same from my question), but now it loads the colors properly. The only difference is the tile-size property for the dzi. I wonder if it is a bug because at first it only gave me a weird greyscale image.

          – Zloy Smiertniy
          Nov 22 '18 at 10:59















          Oh huh how strange. level=0 is the default, you shouldn't need that. If you can find a smallish image which shows the problem, please open an issue on the libvips bug tracker github.com/libvips/libvips/issues/new

          – jcupitt
          Nov 22 '18 at 11:45





          Oh huh how strange. level=0 is the default, you shouldn't need that. If you can find a smallish image which shows the problem, please open an issue on the libvips bug tracker github.com/libvips/libvips/issues/new

          – jcupitt
          Nov 22 '18 at 11:45




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420846%2flibvips-extract-area-of-ndpi-from-ex40-not-from-map%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          'app-layout' is not a known element: how to share Component with different Modules

          android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

          WPF add header to Image with URL pettitions [duplicate]