{
  "id": 332718,
  "title": "Dataset in JPG format",
  "url": "/competitions/hubmap-organ-segmentation/discussion/332718",
  "author_name": "David Roberts",
  "post_date": "2022-06-23T03:43:17.426000",
  "votes": 29,
  "comment_count": 10,
  "views": 0,
  "content": "<p>Here's the train_images dataset converted to JPG. The original pixel dimensions are maintained.</p>\n<p><a href=\"https://www.kaggle.com/datasets/davidbroberts/hubmap-hpa-jpg\" target=\"_blank\">https://www.kaggle.com/datasets/davidbroberts/hubmap-hpa-jpg</a></p>\n<p>This cuts the dataset down from ~8.7G -&gt; ~800MB.</p>\n<p>The original TIFF files are 16 bit and could be exported with filters or bit shifts to get more data as well. Let me know if anyone has any ideas and I'll do some other exports.</p>",
  "messages": [
    {
      "id": 1829920,
      "postDate": "2022-06-23T03:43:17.427Z",
      "content": "<p>Here's the train_images dataset converted to JPG. The original pixel dimensions are maintained.</p>\n<p><a href=\"https://www.kaggle.com/datasets/davidbroberts/hubmap-hpa-jpg\" target=\"_blank\">https://www.kaggle.com/datasets/davidbroberts/hubmap-hpa-jpg</a></p>\n<p>This cuts the dataset down from ~8.7G -&gt; ~800MB.</p>\n<p>The original TIFF files are 16 bit and could be exported with filters or bit shifts to get more data as well. Let me know if anyone has any ideas and I'll do some other exports.</p>",
      "rawMarkdown": "Here's the train_images dataset converted to JPG. The original pixel dimensions are maintained.\n\nhttps://www.kaggle.com/datasets/davidbroberts/hubmap-hpa-jpg\n\nThis cuts the dataset down from ~8.7G -> ~800MB.\n\nThe original TIFF files are 16 bit and could be exported with filters or bit shifts to get more data as well. Let me know if anyone has any ideas and I'll do some other exports.",
      "votes": 28
    },
    {
      "id": 1830648,
      "postDate": "2022-06-23T15:05:21.993Z",
      "content": "<p>Nice to have jpg to work with, files in jpg format are compressed and will lose some information compared to the tiff format though. Working with png might also be easier than tiff but will not be compressed, e.g no information lost.</p>",
      "rawMarkdown": "Nice to have jpg to work with, files in jpg format are compressed and will lose some information compared to the tiff format though. Working with png might also be easier than tiff but will not be compressed, e.g no information lost.",
      "votes": 3
    },
    {
      "id": 1830853,
      "postDate": "2022-06-23T18:10:32.090Z",
      "content": "<p>Been there, done that 👍. Thank you David.  I'll be waiting for yours remarkable Notebooks too.</p>",
      "rawMarkdown": "Been there, done that 👍. Thank you David.  I'll be waiting for yours remarkable Notebooks too.",
      "votes": 2
    },
    {
      "id": 1831597,
      "postDate": "2022-06-24T09:40:24.163Z",
      "content": "<p>Hi David,<br>\naccording to my EDA, using the tifffile lib the training tiffs are only 8 bit.</p>",
      "rawMarkdown": "Hi David,\naccording to my EDA, using the tifffile lib the training tiffs are only 8 bit.",
      "votes": 1,
      "replies": [
        {
          "id": 1832403,
          "postDate": "2022-06-25T02:44:29.447Z",
          "content": "<p>Thanks for pointing that out <a href=\"https://www.kaggle.com/friedchips\" target=\"_blank\">@friedchips</a>, I looked at the file weight and assumed they were 16 bit as most TIFFs in the medical imaging field are. Now I wonder why they use TIFF format if they only needed 8 bits.</p>",
          "rawMarkdown": "Thanks for pointing that out @friedchips, I looked at the file weight and assumed they were 16 bit as most TIFFs in the medical imaging field are. Now I wonder why they use TIFF format if they only needed 8 bits."
        },
        {
          "id": 1835177,
          "postDate": "2022-06-27T14:47:59.230Z",
          "content": "<p>I looked into this and a few of the images are indeed 16 bit. The raw pixel values exceed 0-255 range, not by much, but they are bigger than 8 bit.</p>",
          "rawMarkdown": "I looked into this and a few of the images are indeed 16 bit. The raw pixel values exceed 0-255 range, not by much, but they are bigger than 8 bit.",
          "votes": 1
        },
        {
          "id": 1851748,
          "postDate": "2022-07-11T13:51:47.033Z",
          "content": "<p>I'm using OpenCV for reading tiff files and all of them were 8 bit. I was reading them like this</p>\n<p><code>image = cv2.imread(image_filename, -1)</code></p>\n<p>Any library suggestions for dealing with tiff files?</p>\n<p>I tried using tifffile package for reading images but the outcome was same as OpenCV's imread. None of the images have pixel values greater than 255. OpenCV and tiffile imread methods return slightly different image arrays but their image mean values were exactly same. Some of the pixel values might deviate by 1 or 2 though.</p>",
          "rawMarkdown": "I'm using OpenCV for reading tiff files and all of them were 8 bit. I was reading them like this\n\n`image = cv2.imread(image_filename, -1)`\n\nAny library suggestions for dealing with tiff files?\n\nI tried using tifffile package for reading images but the outcome was same as OpenCV's imread. None of the images have pixel values greater than 255. OpenCV and tiffile imread methods return slightly different image arrays but their image mean values were exactly same. Some of the pixel values might deviate by 1 or 2 though."
        }
      ]
    },
    {
      "id": 1833617,
      "postDate": "2022-06-26T07:11:28.927Z",
      "content": "<p>Hi David, Could you share the process of how you did it? or a hint so we it can be used for other datasets too. This is already big help from you.</p>",
      "rawMarkdown": "Hi David, Could you share the process of how you did it? or a hint so we it can be used for other datasets too. This is already big help from you.",
      "replies": [
        {
          "id": 1834475,
          "postDate": "2022-06-27T01:01:00.263Z",
          "content": "<p>Sure, here's the code. It's really simple .. PIL does all the work, just open as tiff and save as jpg.</p>\n<pre><code>import os\nfrom PIL import Image\n\nfor file in os.listdir(\"train_images\"):\n    filename = os.fsdecode(file)\n    f = filename[:-4]\n    image = Image.open(\"train_images/\" + filename)\n    image.save(\"train_images_jpg/\" + f + \"jpg\")\n</code></pre>",
          "rawMarkdown": "Sure, here's the code. It's really simple .. PIL does all the work, just open as tiff and save as jpg.\n\n```\nimport os\nfrom PIL import Image\n\nfor file in os.listdir(\"train_images\"):\n    filename = os.fsdecode(file)\n    f = filename[:-4]\n    image = Image.open(\"train_images/\" + filename)\n    image.save(\"train_images_jpg/\" + f + \"jpg\")\n```",
          "votes": 2
        },
        {
          "id": 1835295,
          "postDate": "2022-06-27T16:22:09.973Z",
          "content": "<p>You are a genius. Thank you so much for your help.</p>",
          "rawMarkdown": "You are a genius. Thank you so much for your help."
        }
      ]
    },
    {
      "id": 1832379,
      "postDate": "2022-06-25T02:14:50.527Z",
      "content": "<p>Thank you David, it will help a lot</p>",
      "rawMarkdown": "Thank you David, it will help a lot",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 1830648,
      "author_name": "John Scanlan",
      "author_url": "",
      "post_date": "2022-06-23T15:05:21.993000",
      "content": "<p>Nice to have jpg to work with, files in jpg format are compressed and will lose some information compared to the tiff format though. Working with png might also be easier than tiff but will not be compressed, e.g no information lost.</p>",
      "votes": 3,
      "replies": []
    },
    {
      "id": 1830853,
      "author_name": "Marília Prata",
      "author_url": "",
      "post_date": "2022-06-23T18:10:32.090000",
      "content": "<p>Been there, done that 👍. Thank you David.  I'll be waiting for yours remarkable Notebooks too.</p>",
      "votes": 2,
      "replies": []
    },
    {
      "id": 1831597,
      "author_name": "Markus Frank",
      "author_url": "",
      "post_date": "2022-06-24T09:40:24.163000",
      "content": "<p>Hi David,<br>\naccording to my EDA, using the tifffile lib the training tiffs are only 8 bit.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 1832403,
          "author_name": "David Roberts",
          "author_url": "",
          "post_date": "2022-06-25T02:44:29.447000",
          "content": "<p>Thanks for pointing that out <a href=\"https://www.kaggle.com/friedchips\" target=\"_blank\">@friedchips</a>, I looked at the file weight and assumed they were 16 bit as most TIFFs in the medical imaging field are. Now I wonder why they use TIFF format if they only needed 8 bits.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1835177,
          "author_name": "David Roberts",
          "author_url": "",
          "post_date": "2022-06-27T14:47:59.230000",
          "content": "<p>I looked into this and a few of the images are indeed 16 bit. The raw pixel values exceed 0-255 range, not by much, but they are bigger than 8 bit.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1851748,
          "author_name": "Gunes Evitan",
          "author_url": "",
          "post_date": "2022-07-11T13:51:47.033000",
          "content": "<p>I'm using OpenCV for reading tiff files and all of them were 8 bit. I was reading them like this</p>\n<p><code>image = cv2.imread(image_filename, -1)</code></p>\n<p>Any library suggestions for dealing with tiff files?</p>\n<p>I tried using tifffile package for reading images but the outcome was same as OpenCV's imread. None of the images have pixel values greater than 255. OpenCV and tiffile imread methods return slightly different image arrays but their image mean values were exactly same. Some of the pixel values might deviate by 1 or 2 though.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1833617,
      "author_name": "Jims Chacko",
      "author_url": "",
      "post_date": "2022-06-26T07:11:28.927000",
      "content": "<p>Hi David, Could you share the process of how you did it? or a hint so we it can be used for other datasets too. This is already big help from you.</p>",
      "votes": 0,
      "replies": [
        {
          "id": 1834475,
          "author_name": "David Roberts",
          "author_url": "",
          "post_date": "2022-06-27T01:01:00.263000",
          "content": "<p>Sure, here's the code. It's really simple .. PIL does all the work, just open as tiff and save as jpg.</p>\n<pre><code>import os\nfrom PIL import Image\n\nfor file in os.listdir(\"train_images\"):\n    filename = os.fsdecode(file)\n    f = filename[:-4]\n    image = Image.open(\"train_images/\" + filename)\n    image.save(\"train_images_jpg/\" + f + \"jpg\")\n</code></pre>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 1835295,
          "author_name": "Jims Chacko",
          "author_url": "",
          "post_date": "2022-06-27T16:22:09.973000",
          "content": "<p>You are a genius. Thank you so much for your help.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1832379,
      "author_name": "",
      "author_url": "",
      "post_date": "2022-06-25T02:14:50.527000",
      "content": "<p>Thank you David, it will help a lot</p>",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1829920": "Here's the train_images dataset converted to JPG. The original pixel dimensions are maintained.\n\nhttps://www.kaggle.com/datasets/davidbroberts/hubmap-hpa-jpg\n\nThis cuts the dataset down from ~8.7G -> ~800MB.\n\nThe original TIFF files are 16 bit and could be exported with filters or bit shifts to get more data as well. Let me know if anyone has any ideas and I'll do some other exports.",
    "1830648": "Nice to have jpg to work with, files in jpg format are compressed and will lose some information compared to the tiff format though. Working with png might also be easier than tiff but will not be compressed, e.g no information lost.",
    "1830853": "Been there, done that 👍. Thank you David.  I'll be waiting for yours remarkable Notebooks too.",
    "1831597": "Hi David,\naccording to my EDA, using the tifffile lib the training tiffs are only 8 bit.",
    "1833617": "Hi David, Could you share the process of how you did it? or a hint so we it can be used for other datasets too. This is already big help from you.",
    "1832379": "Thank you David, it will help a lot"
  }
}