{
  "id": 334643,
  "title": "HPA Data is not always (3000x3000)",
  "url": "/competitions/hubmap-organ-segmentation/discussion/334643",
  "author_name": "",
  "post_date": "2022-07-02T12:53:30.706048900Z",
  "votes": 8,
  "comment_count": 2,
  "views": 0,
  "content": "<p>Initially, I thought there was an error with the RLEs but it turns out that quite a lot of the HPA images aren't (3000x3000). </p>\n<p>Thank you <a href=\"https://www.kaggle.com/urosjarc\" target=\"_blank\">@urosjarc</a> for catching my mistake and helping :)</p>\n<hr>\n<p>I thought all the HPA images were 3000x3000 because in the <a href=\"https://www.kaggle.com/competitions/hubmap-organ-segmentation/data\" target=\"_blank\"><strong>data</strong></a> section the hosts say:</p>\n<blockquote>\n  <p>\"All HPA images are 3000 x 3000 pixels with a tissue area within the image around 2500 x 2500 pixels\"</p>\n</blockquote>\n<p>I didn't want to just delete this post after my realization in case anyone else makes the same mistake as me in assuming they are all 3000x3000 (a mistake I really shouldn't have made… but oh well). As such I renamed the post title to be more informative and will include the distribution of image sizes below:</p>\n<hr>\n<pre><code>3000    326\n2631      2\n2416      2\n2942      2\n2790      2\n2764      2\n2654      2\n2539      1\n2680      1\n2727      1\n2308      1\n2867      1\n2783      1\n2869      1\n2760      1\n2630      1\n2511      1\n2593      1\n2675      1\n3070      1\n</code></pre>",
  "messages": [
    {
      "id": "1840644",
      "postDate": "07/02/2022 12:53:30",
      "content": "<p>Initially, I thought there was an error with the RLEs but it turns out that quite a lot of the HPA images aren't (3000x3000). </p>\n<p>Thank you <a href=\"https://www.kaggle.com/urosjarc\" target=\"_blank\">@urosjarc</a> for catching my mistake and helping :)</p>\n<hr>\n<p>I thought all the HPA images were 3000x3000 because in the <a href=\"https://www.kaggle.com/competitions/hubmap-organ-segmentation/data\" target=\"_blank\"><strong>data</strong></a> section the hosts say:</p>\n<blockquote>\n  <p>\"All HPA images are 3000 x 3000 pixels with a tissue area within the image around 2500 x 2500 pixels\"</p>\n</blockquote>\n<p>I didn't want to just delete this post after my realization in case anyone else makes the same mistake as me in assuming they are all 3000x3000 (a mistake I really shouldn't have made… but oh well). As such I renamed the post title to be more informative and will include the distribution of image sizes below:</p>\n<hr>\n<pre><code>3000    326\n2631      2\n2416      2\n2942      2\n2790      2\n2764      2\n2654      2\n2539      1\n2680      1\n2727      1\n2308      1\n2867      1\n2783      1\n2869      1\n2760      1\n2630      1\n2511      1\n2593      1\n2675      1\n3070      1\n</code></pre>",
      "rawMarkdown": "Initially, I thought there was an error with the RLEs but it turns out that quite a lot of the HPA images aren't (3000x3000). \n\nThank you @urosjarc for catching my mistake and helping :)\n\n---\n\nI thought all the HPA images were 3000x3000 because in the [**data**](https://www.kaggle.com/competitions/hubmap-organ-segmentation/data) section the hosts say:\n\n> \"All HPA images are 3000 x 3000 pixels with a tissue area within the image around 2500 x 2500 pixels\"\n\nI didn't want to just delete this post after my realization in case anyone else makes the same mistake as me in assuming they are all 3000x3000 (a mistake I really shouldn't have made... but oh well). As such I renamed the post title to be more informative and will include the distribution of image sizes below:\n\n---\n\n```\n3000    326\n2631      2\n2416      2\n2942      2\n2790      2\n2764      2\n2654      2\n2539      1\n2680      1\n2727      1\n2308      1\n2867      1\n2783      1\n2869      1\n2760      1\n2630      1\n2511      1\n2593      1\n2675      1\n3070      1\n```",
      "votes": null
    },
    {
      "id": "1840682",
      "postDate": "07/02/2022 13:39:15",
      "content": "<p>Probably you are using decoding with 3000x3000 and it gets corrupted since this image is 2630x2630.</p>\n<p>Try to decode it with this function:</p>\n<pre><code>def decode_rle(rle: str, shape=(2630, 2630)):\n    rle = [int(i) for i in rle.split(' ')]\n    pairs = list(zip(rle[0::2], rle[1::2]))\n\n    p_loc = []\n\n    for start, length in pairs:\n        for p_pos in range(start, start + length):\n            p_loc.append((p_pos % shape[1], p_pos // shape[0]))\n\n    canvas = np.zeros(shape, dtype=np.uint8).T\n    canvas[tuple(zip(*p_loc))] = 1.0\n    return canvas\n</code></pre>\n<p>Here are my results with overlay…</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2386017%2F1df6def2496017f9b736826b3acafb4c%2Fresult.jpg?generation=1656768939441397&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "Probably you are using decoding with 3000x3000 and it gets corrupted since this image is 2630x2630.\n\nTry to decode it with this function:\n```\ndef decode_rle(rle: str, shape=(2630, 2630)):\n    rle = [int(i) for i in rle.split(' ')]\n    pairs = list(zip(rle[0::2], rle[1::2]))\n\n    p_loc = []\n\n    for start, length in pairs:\n        for p_pos in range(start, start + length):\n            p_loc.append((p_pos % shape[1], p_pos // shape[0]))\n\n    canvas = np.zeros(shape, dtype=np.uint8).T\n    canvas[tuple(zip(*p_loc))] = 1.0\n    return canvas\n```\n\nHere are my results with overlay...\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2386017%2F1df6def2496017f9b736826b3acafb4c%2Fresult.jpg?generation=1656768939441397&alt=media)",
      "votes": null
    },
    {
      "id": "1840690",
      "postDate": "07/02/2022 13:45:46",
      "content": "<p>You’re absolutely correct.</p>\n<p>I was confused by the hosts specifically saying:</p>\n<p>“All HPA images are 3000 x 3000 pixels”</p>\n<p>—-</p>\n<p>Thanks for this catch, I’ll double check things when I get back to a computer but this makes a lot of sense.</p>",
      "rawMarkdown": "You’re absolutely correct.\n\nI was confused by the hosts specifically saying:\n\n“All HPA images are 3000 x 3000 pixels”\n\n—-\n\nThanks for this catch, I’ll double check things when I get back to a computer but this makes a lot of sense.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1840682,
      "author_name": "urosjarc",
      "author_url": "",
      "post_date": "07/02/2022 13:39:15",
      "content": "<p>Probably you are using decoding with 3000x3000 and it gets corrupted since this image is 2630x2630.</p>\n<p>Try to decode it with this function:</p>\n<pre><code>def decode_rle(rle: str, shape=(2630, 2630)):\n    rle = [int(i) for i in rle.split(' ')]\n    pairs = list(zip(rle[0::2], rle[1::2]))\n\n    p_loc = []\n\n    for start, length in pairs:\n        for p_pos in range(start, start + length):\n            p_loc.append((p_pos % shape[1], p_pos // shape[0]))\n\n    canvas = np.zeros(shape, dtype=np.uint8).T\n    canvas[tuple(zip(*p_loc))] = 1.0\n    return canvas\n</code></pre>\n<p>Here are my results with overlay…</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2386017%2F1df6def2496017f9b736826b3acafb4c%2Fresult.jpg?generation=1656768939441397&amp;alt=media\" alt=\"\"></p>",
      "votes": null,
      "replies": [
        {
          "id": 1840690,
          "author_name": "dschettler8845",
          "author_url": "",
          "post_date": "07/02/2022 13:45:46",
          "content": "<p>You’re absolutely correct.</p>\n<p>I was confused by the hosts specifically saying:</p>\n<p>“All HPA images are 3000 x 3000 pixels”</p>\n<p>—-</p>\n<p>Thanks for this catch, I’ll double check things when I get back to a computer but this makes a lot of sense.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1840644": "Initially, I thought there was an error with the RLEs but it turns out that quite a lot of the HPA images aren't (3000x3000). \n\nThank you @urosjarc for catching my mistake and helping :)\n\n---\n\nI thought all the HPA images were 3000x3000 because in the [**data**](https://www.kaggle.com/competitions/hubmap-organ-segmentation/data) section the hosts say:\n\n> \"All HPA images are 3000 x 3000 pixels with a tissue area within the image around 2500 x 2500 pixels\"\n\nI didn't want to just delete this post after my realization in case anyone else makes the same mistake as me in assuming they are all 3000x3000 (a mistake I really shouldn't have made... but oh well). As such I renamed the post title to be more informative and will include the distribution of image sizes below:\n\n---\n\n```\n3000    326\n2631      2\n2416      2\n2942      2\n2790      2\n2764      2\n2654      2\n2539      1\n2680      1\n2727      1\n2308      1\n2867      1\n2783      1\n2869      1\n2760      1\n2630      1\n2511      1\n2593      1\n2675      1\n3070      1\n```",
    "1840682": "Probably you are using decoding with 3000x3000 and it gets corrupted since this image is 2630x2630.\n\nTry to decode it with this function:\n```\ndef decode_rle(rle: str, shape=(2630, 2630)):\n    rle = [int(i) for i in rle.split(' ')]\n    pairs = list(zip(rle[0::2], rle[1::2]))\n\n    p_loc = []\n\n    for start, length in pairs:\n        for p_pos in range(start, start + length):\n            p_loc.append((p_pos % shape[1], p_pos // shape[0]))\n\n    canvas = np.zeros(shape, dtype=np.uint8).T\n    canvas[tuple(zip(*p_loc))] = 1.0\n    return canvas\n```\n\nHere are my results with overlay...\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2386017%2F1df6def2496017f9b736826b3acafb4c%2Fresult.jpg?generation=1656768939441397&alt=media)",
    "1840690": "You’re absolutely correct.\n\nI was confused by the hosts specifically saying:\n\n“All HPA images are 3000 x 3000 pixels”\n\n—-\n\nThanks for this catch, I’ll double check things when I get back to a computer but this makes a lot of sense."
  },
  "source": "meta"
}