{
  "id": 286059,
  "title": "Python Lists",
  "url": "/competitions/sartorius-cell-instance-segmentation/discussion/286059",
  "author_name": "",
  "post_date": "2021-11-07T18:28:56.061929900Z",
  "votes": 2,
  "comment_count": 1,
  "views": 0,
  "content": "<p>I come with the following code:</p>\n<blockquote>\n  <p>starts = list(map(lambda x: int(x) - 1, s[0::2]))<br>\n      lengths = list(map(int, s[1::2]))<br>\n      ends = [x + y for x, y in zip(starts, lengths)]</p>\n</blockquote>\n<pre><code>img = np.zeros((shape[0] * shape[1], shape[2]), dtype=np.float32)\n\nfor start, end in zip(starts, ends):\n    img[start : end] = color\n\nreturn img.reshape(shape)\n</code></pre>\n<p>The question is: what is exactly <em>ends</em> list and img? </p>",
  "messages": [
    {
      "id": "1574640",
      "postDate": "11/07/2021 18:28:56",
      "content": "<p>I come with the following code:</p>\n<blockquote>\n  <p>starts = list(map(lambda x: int(x) - 1, s[0::2]))<br>\n      lengths = list(map(int, s[1::2]))<br>\n      ends = [x + y for x, y in zip(starts, lengths)]</p>\n</blockquote>\n<pre><code>img = np.zeros((shape[0] * shape[1], shape[2]), dtype=np.float32)\n\nfor start, end in zip(starts, ends):\n    img[start : end] = color\n\nreturn img.reshape(shape)\n</code></pre>\n<p>The question is: what is exactly <em>ends</em> list and img? </p>",
      "rawMarkdown": "I come with the following code:\n\n> starts = list(map(lambda x: int(x) - 1, s[0::2]))\n    lengths = list(map(int, s[1::2]))\n    ends = [x + y for x, y in zip(starts, lengths)]\n    \n    img = np.zeros((shape[0] * shape[1], shape[2]), dtype=np.float32)\n            \n    for start, end in zip(starts, ends):\n        img[start : end] = color\n    \n    return img.reshape(shape)\n\nThe question is: what is exactly *ends* list and img?",
      "votes": null
    },
    {
      "id": "1575579",
      "postDate": "11/08/2021 13:38:05",
      "content": "<p>More context would be useful, but it looks to me like decoding RLE. See this discussion for what it is: <a href=\"https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/278936\" target=\"_blank\">https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/278936</a></p>\n<p>In short we represent mask as consecutive blocks of 1s (or black pixels). Each block can be described by where it starts and how long it is. That's what is inside the <code>starts</code> and <code>lengths</code> lists. <code>img</code> is the result of this decoding.</p>",
      "rawMarkdown": "More context would be useful, but it looks to me like decoding RLE. See this discussion for what it is: https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/278936\n\nIn short we represent mask as consecutive blocks of 1s (or black pixels). Each block can be described by where it starts and how long it is. That's what is inside the `starts` and `lengths` lists. `img` is the result of this decoding.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1575579,
      "author_name": "slawekbiel",
      "author_url": "",
      "post_date": "11/08/2021 13:38:05",
      "content": "<p>More context would be useful, but it looks to me like decoding RLE. See this discussion for what it is: <a href=\"https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/278936\" target=\"_blank\">https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/278936</a></p>\n<p>In short we represent mask as consecutive blocks of 1s (or black pixels). Each block can be described by where it starts and how long it is. That's what is inside the <code>starts</code> and <code>lengths</code> lists. <code>img</code> is the result of this decoding.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1574640": "I come with the following code:\n\n> starts = list(map(lambda x: int(x) - 1, s[0::2]))\n    lengths = list(map(int, s[1::2]))\n    ends = [x + y for x, y in zip(starts, lengths)]\n    \n    img = np.zeros((shape[0] * shape[1], shape[2]), dtype=np.float32)\n            \n    for start, end in zip(starts, ends):\n        img[start : end] = color\n    \n    return img.reshape(shape)\n\nThe question is: what is exactly *ends* list and img?",
    "1575579": "More context would be useful, but it looks to me like decoding RLE. See this discussion for what it is: https://www.kaggle.com/c/sartorius-cell-instance-segmentation/discussion/278936\n\nIn short we represent mask as consecutive blocks of 1s (or black pixels). Each block can be described by where it starts and how long it is. That's what is inside the `starts` and `lengths` lists. `img` is the result of this decoding."
  },
  "source": "meta"
}