{
  "id": 197544,
  "title": "loading tiff using matplotlib.image",
  "url": "/competitions/hubmap-kidney-segmentation/discussion/197544",
  "author_name": "",
  "post_date": "2020-11-17T00:43:28.403631200Z",
  "votes": 3,
  "comment_count": 6,
  "views": 0,
  "content": "<p>I got the following error when loading tiff file using matplotlib.image. </p>\n<blockquote>\n  <p>DecompressionBombError: Image size (676985600 pixels) exceeds limit of 178956970 pixels, could be decompression bomb DOS attack.</p>\n</blockquote>\n<p>So, to avoid this, set MAX_IMAGE_PIXELS to None</p>\n<pre><code>from PIL import Image  \nImage.MAX_IMAGE_PIXELS = None\n</code></pre>\n<p>Also, we can only load few images in the given dataset. Other's will error out as they require more memory!</p>\n<p>Source: <a href=\"https://stackoverflow.com/questions/25705773/image-cropping-tool-python\" target=\"_blank\">StackOverflow Post</a></p>",
  "messages": [
    {
      "id": "1081286",
      "postDate": "11/17/2020 00:43:28",
      "content": "<p>I got the following error when loading tiff file using matplotlib.image. </p>\n<blockquote>\n  <p>DecompressionBombError: Image size (676985600 pixels) exceeds limit of 178956970 pixels, could be decompression bomb DOS attack.</p>\n</blockquote>\n<p>So, to avoid this, set MAX_IMAGE_PIXELS to None</p>\n<pre><code>from PIL import Image  \nImage.MAX_IMAGE_PIXELS = None\n</code></pre>\n<p>Also, we can only load few images in the given dataset. Other's will error out as they require more memory!</p>\n<p>Source: <a href=\"https://stackoverflow.com/questions/25705773/image-cropping-tool-python\" target=\"_blank\">StackOverflow Post</a></p>",
      "rawMarkdown": "I got the following error when loading tiff file using matplotlib.image. \n\n> DecompressionBombError: Image size (676985600 pixels) exceeds limit of 178956970 pixels, could be decompression bomb DOS attack.\n\nSo, to avoid this, set MAX_IMAGE_PIXELS to None\n\n```\nfrom PIL import Image  \nImage.MAX_IMAGE_PIXELS = None\n```\n\nAlso, we can only load few images in the given dataset. Other's will error out as they require more memory!\n\nSource: [StackOverflow Post](https://stackoverflow.com/questions/25705773/image-cropping-tool-python)",
      "votes": null
    },
    {
      "id": "1081290",
      "postDate": "11/17/2020 00:47:12",
      "content": "<p>I have tried the same method from stackoverflow. its tedious process. there is an easy option.<br>\nTry <a href=\"https://pypi.org/project/tifffile/\" target=\"_blank\">https://pypi.org/project/tifffile/</a></p>",
      "rawMarkdown": "I have tried the same method from stackoverflow. its tedious process. there is an easy option.\nTry https://pypi.org/project/tifffile/",
      "votes": null
    },
    {
      "id": "1081296",
      "postDate": "11/17/2020 00:54:20",
      "content": "<p>With tifffile, i keep getting an error when plotting it. Matplotlib complains about the wrong shape. When i checked the shape of the loaded file, its more than 3 dimensions. </p>",
      "rawMarkdown": "With tifffile, i keep getting an error when plotting it. Matplotlib complains about the wrong shape. When i checked the shape of the loaded file, its more than 3 dimensions.",
      "votes": null
    },
    {
      "id": "1081297",
      "postDate": "11/17/2020 00:56:33",
      "content": "<p>Yes.. I also faced the same.. only few images are working from the dataset. </p>\n<p>working image: 0486052bb.tiff</p>",
      "rawMarkdown": "Yes.. I also faced the same.. only few images are working from the dataset. \n\nworking image: 0486052bb.tiff",
      "votes": null
    },
    {
      "id": "1081298",
      "postDate": "11/17/2020 00:59:16",
      "content": "<p>probably tifffile is hiding the actual error. Matplotlib couldn't load saying memory not sufficient!</p>",
      "rawMarkdown": "probably tifffile is hiding the actual error. Matplotlib couldn't load saying memory not sufficient!",
      "votes": null
    },
    {
      "id": "1081363",
      "postDate": "11/17/2020 03:11:18",
      "content": "<p><a href=\"https://www.kaggle.com/rawwar\" target=\"_blank\">@rawwar</a>: This notebook should help:<br>\n<a href=\"https://www.kaggle.com/marcosnovaes/hubmap-read-data-and-build-tfrecords\" target=\"_blank\">https://www.kaggle.com/marcosnovaes/hubmap-read-data-and-build-tfrecords</a></p>",
      "rawMarkdown": "rawwar: This notebook should help:\n[https://www.kaggle.com/marcosnovaes/hubmap-read-data-and-build-tfrecords](https://www.kaggle.com/marcosnovaes/hubmap-read-data-and-build-tfrecords)",
      "votes": null
    },
    {
      "id": "1196677",
      "postDate": "02/11/2021 14:54:16",
      "content": "<p><a href=\"https://www.kaggle.com/rawwar\" target=\"_blank\">@rawwar</a> I arrived at the same solution after much searching.  I wish I found your post sooner.  </p>\n<p><a href=\"https://www.kaggle.com/marcosnovaes\" target=\"_blank\">@marcosnovaes</a> Thanks for providing the solution with tifffile.</p>\n<p>Although we have a solution, I'm still wanting to gain a deeper understanding of the other issue <a href=\"https://www.kaggle.com/rawwar\" target=\"_blank\">@rawwar</a> pointed out:  </p>\n<blockquote>\n  <blockquote>\n    <p>Also, we can only load few images in the given dataset. Other's will error out as they require more memory!  </p>\n  </blockquote>\n</blockquote>\n<p>Why doesn't reading in with tifffile module not error out?  Any insight into this issue will be greatly appreciated.</p>",
      "rawMarkdown": "rawwar I arrived at the same solution after much searching.  I wish I found your post sooner.  \n\n@marcosnovaes Thanks for providing the solution with tifffile.\n\nAlthough we have a solution, I'm still wanting to gain a deeper understanding of the other issue @rawwar pointed out:  \n> >Also, we can only load few images in the given dataset. Other's will error out as they require more memory!  \n\nWhy doesn't reading in with tifffile module not error out?  Any insight into this issue will be greatly appreciated.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1081290,
      "author_name": "subbuvolvosekar",
      "author_url": "",
      "post_date": "11/17/2020 00:47:12",
      "content": "<p>I have tried the same method from stackoverflow. its tedious process. there is an easy option.<br>\nTry <a href=\"https://pypi.org/project/tifffile/\" target=\"_blank\">https://pypi.org/project/tifffile/</a></p>",
      "votes": null,
      "replies": [
        {
          "id": 1081296,
          "author_name": "rawwar",
          "author_url": "",
          "post_date": "11/17/2020 00:54:20",
          "content": "<p>With tifffile, i keep getting an error when plotting it. Matplotlib complains about the wrong shape. When i checked the shape of the loaded file, its more than 3 dimensions. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1081297,
          "author_name": "subbuvolvosekar",
          "author_url": "",
          "post_date": "11/17/2020 00:56:33",
          "content": "<p>Yes.. I also faced the same.. only few images are working from the dataset. </p>\n<p>working image: 0486052bb.tiff</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1081298,
          "author_name": "rawwar",
          "author_url": "",
          "post_date": "11/17/2020 00:59:16",
          "content": "<p>probably tifffile is hiding the actual error. Matplotlib couldn't load saying memory not sufficient!</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1081363,
      "author_name": "marcosnovaes",
      "author_url": "",
      "post_date": "11/17/2020 03:11:18",
      "content": "<p><a href=\"https://www.kaggle.com/rawwar\" target=\"_blank\">@rawwar</a>: This notebook should help:<br>\n<a href=\"https://www.kaggle.com/marcosnovaes/hubmap-read-data-and-build-tfrecords\" target=\"_blank\">https://www.kaggle.com/marcosnovaes/hubmap-read-data-and-build-tfrecords</a></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1196677,
      "author_name": "sbpatel2009",
      "author_url": "",
      "post_date": "02/11/2021 14:54:16",
      "content": "<p><a href=\"https://www.kaggle.com/rawwar\" target=\"_blank\">@rawwar</a> I arrived at the same solution after much searching.  I wish I found your post sooner.  </p>\n<p><a href=\"https://www.kaggle.com/marcosnovaes\" target=\"_blank\">@marcosnovaes</a> Thanks for providing the solution with tifffile.</p>\n<p>Although we have a solution, I'm still wanting to gain a deeper understanding of the other issue <a href=\"https://www.kaggle.com/rawwar\" target=\"_blank\">@rawwar</a> pointed out:  </p>\n<blockquote>\n  <blockquote>\n    <p>Also, we can only load few images in the given dataset. Other's will error out as they require more memory!  </p>\n  </blockquote>\n</blockquote>\n<p>Why doesn't reading in with tifffile module not error out?  Any insight into this issue will be greatly appreciated.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1081286": "I got the following error when loading tiff file using matplotlib.image. \n\n> DecompressionBombError: Image size (676985600 pixels) exceeds limit of 178956970 pixels, could be decompression bomb DOS attack.\n\nSo, to avoid this, set MAX_IMAGE_PIXELS to None\n\n```\nfrom PIL import Image  \nImage.MAX_IMAGE_PIXELS = None\n```\n\nAlso, we can only load few images in the given dataset. Other's will error out as they require more memory!\n\nSource: [StackOverflow Post](https://stackoverflow.com/questions/25705773/image-cropping-tool-python)",
    "1081290": "I have tried the same method from stackoverflow. its tedious process. there is an easy option.\nTry https://pypi.org/project/tifffile/",
    "1081296": "With tifffile, i keep getting an error when plotting it. Matplotlib complains about the wrong shape. When i checked the shape of the loaded file, its more than 3 dimensions.",
    "1081297": "Yes.. I also faced the same.. only few images are working from the dataset. \n\nworking image: 0486052bb.tiff",
    "1081298": "probably tifffile is hiding the actual error. Matplotlib couldn't load saying memory not sufficient!",
    "1081363": "rawwar: This notebook should help:\n[https://www.kaggle.com/marcosnovaes/hubmap-read-data-and-build-tfrecords](https://www.kaggle.com/marcosnovaes/hubmap-read-data-and-build-tfrecords)",
    "1196677": "rawwar I arrived at the same solution after much searching.  I wish I found your post sooner.  \n\n@marcosnovaes Thanks for providing the solution with tifffile.\n\nAlthough we have a solution, I'm still wanting to gain a deeper understanding of the other issue @rawwar pointed out:  \n> >Also, we can only load few images in the given dataset. Other's will error out as they require more memory!  \n\nWhy doesn't reading in with tifffile module not error out?  Any insight into this issue will be greatly appreciated."
  },
  "source": "meta"
}